Merge pull request #6541 from salkin/proxy-transport

Add support for http proxy in transport
This commit is contained in:
Wenkai Yin 2018-12-18 15:46:29 +08:00 committed by GitHub
commit b28bca7af4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 2 deletions

View File

@ -39,7 +39,11 @@ func NewClient(c *http.Client, modifiers ...modifier.Modifier) *Client {
client: c,
}
if client.client == nil {
client.client = &http.Client{}
client.client = &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
},
}
}
if len(modifiers) > 0 {
client.modifiers = modifiers

View File

@ -21,6 +21,7 @@ import (
"net/http"
"net/url"
"strings"
// "time"
commonhttp "github.com/goharbor/harbor/src/common/http"
@ -39,11 +40,13 @@ func init() {
defaultHTTPTransport = &http.Transport{}
secureHTTPTransport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: false,
},
}
insecureHTTPTransport = &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: true,
},

View File

@ -41,7 +41,7 @@ const (
UsersURLSuffix = "/Users"
)
var uaaTransport = &http.Transport{}
var uaaTransport = &http.Transport{Proxy: http.ProxyFromEnvironment}
// Client provides funcs to interact with UAA.
type Client interface {

View File

@ -135,6 +135,7 @@ func initProjectManager() error {
}
AdmiralClient = &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
TLSClientConfig: &tls.Config{
RootCAs: pool,
},