| 15 | ) |
| 16 | |
| 17 | func GetDefaultHoverflyHTTPClient(tlsVerification bool, upstreamProxy string) *http.Client { |
| 18 | |
| 19 | var proxyURL func(*http.Request) (*url.URL, error) |
| 20 | if upstreamProxy == "" { |
| 21 | proxyURL = http.ProxyURL(nil) |
| 22 | } else { |
| 23 | if upstreamProxy[0:4] != "http" { |
| 24 | upstreamProxy = "http://" + upstreamProxy |
| 25 | } |
| 26 | u, err := url.Parse(upstreamProxy) |
| 27 | if err != nil { |
| 28 | log.Fatalf("Could not parse upstream proxy: %s", err.Error()) |
| 29 | } |
| 30 | proxyURL = http.ProxyURL(u) |
| 31 | } |
| 32 | |
| 33 | return &http.Client{CheckRedirect: func(req *http.Request, via []*http.Request) error { |
| 34 | return http.ErrUseLastResponse |
| 35 | }, Transport: &http.Transport{ |
| 36 | Proxy: proxyURL, |
| 37 | TLSClientConfig: &tls.Config{ |
| 38 | InsecureSkipVerify: !tlsVerification, |
| 39 | Renegotiation: tls.RenegotiateFreelyAsClient, |
| 40 | }, |
| 41 | }} |
| 42 | } |
| 43 | |
| 44 | func GetHttpClient(hf *Hoverfly, host string) (*http.Client, error) { |
| 45 | if hf.Cfg.PACFile != nil { |