forked from summerwind/h2spec
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3_5.go
46 lines (37 loc) · 754 Bytes
/
3_5.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
package h2spec
import (
"fmt"
"io"
"time"
)
func TestHttp2ConnectionPreface(ctx *Context) {
if !ctx.IsTarget("3.5") {
return
}
PrintHeader("3.5. HTTP/2 Connection Preface", 0)
func(ctx *Context) {
desc := "Sends invalid connection preface"
msg := "The endpoint MUST terminate the TCP connection."
result := false
tcpConn := CreateTcpConn(ctx)
defer tcpConn.conn.Close()
fmt.Fprintf(tcpConn.conn, "INVALID CONNECTION PREFACE")
timeCh := time.After(ctx.Timeout)
loop:
for {
select {
case <-tcpConn.dataCh:
break
case err := <-tcpConn.errCh:
if err == io.EOF {
result = true
break loop
}
case <-timeCh:
break loop
}
}
PrintResult(result, desc, msg, 0)
}(ctx)
PrintFooter()
}