|
|
@@ -1,6 +1,7 @@ |
|
|
|
package sdk |
|
|
|
|
|
|
|
import ( |
|
|
|
"bytes" |
|
|
|
"context" |
|
|
|
"crypto/tls" |
|
|
|
"fmt" |
|
|
@@ -11,6 +12,7 @@ import ( |
|
|
|
"golib.gaore.com/GaoreGo/gaore-common-sdk-go/sdk/utils" |
|
|
|
"net" |
|
|
|
"net/http" |
|
|
|
"net/http/httputil" |
|
|
|
"net/url" |
|
|
|
"os" |
|
|
|
"regexp" |
|
|
@@ -91,6 +93,16 @@ func (client *Client) InitWithAccessKey(accessKeyId, accessKeySecret, accessKeyF |
|
|
|
return client.InitWithOptions(config, credential) |
|
|
|
} |
|
|
|
|
|
|
|
func (client *Client) InitWithStsToken(accessKeyId, accessKeySecret, accessKeyFrom string) (err error) { |
|
|
|
config := client.InitWithConfig() |
|
|
|
credential := &credentials.StdTokenCredential{ |
|
|
|
AccessKeyId: accessKeyId, |
|
|
|
AccessKeySecret: accessKeySecret, |
|
|
|
AccessKeyFrom: accessKeyFrom, |
|
|
|
} |
|
|
|
return client.InitWithOptions(config, credential) |
|
|
|
} |
|
|
|
|
|
|
|
func (client *Client) InitWithOptions(config *Config, credential auth.Credential) (err error) { |
|
|
|
client.httpClient = &http.Client{} |
|
|
|
client.config = config |
|
|
@@ -227,8 +239,10 @@ func (client *Client) DoActionWithSigner(request requests.AcsRequest, response r |
|
|
|
client.httpClient.Transport = trans |
|
|
|
} |
|
|
|
|
|
|
|
var httpResponse *http.Response |
|
|
|
dump, err := httputil.DumpRequest(httpRequest, true) |
|
|
|
debug("client %s", bytes.NewBuffer(dump).String()) |
|
|
|
|
|
|
|
var httpResponse *http.Response |
|
|
|
httpResponse, err = hookDo(client.httpClient.Do)(httpRequest) |
|
|
|
if err != nil { |
|
|
|
return |
|
|
@@ -285,8 +299,6 @@ func (client *Client) buildRequestWithSigner(request requests.AcsRequest, signer |
|
|
|
userAgent := DefaultUserAgent |
|
|
|
httpRequest.Header.Set("User-Agent", userAgent) |
|
|
|
|
|
|
|
debug("%s", request.GetStringToSign()) |
|
|
|
debug("%s", httpRequest.Method) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|