Hello world/Web server task on RosettaCode fails

btiffin btiffin at gnu.org
Sat Jul 17 04:13:53 UTC 2021


On Friday, 16 July 2021 at 20:04:21 UTC, jfondren wrote:
> On Friday, 16 July 2021 at 19:25:32 UTC, btiffin wrote:
>> Using gdc-11 and Seamonkey.  
>> https://rosettacode.org/wiki/Hello_world/Web_server#D does not 
>> compile.
>
> The `while` as you noted is wrong. The server also doesn't turn 
> REUSEADDR on for the server socket, so this will be very 
> annoying to test as you'll frequently get "address already in 
> use" errors when you restart the server. The delimited string 
> leads to your last problem: a blank space between the headers 
> and the body of the response results in "\r\n \r\n" being sent 
> rather than "\r\n\r\n", so the browser gives up on the invalid 
> HTTP.

Ahh, thanks.  The spaces.  And turning on REUSEADDR made playing 
with the code a fair bit more fun.

But, I mainly made the note to motivate a D aficionado to update 
and fix the Rosetta entry so that it at least compiles. Perhaps 
the whole *be bold* thing, and make the sources as idiomatic and 
correctly concise as D deserves.  As a for instance, task 
description calls for Goodbye as the text in the solution.

>
> This works if you're careful to not re-add any stray whitespace 
> in the response:
...
>
> But this *still violates HTTP* by not receiving the client's 
> request, so it's still not a good answer for the task. A vibe 
> hello world would make a lot more sense:
> https://github.com/vibe-d/vibe.d/blob/master/examples/http_server/source/app.d
>
>> If this is the wrong place for this kind of info note, I'll 
>> gladly move to or redo the post in a more appropriate spot.
>
> You're in the right place.

Cool.  It's a nice place.  :-)

Cheers


More information about the Digitalmars-d-learn mailing list