Skip to content

Commit

Permalink
test: use Fprintf to simplify writing headers (#1510)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandear committed Mar 6, 2023
1 parent 74a0507 commit 4ca6994
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down

0 comments on commit 4ca6994

Please sign in to comment.