class Aws::Plugins::DynamoDBCRC32Validation::Handler
def call(context)
def call(context) # disable response gzipping - Net::HTTP unzips these responses # before we can see the body, making it impossible to verify # the CRC32 checksum against the compressed body stream context.http_request.headers['accept-encoding'] = '' @handler.call(context).on_success do |response| response.error = validate(context) end end
def crc32_is_valid?(response)
def crc32_is_valid?(response) if crc_checksum = response.headers['x-amz-crc32'] crc_checksum.to_i == Zlib.crc32(response.body_contents) else true end end
def validate(context)
def validate(context) unless crc32_is_valid?(context.http_response) msg = "Response failed CRC32 check." return Aws::DynamoDB::Errors::CRC32CheckFailed.new(context, msg) end end