aesiniath / http-streams

Haskell HTTP client library for use with io-streams
https://hackage.haskell.org/package/http-streams
BSD 3-Clause "New" or "Revised" License
50 stars 48 forks source link

Possibly not handling 204 responses properly #26

Closed MichaelXavier closed 11 years ago

MichaelXavier commented 11 years ago

I'm doing some testing with a server that returns 204 no content. I've implemented the test server in scotty and snap and for both, http-streams hangs indefinitely on 204 responses with no content. Here's a minimal example:

https://gist.github.com/MichaelXavier/5475167

Just for fun, I made another server in Ruby's sinatra library to return a 204. http-streams handled it fine. I hit both with curl and saw this difference:

ruby:
* Adding handle: conn: 0xc46de0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0xc46de0) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 4567 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 4567 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:4567
> Accept: */*
> 
< HTTP/1.1 204 No Content
< X-Content-Type-Options: nosniff
< Connection: close
* Server thin 1.5.1 codename Straight Razor is not blacklisted
< Server: thin 1.5.1 codename Straight Razor
< 
* Closing connection 0

scotty:
* Adding handle: conn: 0x76ade0
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x76ade0) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 4568 (#0)
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 4568 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.30.0
> Host: localhost:4568
> Accept: */*
> 
< HTTP/1.1 204 No Content
* Server Warp/1.3.8 is not blacklisted
< Server: Warp/1.3.8
< 
* Connection #0 to host localhost left intact

I think the difference is that warp and snap are leaving the connection intact and http-streams isn't closing it?

istathar commented 11 years ago

This may be #25.

AfC

istathar commented 11 years ago

@MichaelXavier Can you test and see if your issue is resolved by v0.5.0.2?

AfC

MichaelXavier commented 11 years ago

Indeed it does. Thanks guys!