-
Notifications
You must be signed in to change notification settings - Fork 170
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
406c2cd
commit e7f07b8
Showing
4 changed files
with
22 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ import ( | |
"net" | ||
"strings" | ||
"sync" | ||
"time" | ||
|
||
http "github.com/bogdanfinn/fhttp" | ||
"github.com/bogdanfinn/fhttp/http2" | ||
|
@@ -141,7 +142,19 @@ func (rt *roundTripper) dialTLS(ctx context.Context, network, addr string) (net. | |
utlsConfig.ServerName = rt.serverNameOverwrite | ||
} | ||
|
||
t2 := http2.Transport{DialTLS: rt.dialTLSHTTP2, TLSClientConfig: utlsConfig, ConnectionFlow: rt.connectionFlow, HeaderPriority: rt.headerPriority} | ||
idleConnectionTimeout := 90 * time.Second | ||
|
||
if rt.transportOptions != nil { | ||
idleConnectionTimeout = rt.transportOptions.IdleConnTimeout | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
bogdanfinn
Author
Owner
|
||
} | ||
|
||
t2 := http2.Transport{ | ||
DialTLS: rt.dialTLSHTTP2, | ||
TLSClientConfig: utlsConfig, | ||
ConnectionFlow: rt.connectionFlow, | ||
HeaderPriority: rt.headerPriority, | ||
IdleConnTimeout: idleConnectionTimeout, | ||
} | ||
|
||
if rt.transportOptions != nil { | ||
t1 := t2.GetT1() | ||
|
@@ -154,6 +167,7 @@ func (rt *roundTripper) dialTLS(ctx context.Context, network, addr string) (net. | |
t1.MaxResponseHeaderBytes = rt.transportOptions.MaxResponseHeaderBytes | ||
t1.WriteBufferSize = rt.transportOptions.WriteBufferSize | ||
t1.ReadBufferSize = rt.transportOptions.ReadBufferSize | ||
t1.IdleConnTimeout = rt.transportOptions.IdleConnTimeout | ||
} | ||
} | ||
|
||
|
@@ -221,6 +235,7 @@ func (rt *roundTripper) buildHttp1Transport() *http.Transport { | |
t.MaxResponseHeaderBytes = rt.transportOptions.MaxResponseHeaderBytes | ||
t.WriteBufferSize = rt.transportOptions.WriteBufferSize | ||
t.ReadBufferSize = rt.transportOptions.ReadBufferSize | ||
t.IdleConnTimeout = rt.transportOptions.IdleConnTimeout | ||
} | ||
|
||
return t | ||
|
Just a note:
If a user uses the following set of TransportOptions:
IdleConnTimeout
will be set to 0 and won't use the default value. One way to overcome it might be using a pointer:In this case, if it is not set by the user,
IdleConnTimeout
will benil
and the default value can be used.