From 3dd235a1ad1e25b964226112b55a84fd9cdb2d00 Mon Sep 17 00:00:00 2001 From: Alexander Vershilov Date: Mon, 15 Jun 2020 20:21:41 +0300 Subject: [PATCH] Sent Accept-Encoding: identity in the head requests. (#155) It appeared that some s3 servers (Yandex storage in particular) honour `Accept-Encoding: gzip` request headeer. In such a case servers can't send `Content-Length` header as transfer size differ from the body size. The simplest solution for this problem is to force http-client to send `Accept-Encoding: identity` header in the HeadObject request. Co-authored-by: Aditya Manthramurthy --- src/Network/Minio/S3API.hs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Network/Minio/S3API.hs b/src/Network/Minio/S3API.hs index ce05771..f016951 100644 --- a/src/Network/Minio/S3API.hs +++ b/src/Network/Minio/S3API.hs @@ -158,6 +158,10 @@ getObject' bucket object queryParams headers = do riObject = Just object, riQueryParams = queryParams, riHeaders = headers + -- This header is required for safety as otherwise http-client, + -- sends Accept-Encoding: gzip, and the server may actually gzip + -- body. In that case Content-Length header will be missing. + <> [("Accept-Encoding", "identity")] } -- | Creates a bucket via a PUT bucket call. @@ -550,8 +554,11 @@ headObject bucket object reqHeaders = do riBucket = Just bucket, riObject = Just object, riHeaders = reqHeaders + -- This header is required for safety as otherwise http-client, + -- sends Accept-Encoding: gzip, and the server may actually gzip + -- body. In that case Content-Length header will be missing. + <> [("Accept-Encoding", "identity")] } - maybe (throwIO MErrVInvalidObjectInfoResponse) return $ parseGetObjectHeaders object $ NC.responseHeaders resp