Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
653b6f9504 |
@@ -233,7 +233,6 @@ func TestUpgradedConnectionOutlastsTheTimeouts(t *testing.T) {
|
|||||||
send(t, conn, "GET /socket HTTP/1.1\r\nHost: app\r\n"+
|
send(t, conn, "GET /socket HTTP/1.1\r\nHost: app\r\n"+
|
||||||
"Connection: Upgrade\r\nUpgrade: websocket\r\n\r\n")
|
"Connection: Upgrade\r\nUpgrade: websocket\r\n\r\n")
|
||||||
|
|
||||||
sent := time.Now()
|
|
||||||
reader := bufio.NewReader(conn)
|
reader := bufio.NewReader(conn)
|
||||||
|
|
||||||
res, err := http.ReadResponse(reader, nil)
|
res, err := http.ReadResponse(reader, nil)
|
||||||
@@ -241,16 +240,17 @@ func TestUpgradedConnectionOutlastsTheTimeouts(t *testing.T) {
|
|||||||
t.Fatalf("read the answer to the upgrade: %v", err)
|
t.Fatalf("read the answer to the upgrade: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
answered := time.Now()
|
||||||
_ = res.Body.Close()
|
_ = res.Body.Close()
|
||||||
|
|
||||||
if res.StatusCode != http.StatusSwitchingProtocols {
|
if res.StatusCode != http.StatusSwitchingProtocols {
|
||||||
t.Fatalf("status %d, want %d", res.StatusCode, http.StatusSwitchingProtocols)
|
t.Fatalf("status %d, want %d", res.StatusCode, http.StatusSwitchingProtocols)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every timeout started by the time smallwebwaf read the request:
|
// Every timeout started before the upgrade was answered, the response
|
||||||
// wait until just past shortTimeout after it was sent, then use the
|
// timeouts last, at the end of the request: wait until just past
|
||||||
// connection.
|
// shortTimeout after the answer was read, then use the connection.
|
||||||
time.Sleep(time.Until(sent.Add(shortTimeout + 100*time.Millisecond)))
|
time.Sleep(time.Until(answered.Add(shortTimeout + 100*time.Millisecond)))
|
||||||
send(t, conn, "still here\n")
|
send(t, conn, "still here\n")
|
||||||
|
|
||||||
echoed, err := reader.ReadString('\n')
|
echoed, err := reader.ReadString('\n')
|
||||||
|
|||||||
Reference in New Issue
Block a user