-
Notifications
You must be signed in to change notification settings - Fork 73
/
7_error_codes.go
69 lines (54 loc) · 1.73 KB
/
7_error_codes.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
package http2
import (
"golang.org/x/net/http2"
"github.com/summerwind/h2spec/config"
"github.com/summerwind/h2spec/spec"
)
func ErrorCodes() *spec.TestGroup {
tg := NewTestGroup("7", "Error Codes")
// Unknown or unsupported error codes MUST NOT trigger any special
// behavior. These MAY be treated by an implementation as being
// equivalent to INTERNAL_ERROR.
tg.AddTestCase(&spec.TestCase{
Desc: "Sends a GOAWAY frame with unknown error code",
Requirement: "The endpoint MUST NOT trigger any special behavior.",
Run: func(c *config.Config, conn *spec.Conn) error {
err := conn.Handshake()
if err != nil {
return err
}
conn.WriteGoAway(0, 0xff, []byte{})
data := [8]byte{'h', '2', 's', 'p', 'e', 'c'}
conn.WritePing(false, data)
return spec.VerifyPingFrameOrConnectionClose(conn, data)
},
})
// Unknown or unsupported error codes MUST NOT trigger any special
// behavior. These MAY be treated by an implementation as being
// equivalent to INTERNAL_ERROR.
tg.AddTestCase(&spec.TestCase{
Desc: "Sends a RST_STREAM frame with unknown error code",
Requirement: "The endpoint MUST NOT trigger any special behavior.",
Run: func(c *config.Config, conn *spec.Conn) error {
var streamID uint32 = 1
err := conn.Handshake()
if err != nil {
return err
}
headers := spec.CommonHeaders(c)
headers[0].Value = "POST"
hp := http2.HeadersFrameParam{
StreamID: streamID,
EndStream: false,
EndHeaders: true,
BlockFragment: conn.EncodeHeaders(headers),
}
conn.WriteHeaders(hp)
conn.WriteRSTStream(streamID, 0xff)
data := [8]byte{}
conn.WritePing(false, data)
return spec.VerifyPingFrameOrConnectionClose(conn, data)
},
})
return tg
}