@@ -4786,3 +4786,87 @@ Frames:
4786
4786
close (s )
4787
4787
}
4788
4788
}
4789
+
4790
+ func TestServerContinuationFlood (t * testing.T ) {
4791
+ st := newServerTester (t , func (w http.ResponseWriter , r * http.Request ) {
4792
+ fmt .Println (r .Header )
4793
+ }, func (ts * httptest.Server ) {
4794
+ ts .Config .MaxHeaderBytes = 4096
4795
+ })
4796
+ defer st .Close ()
4797
+
4798
+ st .writePreface ()
4799
+ st .writeInitialSettings ()
4800
+ st .writeSettingsAck ()
4801
+
4802
+ st .writeHeaders (HeadersFrameParam {
4803
+ StreamID : 1 ,
4804
+ BlockFragment : st .encodeHeader (),
4805
+ EndStream : true ,
4806
+ })
4807
+ for i := 0 ; i < 1000 ; i ++ {
4808
+ st .fr .WriteContinuation (1 , false , st .encodeHeaderRaw (
4809
+ fmt .Sprintf ("x-%v" , i ), "1234567890" ,
4810
+ ))
4811
+ }
4812
+ st .fr .WriteContinuation (1 , true , st .encodeHeaderRaw (
4813
+ "x-last-header" , "1" ,
4814
+ ))
4815
+
4816
+ var sawGoAway bool
4817
+ for {
4818
+ f , err := st .readFrame ()
4819
+ if err != nil {
4820
+ break
4821
+ }
4822
+ switch f .(type ) {
4823
+ case * GoAwayFrame :
4824
+ sawGoAway = true
4825
+ case * HeadersFrame :
4826
+ t .Fatalf ("received HEADERS frame; want GOAWAY" )
4827
+ }
4828
+ }
4829
+ if ! sawGoAway {
4830
+ t .Errorf ("connection closed with no GOAWAY frame; want one" )
4831
+ }
4832
+ }
4833
+
4834
+ func TestServerContinuationAfterInvalidHeader (t * testing.T ) {
4835
+ st := newServerTester (t , func (w http.ResponseWriter , r * http.Request ) {
4836
+ fmt .Println (r .Header )
4837
+ })
4838
+ defer st .Close ()
4839
+
4840
+ st .writePreface ()
4841
+ st .writeInitialSettings ()
4842
+ st .writeSettingsAck ()
4843
+
4844
+ st .writeHeaders (HeadersFrameParam {
4845
+ StreamID : 1 ,
4846
+ BlockFragment : st .encodeHeader (),
4847
+ EndStream : true ,
4848
+ })
4849
+ st .fr .WriteContinuation (1 , false , st .encodeHeaderRaw (
4850
+ "x-invalid-header" , "\x00 " ,
4851
+ ))
4852
+ st .fr .WriteContinuation (1 , true , st .encodeHeaderRaw (
4853
+ "x-valid-header" , "1" ,
4854
+ ))
4855
+
4856
+ var sawGoAway bool
4857
+ for {
4858
+ f , err := st .readFrame ()
4859
+ if err != nil {
4860
+ break
4861
+ }
4862
+ switch f .(type ) {
4863
+ case * GoAwayFrame :
4864
+ sawGoAway = true
4865
+ case * HeadersFrame :
4866
+ t .Fatalf ("received HEADERS frame; want GOAWAY" )
4867
+ }
4868
+ }
4869
+ if ! sawGoAway {
4870
+ t .Errorf ("connection closed with no GOAWAY frame; want one" )
4871
+ }
4872
+ }
0 commit comments