Browse Source

test long header

Darien Raymond 7 years ago
parent
commit
874fc87498
1 changed files with 16 additions and 0 deletions
  1. 16 0
      transport/internet/headers/http/http_test.go

+ 16 - 0
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)