[erlang-bugs] inets-4.7.16 doesn't handle HTTP 204 responses

Ingela Anderton Andin ingela@REDACTED
Thu Nov 22 11:27:43 CET 2007


Hi!

Thank you for reporting this bug and for the patch suggestion. I have 
fixed the problem in inets-5.0 that
will be released in r12b early december. 

Regards Ingela - OTP team

Andrew Birkett wrote:
> Hi,
>
> I've been writing an erlang wrapper for Amazon's S3 storage service, 
> and I've found a problem with the way inets-4.7.16 (from 
> otp_src_R11B-5) handles the HTTP 204 (No content) status code.  I've 
> attached a suggested patch, and also included a method of reproducing 
> the problem.
>
> According to RFC 2616 section 4.3, a 204 response 'must not' contain 
> an entity body.  Therefore the content-length header is optional and 
> should be ignored regardless.
>
> The erlang library wrongly tries to use the content-length header when 
> it receives a 204 reply.  If the content-length header is not present, 
> httpc_handler tries to listen for more bytes on the socket.  With a 
> persistent HTTP connection, this means the application appears to hang.
>
> Attached is a patch against inets-4.7.16 which fixes this issue.  I've 
> only recently started using erlang, so I hope it's okay.  Also, here 
> is a way of reproducing the problem on unix using the socat utility as 
> a mock webserver.
>
> 1. Create a 'reply-204-no-content-length' script containing the 
> following:
> #!/bin/bash
> sleep 1
> echo -ne 'HTTP/1.1 204 No Content\r\nSomeHeader: foo\r\n\r\n'
> sleep 100
>
> 2. Run socat tcp-listen:9999,reuseaddr exec:./reply-204
>
> 3. Evaluate: http:request(put, {"http://localhost:9999/", 
> [{"Content-Length","1"}, {"Content-Type","text/plain"}], [], 
> <<1>>},[],[{sync,true}]).
>
> 4. This will hang for 101 seconds.  The call ultimately only returns 
> because socat has closed the connection.  With the patch applied, the 
> call returns immediately once the HTTP reply is received.
>
> Andrew
> -- 
> - http://www.nobugs.org -
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> erlang-bugs mailing list
> erlang-bugs@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-bugs




More information about the erlang-bugs mailing list