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.Do should mask EOF as ErrUnexpectedEOF #18055

Open
dsnet opened this issue Nov 26, 2016 · 3 comments
Open

net/http: client.Do should mask EOF as ErrUnexpectedEOF #18055

dsnet opened this issue Nov 26, 2016 · 3 comments
Labels
Milestone

Comments

@dsnet
Copy link
Member

@dsnet dsnet commented Nov 26, 2016

func Test(t *testing.T) {
	server := httptest.NewServer(
		http.HandlerFunc(
			func(w http.ResponseWriter, r *http.Request) {
				rwc, _, _ := w.(http.Hijacker).Hijack()
				defer rwc.Close()
			},
		),
	)
	defer server.Close()

	_, err := http.Get(server.URL)
	if err != nil {
		t.Fatalf("GET returned error: %v", err)
	}
}

The preceding test prints GET returned error: EOF, which is strange since io.EOF is often an "error" signaling normal termination of some stream. Instead, Do should mask the error as io.ErrUnexpectedEOF, which is more indicative of an abrupt termination.

@dsnet dsnet added this to the Go1.9Maybe milestone Nov 26, 2016
@dsnet dsnet added the NeedsFix label Nov 26, 2016
@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Nov 26, 2016

We tried to fix this once and had to revert it. There's a testing locking in this behavior. :-/

But maybe we can revisit.

@ibrasho
Copy link
Contributor

@ibrasho ibrasho commented Jan 22, 2017

@bradfitz Can you link the old fix for reference?

@bradfitz
Copy link
Contributor

@bradfitz bradfitz commented Jan 22, 2017

@ibrasho, you can probably find it in git history as quickly as I could. (which might not be super quick)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.