From e70cb9d525c08462b692b3ff45dd0957c6962b57 Mon Sep 17 00:00:00 2001 From: chihskin-afk Date: Thu, 20 Aug 2026 10:31:30 +0300 Subject: [PATCH] feat(doc) add read header timeout docs (#4760) --- docs/doc.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/doc.md b/docs/doc.md index d1c33b87..1c804b7b 100644 --- a/docs/doc.md +++ b/docs/doc.md @@ -2091,6 +2091,17 @@ See a complete example in the `https://github.com/gin-gonic/examples/tree/master > Configure HTTP servers, TLS, proxies, and runtime settings. +### ReadHeaderTimeout + +You can configure the maximum duration for reading the entire request header by setting `engine.ReadHeaderTimeout`. This helps protect against Slowloris attacks by limiting the time a client can take to send headers. + +```go +func main() { + router := gin.New() // or gin.Default() + router.ReadHeaderTimeout = 5 * time.Second + http.ListenAndServe(":8000", router) +} + ### Custom HTTP configuration Use `http.ListenAndServe()` directly, like this: