Skip to content

Commit 4909c4c

Browse files
committed
http2: fix incorrect panic
Previously, we panic'd on sending WINDOW_UPDATE on the half-closed-local state. However, the RFC allows sending WINDOW_UPDATE in this state, so we should no panic. Change-Id: I702b2d5ad525837d7b8c650b7a2ed3f16371be63 Reviewed-on: https://go-review.googlesource.com/34498 Run-TryBot: Tom Bergan <tombergan@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
1 parent 989b0d9 commit 4909c4c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

http2/server.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -936,9 +936,15 @@ func (sc *serverConn) startFrameWrite(wr FrameWriteRequest) {
936936
if st != nil {
937937
switch st.state {
938938
case stateHalfClosedLocal:
939-
panic("internal error: attempt to send frame on half-closed-local stream")
939+
switch wr.write.(type) {
940+
case StreamError, handlerPanicRST, writeWindowUpdate:
941+
// RFC 7540 Section 5.1 allows sending RST_STREAM, PRIORITY, and WINDOW_UPDATE
942+
// in this state. (We never send PRIORITY from the server, so that is not checked.)
943+
default:
944+
panic(fmt.Sprintf("internal error: attempt to send frame on a half-closed-local stream: %v", wr))
945+
}
940946
case stateClosed:
941-
panic(fmt.Sprintf("internal error: attempt to send a write %v on a closed stream", wr))
947+
panic(fmt.Sprintf("internal error: attempt to send frame a closed stream: %v", wr))
942948
}
943949
}
944950
if wpp, ok := wr.write.(*writePushPromise); ok {

0 commit comments

Comments
 (0)