package customizations
import "github.com/aws/aws-sdk-go-v2/service/dynamodb/internal/customizations"
Package customizations provides customizations for the Amazon DynamoDB API client.
The DynamoDB API client uses two customizations, response checksum validation, and manual content-encoding: gzip support.
Middleware layering
Checksum validation needs to be performed first in deserialization chain on top of gzip decompression. Since the behavior of Deserialization is in reverse order to the other stack steps its easier to consider that "after" means "before".
HTTP Response -> Checksum -> gzip decompress -> deserialize
Response checksum validation
DynamoDB responses can include a X-Amz-Crc32 header with the CRC32 checksum value of the response body. If the response body is content-encoding: gzip, the checksum is of the gzipped response content.
If the header is present, the SDK should validate that the response payload computed CRC32 checksum matches the value provided in the header. The checksum header is based on the original payload provided returned by the service. Which means that if the response is gzipped the checksum is of the gzipped response, not the decompressed response bytes.
Customization option:
DisableValidateResponseChecksum (Enabled by Default)
Accept encoding gzip
The Go HTTP client automatically supports accept-encoding and content-encoding gzip by default. This default behavior is not desired by the SDK, and prevents validating the response body's checksum. To prevent this the SDK must manually control usage of content-encoding gzip.
To control content-encoding, the SDK must always set the `Accept-Encoding` header to a value. This prevents the HTTP client from using gzip automatically. When gzip is enabled on the API client, the SDK's customization will control decompressing the gzip data in order to not break the checksum validation. When gzip is disabled, the API client will disable gzip, preventing the HTTP client's default behavior.
Customization option:
EnableAcceptEncodingGzip (Disabled by Default)
Index ¶
- func AddAcceptEncodingGzip(stack *middleware.Stack, options AddAcceptEncodingGzipOptions)
- func AddValidateResponseChecksum(stack *middleware.Stack, options AddValidateResponseChecksumOptions)
- type AcceptEncodingGzipMiddleware
- func (*AcceptEncodingGzipMiddleware) HandleFinalize( ctx context.Context, input middleware.FinalizeInput, next middleware.FinalizeHandler, ) ( output middleware.FinalizeOutput, metadata middleware.Metadata, err error, )
- func (*AcceptEncodingGzipMiddleware) ID() string
- type AddAcceptEncodingGzipOptions
- type AddValidateResponseChecksumOptions
- type ChecksumMiddleware
- func (m *ChecksumMiddleware) HandleDeserialize( ctx context.Context, input middleware.DeserializeInput, next middleware.DeserializeHandler, ) ( output middleware.DeserializeOutput, metadata middleware.Metadata, err error, )
- func (*ChecksumMiddleware) ID() string
- type DecompressGzipMiddleware
- func (*DecompressGzipMiddleware) HandleDeserialize( ctx context.Context, input middleware.DeserializeInput, next middleware.DeserializeHandler, ) ( output middleware.DeserializeOutput, metadata middleware.Metadata, err error, )
- func (*DecompressGzipMiddleware) ID() string
- type DisableAcceptEncodingGzipMiddleware
Functions ¶
func AddAcceptEncodingGzip ¶
func AddAcceptEncodingGzip(stack *middleware.Stack, options AddAcceptEncodingGzipOptions)
AddAcceptEncodingGzip explicitly adds handling for accept-encoding GZIP middleware to the operation stack. This allows checksums to be correctly computed without disabling GZIP support.
func AddValidateResponseChecksum ¶
func AddValidateResponseChecksum(stack *middleware.Stack, options AddValidateResponseChecksumOptions)
AddValidateResponseChecksum adds the ChecksumMiddleware to the middleware stack if checksum is not disabled.
Types ¶
type AcceptEncodingGzipMiddleware ¶
type AcceptEncodingGzipMiddleware struct{}
AcceptEncodingGzipMiddleware provides a middleware to enable support for gzip responses, with manual decompression. This prevents the underlying HTTP client from performing the gzip decompression automatically.
func (*AcceptEncodingGzipMiddleware) HandleFinalize ¶
func (*AcceptEncodingGzipMiddleware) HandleFinalize( ctx context.Context, input middleware.FinalizeInput, next middleware.FinalizeHandler, ) ( output middleware.FinalizeOutput, metadata middleware.Metadata, err error, )
HandleFinalize implements the FinalizeMiddlware interface.
func (*AcceptEncodingGzipMiddleware) ID ¶
func (*AcceptEncodingGzipMiddleware) ID() string
ID returns the id for the middleware.
type AddAcceptEncodingGzipOptions ¶
type AddAcceptEncodingGzipOptions struct { Enable bool }
AddAcceptEncodingGzipOptions provides the options for the AddAcceptEncodingGzip middleware setup.
type AddValidateResponseChecksumOptions ¶
type AddValidateResponseChecksumOptions struct { Disable bool }
AddValidateResponseChecksumOptions provides the options for the AddValidateResponseChecksum middleware setup.
type ChecksumMiddleware ¶
type ChecksumMiddleware struct{}
ChecksumMiddleware provides a middleware to validate the DynamoDB response body's integrity by comparing the computed CRC32 checksum with the value provided in the HTTP response header.
func (*ChecksumMiddleware) HandleDeserialize ¶
func (m *ChecksumMiddleware) HandleDeserialize( ctx context.Context, input middleware.DeserializeInput, next middleware.DeserializeHandler, ) ( output middleware.DeserializeOutput, metadata middleware.Metadata, err error, )
HandleDeserialize implements the Deserialize middleware handle method.
func (*ChecksumMiddleware) ID ¶
func (*ChecksumMiddleware) ID() string
ID returns the middleware ID.
type DecompressGzipMiddleware ¶
type DecompressGzipMiddleware struct{}
DecompressGzipMiddleware provides the middleware for decompressing a gzip response from the service.
func (*DecompressGzipMiddleware) HandleDeserialize ¶
func (*DecompressGzipMiddleware) HandleDeserialize( ctx context.Context, input middleware.DeserializeInput, next middleware.DeserializeHandler, ) ( output middleware.DeserializeOutput, metadata middleware.Metadata, err error, )
HandleDeserialize implements the DeserializeMiddlware interface.
func (*DecompressGzipMiddleware) ID ¶
func (*DecompressGzipMiddleware) ID() string
ID returns the id for the middleware.
type DisableAcceptEncodingGzipMiddleware ¶
type DisableAcceptEncodingGzipMiddleware struct{}
DisableAcceptEncodingGzipMiddleware provides the middleware that will disable the underlying http client automatically enabling for gzip decompress content-encoding support.
func (*DisableAcceptEncodingGzipMiddleware) HandleFinalize ¶
func (*DisableAcceptEncodingGzipMiddleware) HandleFinalize( ctx context.Context, input middleware.FinalizeInput, next middleware.FinalizeHandler, ) ( output middleware.FinalizeOutput, metadata middleware.Metadata, err error, )
HandleFinalize implements the FinalizeMiddlware interface.
func (*DisableAcceptEncodingGzipMiddleware) ID ¶
func (*DisableAcceptEncodingGzipMiddleware) ID() string
ID returns the id for the middleware.
Source Files ¶
accept_encoding_gzip.go checksum.go doc.go
- Version
- v0.1.0
- Published
- Sep 29, 2020
- Platform
- js/wasm
- Imports
- 11 packages
- Last checked
- 19 minutes ago –
Tools for package owners.