diff --git a/transport/internet/headers/http/http_test.go b/transport/internet/headers/http/http_test.go index 61036047..51b5d04a 100644 --- a/transport/internet/headers/http/http_test.go +++ b/transport/internet/headers/http/http_test.go @@ -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)