Skip to content

Commit 4ca6994

Browse files
authored
test: use Fprintf to simplify writing headers (#1510)
1 parent 74a0507 commit 4ca6994

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

server_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3772,7 +3772,7 @@ func TestStreamRequestBody(t *testing.T) {
37723772
pipe := fasthttputil.NewPipeConns()
37733773
cc, sc := pipe.Conn1(), pipe.Conn2()
37743774
// write headers and part1 body
3775-
if _, err := cc.Write([]byte(fmt.Sprintf("POST /foo2 HTTP/1.1\r\nHost: aaa.com\r\nContent-Length: %d\r\nContent-Type: aa\r\n\r\n", contentLength))); err != nil {
3775+
if _, err := fmt.Fprintf(cc, "POST /foo2 HTTP/1.1\r\nHost: aaa.com\r\nContent-Length: %d\r\nContent-Type: aa\r\n\r\n", contentLength); err != nil {
37763776
t.Fatal(err)
37773777
}
37783778
if _, err := cc.Write([]byte(part1)); err != nil {
@@ -3829,7 +3829,7 @@ func TestStreamRequestBodyExceedMaxSize(t *testing.T) {
38293829
pipe := fasthttputil.NewPipeConns()
38303830
cc, sc := pipe.Conn1(), pipe.Conn2()
38313831
// write headers and part1 body
3832-
if _, err := cc.Write([]byte(fmt.Sprintf("POST /foo2 HTTP/1.1\r\nHost: aaa.com\r\nContent-Length: %d\r\nContent-Type: aa\r\n\r\n%s", contentLength, part1))); err != nil {
3832+
if _, err := fmt.Fprintf(cc, "POST /foo2 HTTP/1.1\r\nHost: aaa.com\r\nContent-Length: %d\r\nContent-Type: aa\r\n\r\n%s", contentLength, part1); err != nil {
38333833
t.Error(err)
38343834
}
38353835

@@ -3876,7 +3876,7 @@ func TestStreamBodyRequestContentLength(t *testing.T) {
38763876

38773877
pipe := fasthttputil.NewPipeConns()
38783878
cc, sc := pipe.Conn1(), pipe.Conn2()
3879-
if _, err := cc.Write([]byte(fmt.Sprintf("POST /foo2 HTTP/1.1\r\nHost: aaa.com\r\nContent-Length: %d\r\nContent-Type: aa\r\n\r\n%s", contentLength, content))); err != nil {
3879+
if _, err := fmt.Fprintf(cc, "POST /foo2 HTTP/1.1\r\nHost: aaa.com\r\nContent-Length: %d\r\nContent-Type: aa\r\n\r\n%s", contentLength, content); err != nil {
38803880
t.Fatal(err)
38813881
}
38823882

0 commit comments

Comments
 (0)