Error response in linux listener

Mar 5, 2014 at 10:51 AM
Edited Mar 5, 2014 at 11:05 AM
Hello all,

thanks for this great piece of software.
We are using the http_listener (master branch) in linux to implement a REST api and everything seems to work smooth, but we have a small problem with the error cases.
Althought the error is reported as it should be, the connection "stays" alive. Is this the desired behaviour? Is it client issue? The issue can be easilly reproduced with the blackjackserver:

BlackJackServer:
Listening for requests at: http://localhost:34568/blackjack/dealer
Press ENTER to exit.
GET http://localhost:34568/blackjack/dealer HTTP/1.1
Accept: */*
Host: localhost:34568
User-Agent: curl/7.29.0


GET http://localhost:34568/blackjack/dealer/4343 HTTP/1.1
Accept: */*
Host: localhost:34568
User-Agent: curl/7.29.0

GET http://localhost:34568/blackjack/dealer/32323 HTTP/1.1
Accept: */*
Host: localhost:34568
User-Agent: curl/7.29.0
Using curl as client:
#curl -i -k http://localhost:34568/blackjack/dealer
HTTP/1.1 200 OK
Content-Length: 130
Content-Type: application/json

[{"Id":1,"Capacity":8,"Players":[{"Name":"DEALER","Balance":1000,"Hand":{"state":0,"result":0,"bet":0,"insurance":0,"cards":]}}]}]


# curl -i -k http://localhost:34568/blackjack/dealer/4343
HTTP/1.1 404 Not Found

(stays pending, have to interrupt to exit) 
^C  

# curl  -f -i -k http://localhost:34568/blackjack/dealer/32323
curl: (22) The requested URL returned error: 404 Not Found
thanks in advance,

-Apostolos
Coordinator
Mar 10, 2014 at 9:36 PM
Hi Apostolos,

We've reproduced the issue you've described and are working on a solution. Thanks for the report; we'll hopefully have more info soon.

Thanks,
roschuma
Coordinator
Mar 10, 2014 at 9:59 PM
Hi again,

You've definitely hit a bug here, so thanks for bringing it to our attention. Turns out http_listener does not specify a Content-Length and does not close the connection when sending a default 404, which causes the client to wait indefinitely for a response.

We won't be able to include the fix in the next release, but we will certainly fix it for the release after.

If this behavior is a critical issue, you can work around it by sending your own custom 404 messages.

Sincerely,
roschuma
Marked as answer by amanol on 3/14/2014 at 5:22 AM