Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: client fails to handle requests with no body and chunked encoding #4454

Closed
gopherbot opened this issue Nov 27, 2012 · 3 comments
Closed
Milestone

Comments

@gopherbot
Copy link

by dimiter.naydenov:

I run into this issue and after investigating, it seems it's indeed a bug in net/http,
so I decided to file it here.

What steps will reproduce the problem?
If possible, include a link to a program on play.golang.org.
1. Use the example provided here: http://paste.ubuntu.com/1392332/
2. Run it, it should produce no output
3. But instead it fails on every second request

After investigating, it seems the net/http/client handling the responses with
Transfer-Encoding: chunked and no body (204 No Content, for example) fails, when the
body is "0\r\n" - as per the specs, but that part is confusing the client
somehow. 

What is the expected output?

No output

What do you see instead?

req #1: Get http://localhost:1234/: malformed HTTP response "0"
req #3: Get http://localhost:1234/: malformed HTTP response "0"
req #5: Get http://localhost:1234/: malformed HTTP response "0"
req #7: Get http://localhost:1234/: malformed HTTP response "0"
req #9: Get http://localhost:1234/: malformed HTTP response "0"
...
(every odd request fails)

Which compiler are you using (5g, 6g, 8g, gccgo)?

Tested both with go1.0.3 and go-tip, not using gccgo.

Which operating system are you using?

Linux kubrik 3.2.0-33-generic #52-Ubuntu SMP Thu Oct 18 16:29:15 UTC 2012 x86_64 x86_64
x86_64 GNU/Linux

Which version are you using?  (run 'go version')

go version go1.0.3
(but tested with go version devel +2874a9297c4b Thu Nov 22 01:25:53 2012 +1100 as well)

Please provide any additional information below.
I think I said all above.
@bradfitz
Copy link
Contributor

Comment 1:

Owner changed to @bradfitz.

Status changed to Accepted.

@bradfitz
Copy link
Contributor

Comment 2:

Confirmed. This only happens when you don't close the request body of the previous
request.
Nice find!
Will fix.

@bradfitz
Copy link
Contributor

Comment 3:

This issue was closed by revision 9c2f410.

Status changed to Fixed.

@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1 label Apr 14, 2015
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants