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

Method TestClientTransport_Handle1xxHeaders

internal/transport/transport_test.go:3838–3913  ·  view source on GitHub ↗

TestClientTransport_Handle1xxHeaders validates that 1xx HTTP status headers are ignored and treated as a protocol error if END_STREAM is set.

(t *testing.T)

Source from the content-addressed store, hash-verified

3836// TestClientTransport_Handle1xxHeaders validates that 1xx HTTP status headers
3837// are ignored and treated as a protocol error if END_STREAM is set.
3838func (s) TestClientTransport_Handle1xxHeaders(t *testing.T) {
3839 testStream := func() *ClientStream {
3840 return &ClientStream{
3841 Stream: Stream{
3842 buf: recvBuffer{
3843 c: make(chan recvMsg),
3844 mu: sync.Mutex{},
3845 },
3846 },
3847 done: make(chan struct{}),
3848 headerChan: make(chan struct{}),
3849 }
3850 }
3851
3852 testClient := func(ts *ClientStream) *http2Client {
3853 return &http2Client{
3854 mu: sync.Mutex{},
3855 activeStreams: map[uint32]*ClientStream{
3856 0: ts,
3857 },
3858 controlBuf: newControlBuffer(make(<-chan struct{})),
3859 }
3860 }
3861
3862 for _, test := range []struct {
3863 name string
3864 metaHeaderFrame *http2.MetaHeadersFrame
3865 httpFlags http2.Flags
3866 wantStatus *status.Status
3867 }{
3868 {
3869 name: "1xx with END_STREAM is error",
3870 metaHeaderFrame: &http2.MetaHeadersFrame{
3871 Fields: []hpack.HeaderField{
3872 {Name: ":status", Value: "100"},
3873 },
3874 },
3875 httpFlags: http2.FlagHeadersEndStream,
3876 wantStatus: status.New(
3877 codes.Internal,
3878 "protocol error: informational header with status code 100 must not have END_STREAM set",
3879 ),
3880 },
3881 {
3882 name: "1xx without END_STREAM is ignored",
3883 metaHeaderFrame: &http2.MetaHeadersFrame{
3884 Fields: []hpack.HeaderField{
3885 {Name: ":status", Value: "100"},
3886 },
3887 },
3888 httpFlags: 0,
3889 wantStatus: nil,
3890 },
3891 } {
3892 t.Run(test.name, func(t *testing.T) {
3893 ts := testStream()
3894 s := testClient(ts)
3895

Callers

nothing calls this directly

Calls 6

NewFunction · 0.92
newControlBufferFunction · 0.85
CodeMethod · 0.80
MessageMethod · 0.80
FatalfMethod · 0.65
operateHeadersMethod · 0.45

Tested by

no test coverage detected