Compare commits
1 Commits
main
...
increase-t
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64a122413b |
@ -37,7 +37,7 @@ func NewHTTPWrapper(opts ...Option) *httpWrapper {
|
|||||||
rt = customTransport{
|
rt = customTransport{
|
||||||
n: pipeline{
|
n: pipeline{
|
||||||
middlewares: internalMiddleware(cc),
|
middlewares: internalMiddleware(cc),
|
||||||
transport: defaultTransport(),
|
transport: defaultHttpTransport(),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
redirect = func(req *http.Request, via []*http.Request) error {
|
redirect = func(req *http.Request, via []*http.Request) error {
|
||||||
@ -132,13 +132,6 @@ func (pl pipeline) Next(req *http.Request, idx int) (*http.Response, error) {
|
|||||||
return pl.transport.RoundTrip(req)
|
return pl.transport.RoundTrip(req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultTransport() http.RoundTripper {
|
|
||||||
defaultTransport := http.DefaultTransport.(*http.Transport).Clone()
|
|
||||||
defaultTransport.ForceAttemptHTTP2 = true
|
|
||||||
|
|
||||||
return defaultTransport
|
|
||||||
}
|
|
||||||
|
|
||||||
func internalMiddleware(cc *clientConfig) []khttp.Middleware {
|
func internalMiddleware(cc *clientConfig) []khttp.Middleware {
|
||||||
mw := []khttp.Middleware{
|
mw := []khttp.Middleware{
|
||||||
&RetryMiddleware{
|
&RetryMiddleware{
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
package graph
|
package graph
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -150,12 +151,14 @@ func GetAuth(tenant string, client string, secret string) (*kauth.AzureIdentityA
|
|||||||
// can utilize it on a per-download basis.
|
// can utilize it on a per-download basis.
|
||||||
func KiotaHTTPClient(opts ...Option) *http.Client {
|
func KiotaHTTPClient(opts ...Option) *http.Client {
|
||||||
var (
|
var (
|
||||||
clientOptions = msgraphsdkgo.GetDefaultClientOptions()
|
clientOptions = msgraphsdkgo.GetDefaultClientOptions()
|
||||||
cc = populateConfig(opts...)
|
cc = populateConfig(opts...)
|
||||||
middlewares = kiotaMiddlewares(&clientOptions, cc)
|
middlewares = kiotaMiddlewares(&clientOptions, cc)
|
||||||
httpClient = msgraphgocore.GetDefaultClient(&clientOptions, middlewares...)
|
httpClient = msgraphgocore.GetDefaultClient(&clientOptions, middlewares...)
|
||||||
|
customTransport = khttp.NewCustomTransportWithParentTransport(defaultHttpTransport(), middlewares...)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
httpClient.Transport = customTransport
|
||||||
httpClient.Timeout = defaultHTTPClientTimeout
|
httpClient.Timeout = defaultHTTPClientTimeout
|
||||||
|
|
||||||
cc.apply(httpClient)
|
cc.apply(httpClient)
|
||||||
@ -163,6 +166,22 @@ func KiotaHTTPClient(opts ...Option) *http.Client {
|
|||||||
return httpClient
|
return httpClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func defaultHttpTransport() *http.Transport {
|
||||||
|
defaultTransport := khttp.GetDefaultTransport().(*http.Transport).Clone()
|
||||||
|
|
||||||
|
// default: 10 seconds
|
||||||
|
defaultTransport.TLSHandshakeTimeout = 30 * time.Second
|
||||||
|
|
||||||
|
// default: 30 seconds
|
||||||
|
nd := &net.Dialer{
|
||||||
|
Timeout: 60 * time.Second,
|
||||||
|
KeepAlive: 60 * time.Second,
|
||||||
|
}
|
||||||
|
defaultTransport.DialContext = nd.DialContext
|
||||||
|
|
||||||
|
return defaultTransport
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// HTTP Client Config
|
// HTTP Client Config
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user