|
|
@@ -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)
|
|
|
|