Skip to content

Commit

Permalink
net/http: show that SetWriteDeadline fixes the problem
Browse files Browse the repository at this point in the history
  • Loading branch information
gwik committed Jan 25, 2018
1 parent e4c191a commit 052de95
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion http2/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -828,9 +828,18 @@ func (cc *ClientConn) roundTrip(req *http.Request) (res *http.Response, gotErrAf
bodyWriter := cc.t.getBodyWriterState(cs, body)
cs.on100 = bodyWriter.on100

ctx := reqContext(req)

cc.wmu.Lock()
endStream := !hasBody && !hasTrailers
d, hasDeadline := ctx.Deadline()
if hasDeadline { // or transport base timeout ?
cc.tconn.SetWriteDeadline(d)
}
werr := cc.writeHeaders(cs.ID, endStream, int(cc.maxFrameSize), hdrs)
if hasDeadline {
cc.tconn.SetWriteDeadline(time.Time{})
}
cc.wmu.Unlock()
traceWroteHeaders(cs.trace)
cc.mu.Unlock()
Expand Down Expand Up @@ -861,7 +870,6 @@ func (cc *ClientConn) roundTrip(req *http.Request) (res *http.Response, gotErrAf

readLoopResCh := cs.resc
bodyWritten := false
ctx := reqContext(req)

handleReadLoopResponse := func(re resAndError) (*http.Response, bool, error) {
res := re.res
Expand Down

0 comments on commit 052de95

Please sign in to comment.