()
| 106 | } |
| 107 | |
| 108 | func (srv *server) createTransport() *http.Transport { |
| 109 | // Start with defaults from http.DefaultTransport |
| 110 | transport := &http.Transport{ |
| 111 | Proxy: http.ProxyFromEnvironment, |
| 112 | DialContext: (&net.Dialer{ |
| 113 | Timeout: 30 * time.Second, |
| 114 | KeepAlive: 30 * time.Second, |
| 115 | DualStack: true, |
| 116 | }).DialContext, |
| 117 | MaxIdleConns: 100, |
| 118 | IdleConnTimeout: 90 * time.Second, |
| 119 | TLSHandshakeTimeout: 10 * time.Second, |
| 120 | ExpectContinueTimeout: 1 * time.Second, |
| 121 | } |
| 122 | // Setup HTTPS client |
| 123 | tlsConfig := srv.TLSConfig |
| 124 | tlsConfig.BuildNameToCertificate() |
| 125 | transport.TLSClientConfig = tlsConfig |
| 126 | // Setup Proxy |
| 127 | if srv.proxy != nil { |
| 128 | transport.Proxy = srv.proxy |
| 129 | } |
| 130 | return transport |
| 131 | } |
| 132 | |
| 133 | // post connects to the remote server and returns a Response struct |
| 134 | func (srv *server) post(url string, jsonData []byte) (*api.Response, error) { |
no test coverage detected