瀏覽代碼

fix http proxy

wenzuochao 6 年之前
父節點
當前提交
c11c80a51e
共有 1 個文件被更改,包括 17 次插入19 次删除
  1. 17 19
      sdk/client.go

+ 17 - 19
sdk/client.go

@@ -61,9 +61,9 @@ type Client struct {
 	isInsecure     bool
 	isInsecure     bool
 	regionId       string
 	regionId       string
 	config         *Config
 	config         *Config
-	httpProxy      *string
-	httpsProxy     *string
-	noProxy        *string
+	httpProxy      string
+	httpsProxy     string
+	noProxy        string
 	userAgent      map[string]string
 	userAgent      map[string]string
 	signer         auth.Signer
 	signer         auth.Signer
 	httpClient     *http.Client
 	httpClient     *http.Client
@@ -90,26 +90,26 @@ func (client *Client) GetHTTPSInsecure() bool {
 }
 }
 
 
 func (client *Client) SetHttpsProxy(httpsProxy string) {
 func (client *Client) SetHttpsProxy(httpsProxy string) {
-	client.httpsProxy = &httpsProxy
+	client.httpsProxy = httpsProxy
 }
 }
 
 
-func (client *Client) GetHttpsProxy() *string {
+func (client *Client) GetHttpsProxy() string {
 	return client.httpsProxy
 	return client.httpsProxy
 }
 }
 
 
 func (client *Client) SetHttpProxy(httpProxy string) {
 func (client *Client) SetHttpProxy(httpProxy string) {
-	client.httpProxy = &httpProxy
+	client.httpProxy = httpProxy
 }
 }
 
 
-func (client *Client) GetHttpProxy() *string {
+func (client *Client) GetHttpProxy() string {
 	return client.httpProxy
 	return client.httpProxy
 }
 }
 
 
 func (client *Client) SetNoProxy(noProxy string) {
 func (client *Client) SetNoProxy(noProxy string) {
-	client.noProxy = &noProxy
+	client.noProxy = noProxy
 }
 }
 
 
-func (client *Client) GetNoProxy() *string {
+func (client *Client) GetNoProxy() string {
 	return client.noProxy
 	return client.noProxy
 }
 }
 
 
@@ -170,21 +170,19 @@ func (client *Client) getHttpProxy(scheme string) (*url.URL, error) {
 	var proxy *url.URL
 	var proxy *url.URL
 	var err error
 	var err error
 	if scheme == "https" {
 	if scheme == "https" {
-		if client.GetHttpsProxy() != nil {
-			proxy, err = url.Parse(*client.httpsProxy)
+		if client.GetHttpsProxy() != "" {
+			proxy, err = url.Parse(client.httpsProxy)
 		} else if rawurl := os.Getenv("HTTPS_PROXY"); rawurl != "" {
 		} else if rawurl := os.Getenv("HTTPS_PROXY"); rawurl != "" {
 			proxy, err = url.Parse(rawurl)
 			proxy, err = url.Parse(rawurl)
 		} else if rawurl := os.Getenv("https_proxy"); rawurl != "" {
 		} else if rawurl := os.Getenv("https_proxy"); rawurl != "" {
 			proxy, err = url.Parse(rawurl)
 			proxy, err = url.Parse(rawurl)
 		}
 		}
 	} else {
 	} else {
-		if client.GetHttpProxy() != nil {
-			proxy, err = url.Parse(*client.httpProxy)
-		}
-		if rawurl := os.Getenv("HTTP_PROXY"); rawurl != "" && proxy == nil {
+		if client.GetHttpProxy() != "" {
+			proxy, err = url.Parse(client.httpProxy)
+		} else if rawurl := os.Getenv("HTTP_PROXY"); rawurl != "" {
 			proxy, err = url.Parse(rawurl)
 			proxy, err = url.Parse(rawurl)
-		}
-		if rawurl := os.Getenv("http_proxy"); rawurl != "" && proxy == nil {
+		} else if rawurl := os.Getenv("http_proxy"); rawurl != "" {
 			proxy, err = url.Parse(rawurl)
 			proxy, err = url.Parse(rawurl)
 		}
 		}
 	}
 	}
@@ -194,8 +192,8 @@ func (client *Client) getHttpProxy(scheme string) (*url.URL, error) {
 
 
 func (client *Client) getNoProxy(scheme string) []string {
 func (client *Client) getNoProxy(scheme string) []string {
 	var urls []string
 	var urls []string
-	if client.GetNoProxy() != nil {
-		urls = strings.Split(*client.noProxy, ",")
+	if client.GetNoProxy() != "" {
+		urls = strings.Split(client.noProxy, ",")
 	} else if rawurl := os.Getenv("NO_PROXY"); rawurl != "" {
 	} else if rawurl := os.Getenv("NO_PROXY"); rawurl != "" {
 		urls = strings.Split(rawurl, ",")
 		urls = strings.Split(rawurl, ",")
 	} else if rawurl := os.Getenv("no_proxy"); rawurl != "" {
 	} else if rawurl := os.Getenv("no_proxy"); rawurl != "" {