fix unsafe dereference
This commit is contained in:
parent
df881e16b5
commit
9670bc14f8
1 changed files with 16 additions and 9 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -140,14 +141,20 @@ func putBuffer(buf *bytes.Buffer) {
|
||||||
// getClient gets an http client that's customized to be more performant when dealing with blobs of 2MB in size (most of our blobs)
|
// getClient gets an http client that's customized to be more performant when dealing with blobs of 2MB in size (most of our blobs)
|
||||||
func getClient() *http.Client {
|
func getClient() *http.Client {
|
||||||
// Customize the Transport to have larger connection pool
|
// Customize the Transport to have larger connection pool
|
||||||
defaultRoundTripper := http.DefaultTransport
|
defaultTransport := &http.Transport{
|
||||||
defaultTransportPointer := defaultRoundTripper.(*http.Transport)
|
DialContext: (&net.Dialer{
|
||||||
|
Timeout: 30 * time.Second,
|
||||||
|
KeepAlive: 30 * time.Second,
|
||||||
|
}).DialContext,
|
||||||
|
ForceAttemptHTTP2: true,
|
||||||
|
MaxIdleConns: 100,
|
||||||
|
IdleConnTimeout: 90 * time.Second,
|
||||||
|
TLSHandshakeTimeout: 10 * time.Second,
|
||||||
|
ExpectContinueTimeout: 1 * time.Second,
|
||||||
|
DisableCompression: true,
|
||||||
|
MaxIdleConnsPerHost: 100,
|
||||||
|
ReadBufferSize: stream.MaxBlobSize + 1024*10, //add an extra few KBs to make sure it fits the extra information
|
||||||
|
}
|
||||||
|
|
||||||
defaultTransport := *defaultTransportPointer // dereference it to get a copy of the struct that the pointer points to
|
return &http.Client{Transport: defaultTransport}
|
||||||
defaultTransport.MaxIdleConns = 100
|
|
||||||
defaultTransport.DisableCompression = true
|
|
||||||
defaultTransport.MaxIdleConnsPerHost = 100
|
|
||||||
defaultTransport.ReadBufferSize = stream.MaxBlobSize + 1024*10 //add an extra few KBs to make sure it fits the extra information
|
|
||||||
|
|
||||||
return &http.Client{Transport: &defaultTransport}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue