chore(aws): upgrade aws dependencies
This commit is contained in:
18
vendor/github.com/aws/smithy-go/transport/http/middleware_close_response_body.go
generated
vendored
18
vendor/github.com/aws/smithy-go/transport/http/middleware_close_response_body.go
generated
vendored
@ -2,9 +2,10 @@ package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/aws/smithy-go/logging"
|
||||
"github.com/aws/smithy-go/middleware"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
)
|
||||
|
||||
// AddErrorCloseResponseBodyMiddleware adds the middleware to automatically
|
||||
@ -28,6 +29,8 @@ func (m *errorCloseResponseBodyMiddleware) HandleDeserialize(
|
||||
out, metadata, err := next.HandleDeserialize(ctx, input)
|
||||
if err != nil {
|
||||
if resp, ok := out.RawResponse.(*Response); ok && resp != nil && resp.Body != nil {
|
||||
// Consume the full body to prevent TCP connection resets on some platforms
|
||||
_, _ = io.Copy(ioutil.Discard, resp.Body)
|
||||
// Do not validate that the response closes successfully.
|
||||
resp.Body.Close()
|
||||
}
|
||||
@ -60,8 +63,15 @@ func (m *closeResponseBody) HandleDeserialize(
|
||||
}
|
||||
|
||||
if resp, ok := out.RawResponse.(*Response); ok {
|
||||
if err = resp.Body.Close(); err != nil {
|
||||
return out, metadata, fmt.Errorf("close response body failed, %w", err)
|
||||
// Consume the full body to prevent TCP connection resets on some platforms
|
||||
_, copyErr := io.Copy(ioutil.Discard, resp.Body)
|
||||
if copyErr != nil {
|
||||
middleware.GetLogger(ctx).Logf(logging.Warn, "failed to discard remaining HTTP response body, this may affect connection reuse")
|
||||
}
|
||||
|
||||
closeErr := resp.Body.Close()
|
||||
if closeErr != nil {
|
||||
middleware.GetLogger(ctx).Logf(logging.Warn, "failed to close HTTP response body, this may affect connection reuse")
|
||||
}
|
||||
}
|
||||
|
||||
|
10
vendor/github.com/aws/smithy-go/transport/http/middleware_http_logging.go
generated
vendored
10
vendor/github.com/aws/smithy-go/transport/http/middleware_http_logging.go
generated
vendored
@ -46,11 +46,13 @@ func (r *RequestResponseLogger) HandleDeserialize(
|
||||
|
||||
logger.Logf(logging.Debug, "Request\n%v", string(reqBytes))
|
||||
|
||||
smithyRequest, err = smithyRequest.SetStream(rc.Body)
|
||||
if err != nil {
|
||||
return out, metadata, err
|
||||
if r.LogRequestWithBody {
|
||||
smithyRequest, err = smithyRequest.SetStream(rc.Body)
|
||||
if err != nil {
|
||||
return out, metadata, err
|
||||
}
|
||||
in.Request = smithyRequest
|
||||
}
|
||||
in.Request = smithyRequest
|
||||
}
|
||||
|
||||
out, metadata, err = next.HandleDeserialize(ctx, in)
|
||||
|
79
vendor/github.com/aws/smithy-go/transport/http/middleware_min_proto.go
generated
vendored
Normal file
79
vendor/github.com/aws/smithy-go/transport/http/middleware_min_proto.go
generated
vendored
Normal file
@ -0,0 +1,79 @@
|
||||
package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/aws/smithy-go/middleware"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// MinimumProtocolError is an error type indicating that the established connection did not meet the expected minimum
|
||||
// HTTP protocol version.
|
||||
type MinimumProtocolError struct {
|
||||
proto string
|
||||
expectedProtoMajor int
|
||||
expectedProtoMinor int
|
||||
}
|
||||
|
||||
// Error returns the error message.
|
||||
func (m *MinimumProtocolError) Error() string {
|
||||
return fmt.Sprintf("operation requires minimum HTTP protocol of HTTP/%d.%d, but was %s",
|
||||
m.expectedProtoMajor, m.expectedProtoMinor, m.proto)
|
||||
}
|
||||
|
||||
// RequireMinimumProtocol is a deserialization middleware that asserts that the established HTTP connection
|
||||
// meets the minimum major ad minor version.
|
||||
type RequireMinimumProtocol struct {
|
||||
ProtoMajor int
|
||||
ProtoMinor int
|
||||
}
|
||||
|
||||
// AddRequireMinimumProtocol adds the RequireMinimumProtocol middleware to the stack using the provided minimum
|
||||
// protocol major and minor version.
|
||||
func AddRequireMinimumProtocol(stack *middleware.Stack, major, minor int) error {
|
||||
return stack.Deserialize.Insert(&RequireMinimumProtocol{
|
||||
ProtoMajor: major,
|
||||
ProtoMinor: minor,
|
||||
}, "OperationDeserializer", middleware.Before)
|
||||
}
|
||||
|
||||
// ID returns the middleware identifier string.
|
||||
func (r *RequireMinimumProtocol) ID() string {
|
||||
return "RequireMinimumProtocol"
|
||||
}
|
||||
|
||||
// HandleDeserialize asserts that the established connection is a HTTP connection with the minimum major and minor
|
||||
// protocol version.
|
||||
func (r *RequireMinimumProtocol) HandleDeserialize(
|
||||
ctx context.Context, in middleware.DeserializeInput, next middleware.DeserializeHandler,
|
||||
) (
|
||||
out middleware.DeserializeOutput, metadata middleware.Metadata, err error,
|
||||
) {
|
||||
out, metadata, err = next.HandleDeserialize(ctx, in)
|
||||
if err != nil {
|
||||
return out, metadata, err
|
||||
}
|
||||
|
||||
response, ok := out.RawResponse.(*Response)
|
||||
if !ok {
|
||||
return out, metadata, fmt.Errorf("unknown transport type: %T", out.RawResponse)
|
||||
}
|
||||
|
||||
if !strings.HasPrefix(response.Proto, "HTTP") {
|
||||
return out, metadata, &MinimumProtocolError{
|
||||
proto: response.Proto,
|
||||
expectedProtoMajor: r.ProtoMajor,
|
||||
expectedProtoMinor: r.ProtoMinor,
|
||||
}
|
||||
}
|
||||
|
||||
if response.ProtoMajor < r.ProtoMajor || response.ProtoMinor < r.ProtoMinor {
|
||||
return out, metadata, &MinimumProtocolError{
|
||||
proto: response.Proto,
|
||||
expectedProtoMajor: r.ProtoMajor,
|
||||
expectedProtoMinor: r.ProtoMinor,
|
||||
}
|
||||
}
|
||||
|
||||
return out, metadata, err
|
||||
}
|
16
vendor/github.com/aws/smithy-go/transport/http/request.go
generated
vendored
16
vendor/github.com/aws/smithy-go/transport/http/request.go
generated
vendored
@ -130,14 +130,20 @@ func (r *Request) SetStream(reader io.Reader) (rc *Request, err error) {
|
||||
func (r *Request) Build(ctx context.Context) *http.Request {
|
||||
req := r.Request.Clone(ctx)
|
||||
|
||||
if r.stream != nil {
|
||||
req.Body = iointernal.NewSafeReadCloser(ioutil.NopCloser(r.stream))
|
||||
} else {
|
||||
// we update the content-length to 0,
|
||||
// if request stream was not set.
|
||||
if r.stream == nil && req.ContentLength == -1 {
|
||||
req.ContentLength = 0
|
||||
}
|
||||
|
||||
switch stream := r.stream.(type) {
|
||||
case *io.PipeReader:
|
||||
req.Body = ioutil.NopCloser(stream)
|
||||
req.ContentLength = -1
|
||||
default:
|
||||
if r.stream != nil {
|
||||
req.Body = iointernal.NewSafeReadCloser(ioutil.NopCloser(stream))
|
||||
}
|
||||
}
|
||||
|
||||
return req
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user