forked from summerwind/h2spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
6_8.go
45 lines (36 loc) · 892 Bytes
/
6_8.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
package h2spec
import (
"fmt"
"github.com/bradfitz/http2"
)
func TestGoaway(ctx *Context) {
if !ctx.IsTarget("6.8") {
return
}
PrintHeader("6.8. GOAWAY", 0)
func(ctx *Context) {
desc := "Sends a GOAWAY frame with the stream identifier that is not 0x0"
msg := "the endpoint MUST respond with a connection error of type PROTOCOL_ERROR."
result := false
http2Conn := CreateHttp2Conn(ctx, true)
defer http2Conn.conn.Close()
fmt.Fprintf(http2Conn.conn, "\x00\x00\x08\x07\x00\x00\x00\x00\x03")
fmt.Fprintf(http2Conn.conn, "\x00\x00\x00\x00\x00\x00\x00\x00")
loop:
for {
f, err := http2Conn.ReadFrame(ctx.Timeout)
if err != nil {
break loop
}
switch f := f.(type) {
case *http2.GoAwayFrame:
if f.ErrCode == http2.ErrCodeProtocol {
result = true
break loop
}
}
}
PrintResult(result, desc, msg, 0)
}(ctx)
PrintFooter()
}