@ -39,10 +39,11 @@ func StartHTTPEndpoint(endpoint string, timeouts rpc.HTTPTimeouts, handler http.
CheckTimeouts ( & timeouts )
CheckTimeouts ( & timeouts )
// Bundle and start the HTTP server
// Bundle and start the HTTP server
httpSrv := & http . Server {
httpSrv := & http . Server {
Handler : handler ,
Handler : handler ,
ReadTimeout : timeouts . ReadTimeout ,
ReadTimeout : timeouts . ReadTimeout ,
WriteTimeout : timeouts . WriteTimeout ,
ReadHeaderTimeout : timeouts . ReadHeaderTimeout ,
IdleTimeout : timeouts . IdleTimeout ,
WriteTimeout : timeouts . WriteTimeout ,
IdleTimeout : timeouts . IdleTimeout ,
}
}
go httpSrv . Serve ( listener )
go httpSrv . Serve ( listener )
return httpSrv , listener . Addr ( ) , err
return httpSrv , listener . Addr ( ) , err
@ -75,6 +76,10 @@ func CheckTimeouts(timeouts *rpc.HTTPTimeouts) {
log . Warn ( "Sanitizing invalid HTTP read timeout" , "provided" , timeouts . ReadTimeout , "updated" , rpc . DefaultHTTPTimeouts . ReadTimeout )
log . Warn ( "Sanitizing invalid HTTP read timeout" , "provided" , timeouts . ReadTimeout , "updated" , rpc . DefaultHTTPTimeouts . ReadTimeout )
timeouts . ReadTimeout = rpc . DefaultHTTPTimeouts . ReadTimeout
timeouts . ReadTimeout = rpc . DefaultHTTPTimeouts . ReadTimeout
}
}
if timeouts . ReadHeaderTimeout < time . Second {
log . Warn ( "Sanitizing invalid HTTP read header timeout" , "provided" , timeouts . ReadHeaderTimeout , "updated" , rpc . DefaultHTTPTimeouts . ReadHeaderTimeout )
timeouts . ReadHeaderTimeout = rpc . DefaultHTTPTimeouts . ReadHeaderTimeout
}
if timeouts . WriteTimeout < time . Second {
if timeouts . WriteTimeout < time . Second {
log . Warn ( "Sanitizing invalid HTTP write timeout" , "provided" , timeouts . WriteTimeout , "updated" , rpc . DefaultHTTPTimeouts . WriteTimeout )
log . Warn ( "Sanitizing invalid HTTP write timeout" , "provided" , timeouts . WriteTimeout , "updated" , rpc . DefaultHTTPTimeouts . WriteTimeout )
timeouts . WriteTimeout = rpc . DefaultHTTPTimeouts . WriteTimeout
timeouts . WriteTimeout = rpc . DefaultHTTPTimeouts . WriteTimeout