Skip to content

Commit 052de95

Browse files
committed
net/http: show that SetWriteDeadline fixes the problem
1 parent e4c191a commit 052de95

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

http2/transport.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,9 +828,18 @@ func (cc *ClientConn) roundTrip(req *http.Request) (res *http.Response, gotErrAf
828828
bodyWriter := cc.t.getBodyWriterState(cs, body)
829829
cs.on100 = bodyWriter.on100
830830

831+
ctx := reqContext(req)
832+
831833
cc.wmu.Lock()
832834
endStream := !hasBody && !hasTrailers
835+
d, hasDeadline := ctx.Deadline()
836+
if hasDeadline { // or transport base timeout ?
837+
cc.tconn.SetWriteDeadline(d)
838+
}
833839
werr := cc.writeHeaders(cs.ID, endStream, int(cc.maxFrameSize), hdrs)
840+
if hasDeadline {
841+
cc.tconn.SetWriteDeadline(time.Time{})
842+
}
834843
cc.wmu.Unlock()
835844
traceWroteHeaders(cs.trace)
836845
cc.mu.Unlock()
@@ -861,7 +870,6 @@ func (cc *ClientConn) roundTrip(req *http.Request) (res *http.Response, gotErrAf
861870

862871
readLoopResCh := cs.resc
863872
bodyWritten := false
864-
ctx := reqContext(req)
865873

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

0 commit comments

Comments
 (0)