forked from summerwind/h2spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
6_3.go
62 lines (49 loc) · 1.73 KB
/
6_3.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package h2spec
import (
"fmt"
"github.com/bradfitz/http2"
)
func PriorityTestGroup(ctx *Context) *TestGroup {
tg := NewTestGroup("6.3", "PRIORITY")
tg.AddTestCase(NewTestCase(
"Sends a PRIORITY frame with 0x0 stream identifier",
"The endpoint MUST respond with a connection error of type PROTOCOL_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)
// PRIORITY Frame
fmt.Fprintf(http2Conn.conn, "\x00\x00\x05\x02\x00\x00\x00\x00\x00")
fmt.Fprintf(http2Conn.conn, "\x80\x00\x00\x01\x0a")
actualCodes := []http2.ErrCode{http2.ErrCodeProtocol}
return TestConnectionError(ctx, http2Conn, actualCodes)
},
))
tg.AddTestCase(NewTestCase(
"Sends a PRIORITY frame with a length other than 5 octets",
"The endpoint MUST respond with a stream error of type FRAME_SIZE_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)
// PRIORITY Frame
fmt.Fprintf(http2Conn.conn, "\x00\x00\x04\x02\x00\x00\x00\x00\x01")
fmt.Fprintf(http2Conn.conn, "\x80\x00\x00\x01")
actualCodes := []http2.ErrCode{http2.ErrCodeFrameSize}
return TestStreamError(ctx, http2Conn, actualCodes)
},
))
return tg
}