Skip to content

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

Closed
@gopherbot

Description

@gopherbot

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions