Skip to content

Commit 30a9713

Browse files
committed
Add test case for 'content-length' header field and multiple DATA frames
1 parent 7886b63 commit 30a9713

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

8_1.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,35 @@ func MalformedRequestsAndResponsesTestGroup() *TestGroup {
234234
tg := NewTestGroup("8.1.2.6", "Malformed Requests and Responses")
235235

236236
tg.AddTestCase(NewTestCase(
237-
"Sends a HEADERS frame that is omitted mandatory pseudo-header fields",
237+
"Sends a HEADERS frame that contains the \"content-length\" header field which does not equal the sum of the DATA frame payload lengths",
238+
"the endpoint MUST respond with a stream error of type PROTOCOL_ERROR.",
239+
func(ctx *Context) (expected []Result, actual Result) {
240+
http2Conn := CreateHttp2Conn(ctx, true)
241+
defer http2Conn.conn.Close()
242+
243+
hdrs := []hpack.HeaderField{
244+
pair(":method", "POST"),
245+
pair(":scheme", "http"),
246+
pair(":path", "/"),
247+
pair(":authority", ctx.Authority()),
248+
pair("content-length", "1"),
249+
}
250+
251+
var hp http2.HeadersFrameParam
252+
hp.StreamID = 1
253+
hp.EndStream = false
254+
hp.EndHeaders = true
255+
hp.BlockFragment = http2Conn.EncodeHeader(hdrs)
256+
http2Conn.fr.WriteHeaders(hp)
257+
http2Conn.fr.WriteData(1, true, []byte("test"))
258+
259+
actualCodes := []http2.ErrCode{http2.ErrCodeProtocol}
260+
return TestStreamError(ctx, http2Conn, actualCodes)
261+
},
262+
))
263+
264+
tg.AddTestCase(NewTestCase(
265+
"Sends a HEADERS frame that contains the \"content-length\" header field which does not equal the sum of the multiple DATA frame payload lengths",
238266
"the endpoint MUST respond with a stream error of type PROTOCOL_ERROR.",
239267
func(ctx *Context) (expected []Result, actual Result) {
240268
http2Conn := CreateHttp2Conn(ctx, true)
@@ -254,6 +282,7 @@ func MalformedRequestsAndResponsesTestGroup() *TestGroup {
254282
hp.EndHeaders = true
255283
hp.BlockFragment = http2Conn.EncodeHeader(hdrs)
256284
http2Conn.fr.WriteHeaders(hp)
285+
http2Conn.fr.WriteData(1, false, []byte("test"))
257286
http2Conn.fr.WriteData(1, true, []byte("test"))
258287

259288
actualCodes := []http2.ErrCode{http2.ErrCodeProtocol}

0 commit comments

Comments
 (0)