test long header

pull/2476/head
Darien Raymond 2018-11-07 17:16:57 +01:00
parent 440cf090d6
commit 874fc87498
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
1 changed files with 16 additions and 0 deletions

View File

@ -1,7 +1,9 @@
package http_test
import (
"bytes"
"context"
"crypto/rand"
"testing"
"time"
@ -54,6 +56,20 @@ func TestRequestHeader(t *testing.T) {
assert(cache.String(), Equals, "GET / HTTP/1.1\r\nTest: Value\r\n\r\n")
}
func TestLongRequestHeader(t *testing.T) {
payload := make([]byte, buf.Size+2)
common.Must2(rand.Read(payload[:buf.Size-2]))
copy(payload[buf.Size-2:], []byte(ENDING))
payload = append(payload, []byte("abcd")...)
reader := HeaderReader{}
b, err := reader.Read(bytes.NewReader(payload))
common.Must(err)
if b.String() != "abcd" {
t.Error("expect content abcd, but actually ", b.String())
}
}
func TestConnection(t *testing.T) {
assert := With(t)