Skip to content

x/net/http2: add IdleConnTimeout, DisableKeepAlives, ExpectContinueTimeout, and ResponseHeaderTimeout to http2.Transport #57893

@dastbe

Description

@dastbe

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

  1. if the transport IdleConnTimeout is non-zero, return that
  2. if the underlying transport is non-nil, return the underly transport's IdleConnTimeout
  3. otherwise, return 0 (no timeout)

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Accepted

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions