Skip to content

net/http: add ResponseController http2 request without body read deadline test #58282

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/net/http/responsecontroller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,3 +326,18 @@ func testResponseControllerEnableFullDuplex(t *testing.T, mode testMode) {
}
pw.Close()
}

func TestIssue58237(t *testing.T) {
cst := newClientServerTest(t, http2Mode, HandlerFunc(func(w ResponseWriter, req *Request) {
ctl := NewResponseController(w)
if err := ctl.SetReadDeadline(time.Now().Add(1 * time.Millisecond)); err != nil {
t.Errorf("ctl.SetReadDeadline() = %v, want nil", err)
}
time.Sleep(10 * time.Millisecond)
Comment on lines +331 to +336
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since the 1ms and 10ms are related, my I suggest:

Suggested change
cst := newClientServerTest(t, http2Mode, HandlerFunc(func(w ResponseWriter, req *Request) {
ctl := NewResponseController(w)
if err := ctl.SetReadDeadline(time.Now().Add(1 * time.Millisecond)); err != nil {
t.Errorf("ctl.SetReadDeadline() = %v, want nil", err)
}
time.Sleep(10 * time.Millisecond)
cst := newClientServerTest(t, http2Mode, HandlerFunc(func(w ResponseWriter, req *Request) {
ctl := NewResponseController(w)
duration := 1 * time.Millisecond
if err := ctl.SetReadDeadline(time.Now().Add(duration)); err != nil {
t.Errorf("ctl.SetReadDeadline() = %v, want nil", err)
}
time.Sleep(10 * duration)

}))
res, err := cst.c.Get(cst.ts.URL)
if err != nil {
t.Fatal(err)
}
res.Body.Close()
}