@@ -39,7 +39,7 @@ func getConn(s *Server) (*Conn, net.Listener, error) {
39
39
return nc , ln , nc .doHandshake ()
40
40
}
41
41
42
- func makeHeaders (id uint32 , enc * HPACK , endStream bool , hs map [string ]string ) * FrameHeader {
42
+ func makeHeaders (id uint32 , enc * HPACK , endHeaders , endStream bool , hs map [string ]string ) * FrameHeader {
43
43
fr := AcquireFrameHeader ()
44
44
45
45
fr .SetStream (id )
@@ -56,7 +56,7 @@ func makeHeaders(id uint32, enc *HPACK, endStream bool, hs map[string]string) *F
56
56
57
57
h .SetPadding (false )
58
58
h .SetEndStream (endStream )
59
- h .SetEndHeaders (true )
59
+ h .SetEndHeaders (endHeaders )
60
60
61
61
return fr
62
62
}
@@ -89,21 +89,21 @@ func testIssue52(t *testing.T) {
89
89
90
90
msg := []byte ("Hello world, how are you doing?" )
91
91
92
- h1 := makeHeaders (3 , c .enc , false , map [string ]string {
92
+ h1 := makeHeaders (3 , c .enc , true , false , map [string ]string {
93
93
string (StringAuthority ): "localhost" ,
94
94
string (StringMethod ): "POST" ,
95
95
string (StringPath ): "/hello/world" ,
96
96
string (StringScheme ): "https" ,
97
97
"Content-Length" : strconv .Itoa (len (msg )),
98
98
})
99
- h2 := makeHeaders (9 , c .enc , false , map [string ]string {
99
+ h2 := makeHeaders (9 , c .enc , true , false , map [string ]string {
100
100
string (StringAuthority ): "localhost" ,
101
101
string (StringMethod ): "POST" ,
102
102
string (StringPath ): "/hello/world" ,
103
103
string (StringScheme ): "https" ,
104
104
"Content-Length" : strconv .Itoa (len (msg )),
105
105
})
106
- h3 := makeHeaders (7 , c .enc , true , map [string ]string {
106
+ h3 := makeHeaders (7 , c .enc , true , true , map [string ]string {
107
107
string (StringAuthority ): "localhost" ,
108
108
string (StringMethod ): "GET" ,
109
109
string (StringPath ): "/hello/world" ,
@@ -153,3 +153,78 @@ func testIssue52(t *testing.T) {
153
153
t .Fatalf ("expected EOF, got %s" , err )
154
154
}
155
155
}
156
+
157
+ func TestIssue27 (t * testing.T ) {
158
+ s := & Server {
159
+ s : & fasthttp.Server {
160
+ Handler : func (ctx * fasthttp.RequestCtx ) {
161
+ io .WriteString (ctx , "Hello world" )
162
+ },
163
+ ReadTimeout : time .Second * 1 ,
164
+ },
165
+ cnf : ServerConfig {
166
+ Debug : false ,
167
+ },
168
+ }
169
+
170
+ c , ln , err := getConn (s )
171
+ if err != nil {
172
+ t .Fatal (err )
173
+ }
174
+ defer c .Close ()
175
+ defer ln .Close ()
176
+
177
+ msg := []byte ("Hello world, how are you doing?" )
178
+
179
+ h1 := makeHeaders (3 , c .enc , true , false , map [string ]string {
180
+ string (StringAuthority ): "localhost" ,
181
+ string (StringMethod ): "POST" ,
182
+ string (StringPath ): "/hello/world" ,
183
+ string (StringScheme ): "https" ,
184
+ "Content-Length" : strconv .Itoa (len (msg )),
185
+ })
186
+ h2 := makeHeaders (5 , c .enc , true , false , map [string ]string {
187
+ string (StringAuthority ): "localhost" ,
188
+ string (StringMethod ): "POST" ,
189
+ string (StringPath ): "/hello/world" ,
190
+ string (StringScheme ): "https" ,
191
+ "Content-Length" : strconv .Itoa (len (msg )),
192
+ })
193
+ h3 := makeHeaders (7 , c .enc , false , false , map [string ]string {
194
+ string (StringAuthority ): "localhost" ,
195
+ string (StringMethod ): "GET" ,
196
+ string (StringPath ): "/hello/world" ,
197
+ string (StringScheme ): "https" ,
198
+ "Content-Length" : strconv .Itoa (len (msg )),
199
+ })
200
+
201
+ c .writeFrame (h1 )
202
+ c .writeFrame (h2 )
203
+
204
+ time .Sleep (time .Second )
205
+ c .writeFrame (h3 )
206
+
207
+ id := uint32 (3 )
208
+
209
+ for i := 0 ; i < 3 ; i ++ {
210
+ fr , err := c .readNext ()
211
+ if err != nil {
212
+ t .Fatal (err )
213
+ }
214
+
215
+ if fr .Stream () != id {
216
+ t .Fatalf ("Expecting update on stream %d, got %d" , id , fr .Stream ())
217
+ }
218
+
219
+ if fr .Type () != FrameResetStream {
220
+ t .Fatalf ("Expecting Reset, got %s" , fr .Type ())
221
+ }
222
+
223
+ rst := fr .Body ().(* RstStream )
224
+ if rst .Code () != StreamCanceled {
225
+ t .Fatalf ("Expecting StreamCanceled, got %s" , rst .Code ())
226
+ }
227
+
228
+ id += 2
229
+ }
230
+ }
0 commit comments