Content-Length header is duplicated if set via UserHeader #59

Closed
gorenje opened this Issue Mar 18, 2013 · 3 comments

Comments

Projects
None yet
2 participants

gorenje commented Mar 18, 2013

If you provide the Content-Length header via the user headers for a response, the content length will be duplicated in the response header.

Example:

Typical handle for elli:

handle('GET',[], Req) ->
    TrackingPixelData = <<71,73,70,56,57,97,1,0,1,0,128,1,0,0,0,0,255,255,255,33,
                         249,4,1,0,0,1,0,44,0,0,0,0,1,0,1,0,0,2,2,76,1,0,59>>,
    {ok, [{<<"Connection">>, <<"close">>}, {<<"Content-Length">>,<<"43">>}, {<<"Content-Type">>, <<"image/gif">>}],
     TrackingPixelData};

Response Header:

prompt> curl -v "http://localhost:3000/?sdasda"
* About to connect() to localhost port 3000 (#0)
*   Trying ::1...
* Connection refused
*   Trying 127.0.0.1...
* connected
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET /?sdasda HTTP/1.1
> User-Agent: curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8r zlib/1.2.5
> Host: localhost:3000
> Accept: */*
> 
< HTTP/1.1 200 OK
< Content-Length: 43
< Connection: close
< Content-Lengthd: 43
< Content-Type: image/gif
< 
* Closing connection #0
GIF89a????!?,L;

This happens because of this line and this line.

It would seem to be a trival issue but this causes some Amazon ELBs to fall-over and send out a 502 Bad Gateway. In our case, heroku dynos were responding with 200 but the dynos responses were causing the ELBs to fall over, in turn, sending out a 502.

gorenje commented Mar 18, 2013

i was going to provide a patch, but httpc:request suppresses the duplicated header and makes one entry out of the two. Perhaps lhttpc would be a better bet.

Owner

knutin commented Mar 19, 2013

Thanks for letting me know. There is a fix in the user_content_length branch. Let me know if it solves the ELB issues, then I'll merge it to master.

gorenje commented Mar 20, 2013

Thanks - deployed and working perfectly!

knutin closed this in 4b1ba4c Mar 23, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment