aboutsummaryrefslogtreecommitdiff
path: root/server_test.go
diff options
context:
space:
mode:
authorGravatar Erik Dubbelboer <erik@dubbelboer.com> 2022-07-29 19:03:15 +0200
committerGravatar GitHub <noreply@github.com> 2022-07-29 19:03:15 +0200
commita5f448fc970972ab47113971d898a22fb28fef52 (patch)
tree826fe1e91cdca5002f7db0bef4b8dfdcf55efddc /server_test.go
parentPrevent overflow and panic on large HTTP responses (#1351) (diff)
downloadfasthttp-a5f448fc970972ab47113971d898a22fb28fef52.tar.gz
fasthttp-a5f448fc970972ab47113971d898a22fb28fef52.tar.bz2
fasthttp-a5f448fc970972ab47113971d898a22fb28fef52.zip
Improve Client timeout (#1346)
Don't run requests in a separate Goroutine anymore. Instead use proper conn deadlines to enforce timeouts. - Also contains some linting fixes.
Diffstat (limited to 'server_test.go')
-rw-r--r--server_test.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/server_test.go b/server_test.go
index 6775ce6..1a2adcc 100644
--- a/server_test.go
+++ b/server_test.go
@@ -254,7 +254,7 @@ func TestServerConnState(t *testing.T) {
states := make([]string, 0)
s := &Server{
Handler: func(ctx *RequestCtx) {},
- ConnState: func(conn net.Conn, state ConnState) {
+ ConnState: func(_ net.Conn, state ConnState) {
states = append(states, state.String())
},
}
@@ -2103,7 +2103,7 @@ func TestServerErrorHandler(t *testing.T) {
s := &Server{
Handler: func(ctx *RequestCtx) {},
- ErrorHandler: func(ctx *RequestCtx, err error) {
+ ErrorHandler: func(ctx *RequestCtx, _ error) {
resultReqStr = ctx.Request.String()
resultRespStr = ctx.Response.String()
},
@@ -3681,6 +3681,7 @@ func TestStreamRequestBody(t *testing.T) {
checkReader(t, ctx.RequestBodyStream(), part2)
},
StreamRequestBody: true,
+ Logger: &testLogger{},
}
pipe := fasthttputil.NewPipeConns()
@@ -3828,7 +3829,7 @@ func TestMaxReadTimeoutPerRequest(t *testing.T) {
headers := []byte(fmt.Sprintf("POST /foo2 HTTP/1.1\r\nHost: aaa.com\r\nContent-Length: %d\r\nContent-Type: aa\r\n\r\n", 5*1024))
s := &Server{
- Handler: func(ctx *RequestCtx) {
+ Handler: func(_ *RequestCtx) {
t.Error("shouldn't reach handler")
},
HeaderReceived: func(header *RequestHeader) RequestConfig {
@@ -3971,7 +3972,7 @@ func TestServerChunkedResponse(t *testing.T) {
if err := w.Flush(); err != nil {
t.Errorf("unexpected error: %v", err)
}
- time.Sleep(time.Second)
+ time.Sleep(time.Millisecond * 100)
}
})
for k, v := range trailer {