Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ea63359

Browse filesBrowse files
AlexanderYastrebovgopherbot
authored andcommitted
http2: check stream body is present on read timeout
Check stream body is not nil in the handler to cover all callsites For golang/go#58237 Change-Id: Ibeb19f2597f12da71b8dfb73718e230b4b316d06 GitHub-Last-Rev: dc87bef GitHub-Pull-Request: #162 Reviewed-on: https://go-review.googlesource.com/c/net/+/464936 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Commit-Queue: Bryan Mills <bcmills@google.com>
1 parent ddd8598 commit ea63359
Copy full SHA for ea63359

File tree

Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-6
lines changed

‎http2/server.go

Copy file name to clipboardExpand all lines: http2/server.go
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,9 +1892,11 @@ func (st *stream) copyTrailersToHandlerRequest() {
18921892
// onReadTimeout is run on its own goroutine (from time.AfterFunc)
18931893
// when the stream's ReadTimeout has fired.
18941894
func (st *stream) onReadTimeout() {
1895-
// Wrap the ErrDeadlineExceeded to avoid callers depending on us
1896-
// returning the bare error.
1897-
st.body.CloseWithError(fmt.Errorf("%w", os.ErrDeadlineExceeded))
1895+
if st.body != nil {
1896+
// Wrap the ErrDeadlineExceeded to avoid callers depending on us
1897+
// returning the bare error.
1898+
st.body.CloseWithError(fmt.Errorf("%w", os.ErrDeadlineExceeded))
1899+
}
18981900
}
18991901

19001902
// onWriteTimeout is run on its own goroutine (from time.AfterFunc)
@@ -2012,9 +2014,7 @@ func (sc *serverConn) processHeaders(f *MetaHeadersFrame) error {
20122014
// (in Go 1.8), though. That's a more sane option anyway.
20132015
if sc.hs.ReadTimeout != 0 {
20142016
sc.conn.SetReadDeadline(time.Time{})
2015-
if st.body != nil {
2016-
st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout)
2017-
}
2017+
st.readDeadline = time.AfterFunc(sc.hs.ReadTimeout, st.onReadTimeout)
20182018
}
20192019

20202020
go sc.runHandler(rw, req, handler)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.