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/httptest: Server.CloseClientConnections does not force a connection error in go1.6rc2 #14290

Closed
superbaddude opened this issue Feb 10, 2016 · 5 comments

Comments

@superbaddude
Copy link

reference code: http://play.golang.org/p/MLJM0N3_SH

in go1.6rc2, the reference code returns a nil error and a valid response object with a 200 status code.
in go1.5.2, the reference code produced an error, something like:
Get http://127.0.0.1:2: EOF

this prevents being able to test error handling when a http request is unexpectedly disconnected from by the remote server.

  • go version: go1.6rc1 linux/amd64
  • os: ubuntu 14.04 x86_64
@ianlancetaylor ianlancetaylor changed the title httptest.Server.CloseClientConnections does not force a connection error in go1.6rc2 net/http/httptest: Server.CloseClientConnections does not force a connection error in go1.6rc2 Feb 10, 2016
@ianlancetaylor
Copy link
Contributor

CC @bradfitz

@bradfitz
Copy link
Contributor

Interesting... we have no test coverage for CloseClientConnections at all. And because CloseClientConnections just uses an internal closeConn function, and closeConn was made async for an earlier change, it ended up making CloseClientConnections async, which we then never noticed for lack of tests.

I filed #14291 to investigate making closeConn not async for Go 1.7, but for Go 1.6 we can probably just fix CloseClientConnections to wait on the conns being closed before returning, which would prevent your handler from then replying with 200 OK. (I can reproduce)

I'll add this as a test, too.

@bradfitz bradfitz self-assigned this Feb 10, 2016
@bradfitz bradfitz added this to the Go1.6Maybe milestone Feb 10, 2016
@gopherbot
Copy link

CL https://golang.org/cl/19432 mentions this issue.

@nbari
Copy link

nbari commented Feb 27, 2016

Any possible example of this fix on play.golang.org.

thanks in advance.

@superbaddude
Copy link
Author

http://play.golang.org/p/MLJM0N3_SH

however, the bug was resolved with a temporary workaround prior to release
of go1.6. the bug exists in go1.6rc2.

On Sat, Feb 27, 2016 at 4:11 AM, Nicolas Embriz notifications@github.com
wrote:

Any possible example of this fix on play.golang.org.

thanks in advance.


Reply to this email directly or view it on GitHub
#14290 (comment).

@golang golang locked and limited conversation to collaborators Feb 28, 2017
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