Skip to content
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions internal/transport/http2_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -600,10 +600,24 @@
return nil
}
}

if s.ctx.Err() != nil {
// Early abort in case the timeout was zero or so low it already fired.
t.controlBuf.put(&earlyAbortStream{
httpStatus: http.StatusOK,
streamID: s.id,
contentSubtype: s.contentSubtype,
status: status.New(codes.DeadlineExceeded, context.DeadlineExceeded.Error()),
rst: !frame.StreamEnded(),
})
return nil
}

Check warning on line 614 in internal/transport/http2_server.go

View check run for this annotation

Codecov / codecov/patch

internal/transport/http2_server.go#L605-L614

Added lines #L605 - L614 were not covered by tests

t.activeStreams[streamID] = s
if len(t.activeStreams) == 1 {
t.idle = time.Time{}
}

// Start a timer to close the stream on reaching the deadline.
if timeoutSet {
// We need to wait for s.cancel to be updated before calling
Expand Down
3 changes: 0 additions & 3 deletions internal/transport/http_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,6 @@ func decodeTimeout(s string) (time.Duration, error) {
if err != nil {
return 0, err
}
if t == 0 {
return 0, fmt.Errorf("transport: timeout must be positive: %q", s)
}
const maxHours = math.MaxInt64 / uint64(time.Hour)
if d == time.Hour && t > maxHours {
// This timeout would overflow math.MaxInt64; clamp it.
Expand Down
6 changes: 3 additions & 3 deletions internal/transport/http_util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ func (s) TestDecodeTimeout(t *testing.T) {
{"1", 0, true},
{"", 0, true},
{"9a1S", 0, true},
{"0S", 0, true}, // PROTOCOL-HTTP2.md requires positive integers
{"00000000S", 0, true},
{"000000000S", 0, true},
{"0S", 0, false}, // PROTOCOL-HTTP2.md requires positive integers, but we allow it to timeout instead
{"00000000S", 0, false},
{"000000000S", 0, true}, // PROTOCOL-HTTP2.md allows at most 8 digits
} {
d, err := decodeTimeout(test.s)
gotErr := err != nil
Expand Down