From 4ca6994c93983054ad9c82789844de77a04f6dd5 Mon Sep 17 00:00:00 2001 From: Oleksandr Redko Date: Mon, 6 Mar 2023 12:13:37 +0200 Subject: [PATCH] test: use Fprintf to simplify writing headers (#1510) --- server_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server_test.go b/server_test.go index eef3c2c466..62e6eec063 100644 --- a/server_test.go +++ b/server_test.go @@ -3772,7 +3772,7 @@ func TestStreamRequestBody(t *testing.T) { pipe := fasthttputil.NewPipeConns() cc, sc := pipe.Conn1(), pipe.Conn2() // write headers and part1 body - 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 { + 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 { t.Fatal(err) } if _, err := cc.Write([]byte(part1)); err != nil { @@ -3829,7 +3829,7 @@ func TestStreamRequestBodyExceedMaxSize(t *testing.T) { pipe := fasthttputil.NewPipeConns() cc, sc := pipe.Conn1(), pipe.Conn2() // write headers and part1 body - 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 { + 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 { t.Error(err) } @@ -3876,7 +3876,7 @@ func TestStreamBodyRequestContentLength(t *testing.T) { pipe := fasthttputil.NewPipeConns() cc, sc := pipe.Conn1(), pipe.Conn2() - 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 { + 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 { t.Fatal(err) }