aboutsummaryrefslogtreecommitdiff
path: root/http_test.go
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2021-12-13 16:41:34 +0800
committerGravatar GitHub <noreply@github.com> 2021-12-13 09:41:34 +0100
commite9db537178708982f64736dbdedfddd2a168d395 (patch)
tree705174cc0a2f0dd156dc98b578f14b7616608eba /http_test.go
parentFix bad request trailer panic (diff)
downloadfasthttp-e9db537178708982f64736dbdedfddd2a168d395.tar.gz
fasthttp-e9db537178708982f64736dbdedfddd2a168d395.tar.bz2
fasthttp-e9db537178708982f64736dbdedfddd2a168d395.zip
Use %w to wrap errors (#1175)
Diffstat (limited to 'http_test.go')
-rw-r--r--http_test.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/http_test.go b/http_test.go
index 1282144..a4a1e58 100644
--- a/http_test.go
+++ b/http_test.go
@@ -4,6 +4,7 @@ import (
"bufio"
"bytes"
"encoding/base64"
+ "errors"
"fmt"
"io"
"io/ioutil"
@@ -20,9 +21,13 @@ import (
func TestInvalidTrailers(t *testing.T) {
t.Parallel()
- br := bufio.NewReader(bytes.NewReader([]byte{0x20, 0x30, 0x0a, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0xff, 0x0a, 0x0a, 0x30, 0x0d, 0x0a, 0x30}))
- err := (&Response{}).Read(br)
- if err == io.EOF {
+ if err := (&Response{}).Read(bufio.NewReader(bytes.NewReader([]byte{0x20, 0x30, 0x0a, 0x54, 0x72, 0x61, 0x6e, 0x73, 0x66, 0x65, 0x72, 0x2d, 0x45, 0x6e, 0x63, 0x6f, 0x64, 0x69, 0x6e, 0x67, 0x3a, 0xff, 0x0a, 0x0a, 0x30, 0x0d, 0x0a, 0x30}))); !errors.Is(err, io.EOF) {
+ t.Fatalf("%#v", err)
+ }
+ if err := (&Response{}).Read(bufio.NewReader(bytes.NewReader([]byte{0xff, 0x20, 0x0a, 0x54, 0x52, 0x61, 0x49, 0x4c, 0x65, 0x52, 0x3a, 0x2c, 0x0a, 0x0a}))); !errors.Is(err, errEmptyInt) {
+ t.Fatal(err)
+ }
+ if err := (&Response{}).Read(bufio.NewReader(bytes.NewReader([]byte{0x54, 0x52, 0x61, 0x49, 0x4c, 0x65, 0x52, 0x3a, 0x2c, 0x0a, 0x0a}))); !strings.Contains(err.Error(), "cannot find whitespace in the first line of response") {
t.Fatal(err)
}