Skip to content

Commit

Permalink
client: Client {} supports custom Transport (#1935)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyongding authored Jan 10, 2025
1 parent 4cd46d7 commit 655424d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ type Client struct {
readerPool sync.Pool
writerPool sync.Pool

// Transport defines a transport-like mechanism that wraps every request/response.
Transport RoundTripper

// Callback for establishing new connections to hosts.
//
// Default DialTimeout is used if not set.
Expand Down Expand Up @@ -526,6 +529,7 @@ func (c *Client) Do(req *Request, resp *Response) error {
if hc == nil {
hc = &HostClient{
Addr: AddMissingPort(string(host), isTLS),
Transport: c.Transport,
Name: c.Name,
NoDefaultUserAgentHeader: c.NoDefaultUserAgentHeader,
Dial: c.Dial,
Expand Down

0 comments on commit 655424d

Please sign in to comment.