forked from IBM-Cloud/bluemix-go
/
http.go
40 lines (35 loc) · 819 Bytes
/
http.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package http
import (
"crypto/tls"
"fmt"
"net"
"net/http"
"runtime"
"time"
"github.com/IBM-Cloud/bluemix-go"
)
//NewHTTPClient ...
func NewHTTPClient(config *bluemix.Config) *http.Client {
return &http.Client{
Transport: makeTransport(config),
Timeout: config.HTTPTimeout,
}
}
func makeTransport(config *bluemix.Config) http.RoundTripper {
return NewTraceLoggingTransport(&http.Transport{
Proxy: http.ProxyFromEnvironment,
Dial: (&net.Dialer{
Timeout: 50 * time.Second,
KeepAlive: 30 * time.Second,
}).Dial,
TLSHandshakeTimeout: 20 * time.Second,
DisableCompression: true,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: config.SSLDisable,
},
})
}
//UserAgent ...
func UserAgent() string {
return fmt.Sprintf("Blumix-go SDK %s / %s ", bluemix.Version, runtime.GOOS)
}