Skip to content

Setting any value to PutObject's poContentEncoding breaks signing #537

@mgajda

Description

@mgajda

Attempting to run this snippet:

{-# LANGUAGE OverloadedStrings #-}
module Main where

import Network.AWS
import Network.AWS.S3
import Network.AWS.S3.PutObject
import Control.Lens

bucketName = "test.migamake.com"

main = do
  env  <- newEnv Discover
  runResourceT $ runAWS env $
    within Frankfurt $ do
      content <- chunkedFile 8192 "public/index.html"
      send $ set poContentType     (Just "text/html")
           $ set poContentEncoding (Just "identity")
           $ putObject bucketName (ObjectKey "index.html") content

Results in signing error:

*** Exception: ServiceError (ServiceError' {_serviceAbbrev = Abbrev "S3", _serviceStatus = Status {statusCode = 403, statusMessage = "Forbidden"}, _serviceHeaders = [("x-amz-request-id","C211E7670B81BA51"),("x-amz-id-2","VdRQD1mnawJ2iXGc+CYJnPNsH8ZPtIiWcUqZUieBuOh4SBZXZNEjCSZnpQvXS7/UTElB3c68Qbw="),("Content-Type","application/xml"),("Transfer-Encoding","chunked"),("Date","Sun, 28 Jul 2019 08:50:02 GMT"),("Connection","close"),("Server","AmazonS3")], _serviceCode = ErrorCode "SignatureDoesNotMatch", _serviceMessage = Just (ErrorMessage "The request signature we calculated does not match the signature you provided. Check your key and signing method."), _serviceRequestId = Just (RequestId "C211E7670B81BA51")})

This breaks workaround for #536.

Note that normally there may be multiple content encodings put into a single stance, but it seems that now we have aws-chunked hardwired and it interferes with attempt to assign value here.

I prepared a small example of this issue:
https://github.com/mgajda/aws-empty-content-encoding-issue/tree/assign-content-encoding

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions