From 16c53d6b04504ef4f6d746b58d72fe9dcd3c11c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=B7=E6=9C=88=E8=BD=A9?= Date: Tue, 31 Dec 2019 19:23:27 +0800 Subject: [PATCH] Set StatusRequestTimeout when net timeout error occurred (#713) --- server.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server.go b/server.go index 5703578b15..8c4f4057f1 100644 --- a/server.go +++ b/server.go @@ -2505,6 +2505,8 @@ func (s *Server) writeFastError(w io.Writer, statusCode int, msg string) { func defaultErrorHandler(ctx *RequestCtx, err error) { if _, ok := err.(*ErrSmallBuffer); ok { ctx.Error("Too big request header", StatusRequestHeaderFieldsTooLarge) + } else if netErr, ok := err.(*net.OpError); ok && netErr.Timeout() { + ctx.Error("Request timeout", StatusRequestTimeout) } else { ctx.Error("Error when parsing request", StatusBadRequest) }