author | Brad Fitzpatrick
<bradfitz@golang.org> 2016-07-15 16:59:30 UTC |
committer | Brad Fitzpatrick
<bradfitz@golang.org> 2016-07-15 18:41:38 UTC |
parent | a728288923b47049b2ce791836767ffbe964a5bd |
http2/transport_test.go | +38 | -33 |
diff --git a/http2/transport_test.go b/http2/transport_test.go index 6009cef..5887714 100644 --- a/http2/transport_test.go +++ b/http2/transport_test.go @@ -1017,41 +1017,38 @@ func testTransportResPattern(t *testing.T, expect100Continue, resHeader headerTy if err != nil { return err } + endStream := false + send := func(mode headerType) { + hbf := buf.Bytes() + switch mode { + case oneHeader: + ct.fr.WriteHeaders(HeadersFrameParam{ + StreamID: f.Header().StreamID, + EndHeaders: true, + EndStream: endStream, + BlockFragment: hbf, + }) + case splitHeader: + if len(hbf) < 2 { + panic("too small") + } + ct.fr.WriteHeaders(HeadersFrameParam{ + StreamID: f.Header().StreamID, + EndHeaders: false, + EndStream: endStream, + BlockFragment: hbf[:1], + }) + ct.fr.WriteContinuation(f.Header().StreamID, true, hbf[1:]) + default: + panic("bogus mode") + } + } switch f := f.(type) { case *WindowUpdateFrame, *SettingsFrame: case *DataFrame: - // ignore for now. - case *HeadersFrame: - endStream := false - send := func(mode headerType) { - hbf := buf.Bytes() - switch mode { - case oneHeader: - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: true, - EndStream: endStream, - BlockFragment: hbf, - }) - case splitHeader: - if len(hbf) < 2 { - panic("too small") - } - ct.fr.WriteHeaders(HeadersFrameParam{ - StreamID: f.StreamID, - EndHeaders: false, - EndStream: endStream, - BlockFragment: hbf[:1], - }) - ct.fr.WriteContinuation(f.StreamID, true, hbf[1:]) - default: - panic("bogus mode") - } - } - if expect100Continue != noHeader { - buf.Reset() - enc.WriteField(hpack.HeaderField{Name: ":status", Value: "100"}) - send(expect100Continue) + if !f.StreamEnded() { + // No need to send flow control tokens. The test request body is tiny. + continue } // Response headers (1+ frames; 1 or 2 in this test, but never 0) { @@ -1075,7 +1072,15 @@ func testTransportResPattern(t *testing.T, expect100Continue, resHeader headerTy enc.WriteField(hpack.HeaderField{Name: "some-trailer", Value: "some-value"}) send(trailers) } - return nil + if endStream { + return nil + } + case *HeadersFrame: + if expect100Continue != noHeader { + buf.Reset() + enc.WriteField(hpack.HeaderField{Name: ":status", Value: "100"}) + send(expect100Continue) + } } } }