While it is possible to configure the IdleConnTimeout using the ConfigureTransports function, doing so is comparatively clunky to configuring it directly on the http2.Transport.
- It requires you to setup an http1 Transport which you may not otherwise need. you also need to guard against behavior differences elsewhere if the underlying transport is non-nil
- It requires you to reset the connPool as
ConfigureTransports sets up a different connPool implementation than if it were left nil before the first usage
The proposal then is to add the following API
// IdleConnTimeout is the maximum amount of time an idle
// (keep-alive) connection will remain idle before closing
// itself.
// Zero means no limit.
IdleConnTimeout time.Duration
which follows the existing http.Transport API. To preserve backwards compatibility, idleConnTimeout in http2.Transport will use the following rules
- if the transport IdleConnTimeout is non-zero, return that
- if the underlying transport is non-nil, return the underly transport's IdleConnTimeout
- otherwise, return 0 (no timeout)