customizations

package
v0.26.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 30, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

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

Constants

This section is empty.

Variables

This section is empty.

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

HandleFinalize implements the FinalizeMiddlware interface.

func (*AcceptEncodingGzipMiddleware) ID

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

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

HandleDeserialize implements the DeserializeMiddlware interface.

func (*DecompressGzipMiddleware) ID

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

HandleFinalize implements the FinalizeMiddlware interface.

func (*DisableAcceptEncodingGzipMiddleware) ID

ID returns the id for the middleware.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL