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: Response.Body.Read fails with "use of closed network connection" on some servers #4704

Closed
gopherbot opened this issue Jan 24, 2013 · 8 comments
Milestone

Comments

@gopherbot
Copy link

by meyermagic:

What steps will reproduce the problem?
1. Run attached code on either of the following URLS:
http://repo.bukkit.org/index.html
http://217.19.223.2:20001

What is the expected output?
There should be no output.

What do you see instead?
2013/01/24 11:17:06 use of closed network connection

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

Which operating system are you using?
Linux 3.5.0-22-generic #34-Ubuntu SMP Tue Jan 8 21:47:00 UTC 2013 x86_64 GNU/Linux
(64-bit Ubuntu on Linux 3.5.x)

Which version are you using?  (run 'go version')
go1.0.2

Please provide any additional information below.
Test cases here: https://gist.github.com/4626358
There is ongoing discussion of this bug here:
https://groups.google.com/forum/?fromgroups=#!topic/golang-nuts/_DA71u569uw
This bug is probably related: https://golang.org/issue/3643

Synopsis:
Response.Body.Read seems to fail on HTTP 1.0 servers that do not send a
"Connection: Keep-Alive" header.

Attachments:

  1. mini.go (485 bytes)
@davecheney
Copy link
Contributor

Comment 1:

Are you able to reproduce the issue with tip? A lot of improvements to net/http went
into 1.0.3, and a bunch more went in after 1.0.3 was released. It is possible this issue
is fixed in tip and will be fixed when 1.1 ships (soon)

Status changed to WaitingForReply.

@gopherbot
Copy link
Author

Comment 2 by meyermagic:

I haven't tested on 1.0.3, I will tonight.
One of the users in this thread reported the bug occurring in 1.0.3, though:
https://groups.google.com/d/msg/golang-nuts/_DA71u569uw/jGpIssYwznUJ

@gopherbot
Copy link
Author

Comment 3 by meyermagic:

I haven't tested on 1.0.3. I'll test on 1.0.3 and on the current bleeding edge tonight.
One of the users in this thread reported the bug occurring in 1.0.3, though:
https://groups.google.com/d/msg/golang-nuts/_DA71u569uw/jGpIssYwznUJ

@davecheney
Copy link
Contributor

Comment 4:

Summary as I understand it: net/http may be confused in the face of HTTP/1.0 servers
that use the non standard (there is no standard in HTTP/1.0) Connection: Keep-Alive
mechanism.

@davecheney
Copy link
Contributor

Comment 6:

lucky(~/src) % hg id $GOROOT
45a405b5c63a+ tip
lucky(~/src) % go run get.go
&http.Response{Status:"200 OK", StatusCode:200, Proto:"HTTP/1.1", ProtoMajor:1,
ProtoMinor:1, Header:http.Header{"Vary":[]string{"Accept-Charset, Accept-Encoding,
Accept-Language, Accept"}, "Content-Type":[]string{"text/html"},
"Server":[]string{"Noelios-Restlet-Engine/1.1.6-SONATYPE-5348-V4"},
"Date":[]string{"Fri, 25 Jan 2013 10:40:50 GMT", "Fri, 25 Jan 2013 10:40:50 GMT"}},
Body:(*http.bodyEOFSignal)(0xc20008e8c0), ContentLength:-1,
TransferEncoding:[]string(nil), Close:true, Trailer:http.Header(nil),
Request:(*http.Request)(0xc2000ad1a0)}
&http.Request{Method:"GET", URL:(*url.URL)(0xc200079310), Proto:"HTTP/1.1",
ProtoMajor:1, ProtoMinor:1, Header:http.Header{}, Body:io.ReadCloser(nil),
ContentLength:0, TransferEncoding:[]string(nil), Close:false, Host:"repo.bukkit.org",
Form:url.Values(nil), PostForm:url.Values(nil), MultipartForm:(*multipart.Form)(nil),
Trailer:http.Header(nil), RemoteAddr:"", RequestURI:"", TLS:(*tls.ConnectionState)(nil)}

@gopherbot
Copy link
Author

Comment 7 by meyermagic:

I can't reproduce in go 1.0.3.
meyer@meter:~/Code/golang/go$ hg id
2d8bc3c94ecb (release-branch.go1) go1.0.3/release
meyer@meter:~/Code/golang/go$ ./bin/go get -x mini
WORK=/tmp/go-build936265783
mkdir -p $WORK/mini/_obj/
cd /home/meyer/Code/go/src/mini
/home/meyer/Code/golang/go/pkg/tool/linux_amd64/6g -o $WORK/mini/_obj/_go_.6 -p mini -D
_/home/meyer/Code/go/src/mini -I $WORK ./mini.go
/home/meyer/Code/golang/go/pkg/tool/linux_amd64/pack grcP $WORK $WORK/mini.a
$WORK/mini/_obj/_go_.6
cd .
/home/meyer/Code/golang/go/pkg/tool/linux_amd64/6l -o $WORK/mini/_obj/a.out -L $WORK
$WORK/mini.a
mkdir -p /home/meyer/Code/go/bin/
cp $WORK/mini/_obj/a.out /home/meyer/Code/go/bin/mini
meyer@meter:~/Code/golang/go$ $GOPATH/bin/mini
Sorry for the unnecessary bug report, and keep up the good work!

@bradfitz
Copy link
Contributor

Comment 8:

Status changed to Retracted.

@niemeyer
Copy link
Contributor

Comment 9:

For the record, this is most probably issue #4914.

@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

5 participants