Ver código fonte

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>
Tom Bergan 9 anos atrás
pai
commit
4909c4c0b6
1 arquivos alterados com 8 adições e 2 exclusões
  1. 8 2
      http2/server.go

+ 8 - 2
http2/server.go

@@ -936,9 +936,15 @@ func (sc *serverConn) startFrameWrite(wr FrameWriteRequest) {
 	if st != nil {
 		switch st.state {
 		case stateHalfClosedLocal:
-			panic("internal error: attempt to send frame on half-closed-local stream")
+			switch wr.write.(type) {
+			case StreamError, handlerPanicRST, writeWindowUpdate:
+				// RFC 7540 Section 5.1 allows sending RST_STREAM, PRIORITY, and WINDOW_UPDATE
+				// in this state. (We never send PRIORITY from the server, so that is not checked.)
+			default:
+				panic(fmt.Sprintf("internal error: attempt to send frame on a half-closed-local stream: %v", wr))
+			}
 		case stateClosed:
-			panic(fmt.Sprintf("internal error: attempt to send a write %v on a closed stream", wr))
+			panic(fmt.Sprintf("internal error: attempt to send frame a closed stream: %v", wr))
 		}
 	}
 	if wpp, ok := wr.write.(*writePushPromise); ok {