diff --git a/v2/protocol/http/options.go b/v2/protocol/http/options.go index 7963898bd..f2afebfe1 100644 --- a/v2/protocol/http/options.go +++ b/v2/protocol/http/options.go @@ -83,7 +83,8 @@ func WithShutdownTimeout(timeout time.Duration) Option { } } -// WithReadTimeout sets the read timeout for the http server. +// WithReadTimeout sets the read timeout for the http server. If not set, it will default to the +// DefaultTimeout (600s). There is no maximum limit on the timeout for long-running processes. func WithReadTimeout(timeout time.Duration) Option { return func(p *Protocol) error { if p == nil { @@ -94,7 +95,8 @@ func WithReadTimeout(timeout time.Duration) Option { } } -// WithWriteTimeout sets the write timeout for the http server. +// WithWriteTimeout sets the write timeout for the http server. If not set, it will default to the +// DefaultTimeout (600s). There is no maximum limit on the timeout for long-running processes. func WithWriteTimeout(timeout time.Duration) Option { return func(p *Protocol) error { if p == nil { diff --git a/v2/protocol/http/protocol.go b/v2/protocol/http/protocol.go index 70df2eab8..58aa87c93 100644 --- a/v2/protocol/http/protocol.go +++ b/v2/protocol/http/protocol.go @@ -136,7 +136,7 @@ func New(opts ...Option) (*Protocol, error) { p.readTimeout = DefaultTimeout } - if p.writeTimeout <= 0 { + if p.writeTimeout == 0 { p.writeTimeout = DefaultTimeout } diff --git a/v2/protocol/http/protocol_lifecycle.go b/v2/protocol/http/protocol_lifecycle.go index dacfd30f6..fd61d7900 100644 --- a/v2/protocol/http/protocol_lifecycle.go +++ b/v2/protocol/http/protocol_lifecycle.go @@ -38,8 +38,10 @@ func (p *Protocol) OpenInbound(ctx context.Context) error { } p.server = &http.Server{ - Addr: listener.Addr().String(), - Handler: attachMiddleware(p.Handler, p.middleware), + Addr: listener.Addr().String(), + Handler: attachMiddleware(p.Handler, p.middleware), + ReadTimeout: p.readTimeout, + WriteTimeout: p.writeTimeout, } // Shutdown