-
Notifications
You must be signed in to change notification settings - Fork 73
/
4_1_frame_format.go
79 lines (66 loc) · 2.42 KB
/
4_1_frame_format.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
package client
import (
"github.com/summerwind/h2spec/config"
"github.com/summerwind/h2spec/spec"
)
func FrameFormat() *spec.ClientTestGroup {
tg := NewTestGroup("4.1", "Frame Format")
// Type: The 8-bit type of the frame. The frame type determines
// the format and semantics of the frame. Implementations MUST
// ignore and discard any frame that has a type that is unknown.
tg.AddTestCase(&spec.ClientTestCase{
Desc: "Sends a frame with unknown type",
Requirement: "The endpoint MUST ignore and discard any frame that has a type that is unknown.",
Run: func(c *config.Config, conn *spec.Conn) error {
err := conn.Handshake()
if err != nil {
return err
}
// UNKONWN Frame:
// Length: 8, Type: 255, Flags: 0, R: 0, StreamID: 0
conn.Send([]byte("\x00\x00\x08\x16\x00\x00\x00\x00\x00"))
conn.Send([]byte("\x00\x00\x00\x00\x00\x00\x00\x00"))
data := [8]byte{}
conn.WritePing(false, data)
return spec.VerifyPingFrameWithAck(conn, data)
},
})
// Flags are assigned semantics specific to the indicated frame
// type. Flags that have no defined semantics for a particular
// frame type MUST be ignored and MUST be left unset (0x0) when
// sending.
tg.AddTestCase(&spec.ClientTestCase{
Desc: "Sends a frame with undefined flag",
Requirement: "The endpoint MUST ignore any flags that is undefined.",
Run: func(c *config.Config, conn *spec.Conn) error {
err := conn.Handshake()
if err != nil {
return err
}
// PING Frame:
// Length: 8, Type: 6, Flags: 255, R: 0, StreamID: 0
conn.Send([]byte("\x00\x00\x08\x06\x16\x00\x00\x00\x00"))
conn.Send([]byte("\x00\x00\x00\x00\x00\x00\x00\x00"))
return spec.VerifyEventType(conn, spec.EventPingFrame)
},
})
// R: A reserved 1-bit field. The semantics of this bit are
// undefined, and the bit MUST remain unset (0x0) when sending
// and MUST be ignored when receiving.
tg.AddTestCase(&spec.ClientTestCase{
Desc: "Sends a frame with reserved field bit",
Requirement: "The endpoint MUST ignore the value of reserved field.",
Run: func(c *config.Config, conn *spec.Conn) error {
err := conn.Handshake()
if err != nil {
return err
}
// PING Frame:
// Length: 8, Type: 6, Flags: 255, R: 1, StreamID: 0
conn.Send([]byte("\x00\x00\x08\x06\x16\x80\x00\x00\x00"))
conn.Send([]byte("\x00\x00\x00\x00\x00\x00\x00\x00"))
return spec.VerifyEventType(conn, spec.EventPingFrame)
},
})
return tg
}