Skip to content

Commit 14ecbb8

Browse files
committed
Return error and add GoAwayFrame
1 parent 34dd481 commit 14ecbb8

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

internal/transport/http2_server.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,12 +352,7 @@ func (t *http2Server) operateHeaders(ctx context.Context, frame *http2.MetaHeade
352352

353353
if streamID%2 != 1 || streamID <= t.maxStreamID {
354354
// illegal gRPC stream id.
355-
t.controlBuf.put(&goAway{
356-
code: http2.ErrCodeProtocol,
357-
debugData: []byte(fmt.Sprintf("received an illegal stream id: %+v", streamID)),
358-
closeConn: fmt.Errorf("received an illegal stream id: %v. headers frame: %+v", streamID, frame),
359-
})
360-
return nil
355+
return fmt.Errorf("received an illegal stream id: %v. headers frame: %+v", streamID, frame)
361356
}
362357
t.maxStreamID = streamID
363358

@@ -647,8 +642,12 @@ func (t *http2Server) HandleStreams(ctx context.Context, handle func(*Stream)) {
647642
switch frame := frame.(type) {
648643
case *http2.MetaHeadersFrame:
649644
if err := t.operateHeaders(ctx, frame, handle); err != nil {
650-
t.Close(err)
651-
break
645+
t.controlBuf.put(&goAway{
646+
code: http2.ErrCodeProtocol,
647+
debugData: []byte(err.Error()),
648+
closeConn: err,
649+
})
650+
continue
652651
}
653652
case *http2.DataFrame:
654653
t.handleData(frame)

test/end2end_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3927,9 +3927,9 @@ func (s) TestClientInvalidStreamID(t *testing.T) {
39273927
st.writeHeadersGRPC(2, "/grpc.testing.TestService/StreamingInputCall", true)
39283928
goAwayFrame := st.wantGoAway(http2.ErrCodeProtocol)
39293929
got := string(goAwayFrame.DebugData()[:])
3930-
want := "received an illegal stream id: 2"
3930+
want := "received an illegal stream id: 2. headers frame: [FrameHeader HEADERS flags=END_STREAM|END_HEADERS stream=2 len=60]"
39313931
if got != want {
3932-
t.Fatalf("Debug data received from stream %v, want: %v", got, want)
3932+
t.Fatalf("Error received: %v, want: %v", got, want)
39333933
}
39343934
}
39353935

0 commit comments

Comments
 (0)