代码拉取完成,页面将自动刷新
// Copyright 2012-present Oliver Eilhard. All rights reserved.
// Use of this source code is governed by a MIT-license.
// See http://olivere.mit-license.org/license.txt for details.
package aws
import (
"net/http"
"github.com/smartystreets/go-aws-auth"
)
// NewV4SigningClient returns an *http.Client that will sign all requests with AWS V4 Signing.
func NewV4SigningClient(credentials awsauth.Credentials) *http.Client {
return NewV4SigningClientWithHTTPClient(credentials, http.DefaultClient)
}
// NewV4SigningClientWithHTTPClient returns an *http.Client that will sign all requests with AWS V4 Signing.
func NewV4SigningClientWithHTTPClient(credentials awsauth.Credentials, httpClient *http.Client) *http.Client {
return &http.Client{
Transport: V4Transport{
HTTPClient: httpClient,
Credentials: credentials,
},
}
}
// V4Transport is a RoundTripper that will sign requests with AWS V4 Signing
type V4Transport struct {
HTTPClient *http.Client
Credentials awsauth.Credentials
}
// RoundTrip uses the underlying RoundTripper transport, but signs request first with AWS V4 Signing
func (st V4Transport) RoundTrip(req *http.Request) (*http.Response, error) {
// Instead of directly modifying the request then calling http.DefaultTransport,
// instead restart the request with the HTTPClient.Do function,
// because the HTTPClient includes safeguards around not forwarding the
// signed Authorization header to untrusted domains.
return st.HTTPClient.Do(awsauth.Sign4(req, st.Credentials))
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。