mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-15 17:30:44 +00:00
Merge pull request #469 from gzliudan/http-server-timeout
add http.TimeoutHandler for rpc http server
This commit is contained in:
commit
5223454dee
1 changed files with 2 additions and 1 deletions
|
|
@ -237,11 +237,12 @@ func NewHTTPServer(cors []string, vhosts []string, srv *Server, writeTimeout tim
|
||||||
// Wrap the CORS-handler within a host-handler
|
// Wrap the CORS-handler within a host-handler
|
||||||
handler := newCorsHandler(srv, cors)
|
handler := newCorsHandler(srv, cors)
|
||||||
handler = newVHostHandler(vhosts, handler)
|
handler = newVHostHandler(vhosts, handler)
|
||||||
|
handler = http.TimeoutHandler(handler, writeTimeout, `{"error":"http server timeout"}`)
|
||||||
log.Info("NewHTTPServer", "writeTimeout", writeTimeout)
|
log.Info("NewHTTPServer", "writeTimeout", writeTimeout)
|
||||||
return &http.Server{
|
return &http.Server{
|
||||||
Handler: handler,
|
Handler: handler,
|
||||||
ReadTimeout: 5 * time.Second,
|
ReadTimeout: 5 * time.Second,
|
||||||
WriteTimeout: writeTimeout,
|
WriteTimeout: writeTimeout + time.Second,
|
||||||
IdleTimeout: 120 * time.Second,
|
IdleTimeout: 120 * time.Second,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue