MCPcopy
hub / github.com/grpc/grpc-go / TestEarlyAbortStreamHeaderListSizeCheck

Method TestEarlyAbortStreamHeaderListSizeCheck

test/end2end_test.go:6163–6198  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6161}
6162
6163func (s) TestEarlyAbortStreamHeaderListSizeCheck(t *testing.T) {
6164 lis, err := net.Listen("tcp", "localhost:0")
6165 if err != nil {
6166 t.Fatalf("Failed to listen: %v", err)
6167 }
6168 s := grpc.NewServer()
6169 defer s.Stop()
6170 go s.Serve(lis)
6171
6172 conn, err := net.DialTimeout("tcp", lis.Addr().String(), defaultTestTimeout)
6173 if err != nil {
6174 t.Fatalf("Failed to dial: %v", err)
6175 }
6176 defer conn.Close()
6177 st := newServerTesterFromConn(t, conn)
6178
6179 // Set a very small MaxHeaderListSize that any response headers would violate.
6180 st.greetWithSettings(http2.Setting{ID: http2.SettingMaxHeaderListSize, Val: 1})
6181
6182 // Send a request with an invalid content-type to trigger early abort.
6183 st.writeHeaders(http2.HeadersFrameParam{
6184 StreamID: 1,
6185 BlockFragment: st.encodeHeader(
6186 ":method", "POST",
6187 ":path", "/grpc.testing.TestService/UnaryCall",
6188 "content-type", "text/plain", // Invalid content-type to trigger early abort
6189 "te", "trailers",
6190 ),
6191 EndStream: true,
6192 EndHeaders: true,
6193 })
6194
6195 // We should receive a RST_STREAM with ErrCodeInternal because the response
6196 // headers exceed the MaxHeaderListSize limit.
6197 st.wantRSTStream(http2.ErrCodeInternal)
6198}
6199
6200func (s) TestNetPipeConn(t *testing.T) {
6201 // This test will block indefinitely if grpc writes both client and server

Callers

nothing calls this directly

Calls 12

NewServerFunction · 0.92
newServerTesterFromConnFunction · 0.85
greetWithSettingsMethod · 0.80
wantRSTStreamMethod · 0.80
FatalfMethod · 0.65
StopMethod · 0.65
ServeMethod · 0.65
StringMethod · 0.65
CloseMethod · 0.65
AddrMethod · 0.45
writeHeadersMethod · 0.45
encodeHeaderMethod · 0.45

Tested by

no test coverage detected