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
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dsnet
Copy link
Member

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 The path to resolution is known, but the work has not been done. label Nov 26, 2016
@bradfitz
Copy link
Contributor

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 commented Jan 22, 2017

@bradfitz Can you link the old fix for reference?

@bradfitz
Copy link
Contributor

@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
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

5 participants