forked from summerwind/h2spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
4_2.go
38 lines (30 loc) · 980 Bytes
/
4_2.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package h2spec
import (
"github.com/bradfitz/http2"
)
func FrameSizeTestGroup(ctx *Context) *TestGroup {
tg := NewTestGroup("4.2", "Frame Size")
tg.AddTestCase(NewTestCase(
"Sends large size frame that exceeds the SETTINGS_MAX_FRAME_SIZE",
"The endpoint MUST send a FRAME_SIZE_ERROR error.",
func(ctx *Context) (pass bool, expected []Result, actual Result) {
http2Conn := CreateHttp2Conn(ctx, true)
defer http2Conn.conn.Close()
hdrs := commonHeaderFields(ctx)
var hp http2.HeadersFrameParam
hp.StreamID = 1
hp.EndStream = false
hp.EndHeaders = true
hp.BlockFragment = http2Conn.EncodeHeader(hdrs)
http2Conn.fr.WriteHeaders(hp)
max_size, ok := http2Conn.Settings[http2.SettingMaxFrameSize]
if !ok {
max_size = 18384
}
http2Conn.fr.WriteData(1, true, []byte(dummyData(int(max_size)+1)))
actualCodes := []http2.ErrCode{http2.ErrCodeFrameSize}
return TestStreamError(ctx, http2Conn, actualCodes)
},
))
return tg
}