Skip to content

Commit

Permalink
Merge pull request #60803 from ClickHouse/backport/24.1/60748
Browse files Browse the repository at this point in the history
Backport #60748 to 24.1: Prevent setting custom metadata headers on unsupported multipart upload operations
  • Loading branch information
alexey-milovidov committed Mar 5, 2024
2 parents 8a5fe4f + 37a9baf commit c6129a2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/IO/S3/Requests.cpp
Expand Up @@ -52,6 +52,20 @@ Aws::Http::HeaderValueCollection CopyObjectRequest::GetRequestSpecificHeaders()
return headers;
}

void CompleteMultipartUploadRequest::SetAdditionalCustomHeaderValue(const Aws::String& headerName, const Aws::String& headerValue)
{
// S3's CompleteMultipartUpload doesn't support metadata headers so we skip adding them
if (!headerName.starts_with("x-amz-meta-"))
Model::CompleteMultipartUploadRequest::SetAdditionalCustomHeaderValue(headerName, headerValue);
}

void UploadPartRequest::SetAdditionalCustomHeaderValue(const Aws::String& headerName, const Aws::String& headerValue)
{
// S3's UploadPart doesn't support metadata headers so we skip adding them
if (!headerName.starts_with("x-amz-meta-"))
Model::UploadPartRequest::SetAdditionalCustomHeaderValue(headerName, headerValue);
}

Aws::String ComposeObjectRequest::SerializePayload() const
{
if (component_names.empty())
Expand All @@ -70,6 +84,7 @@ Aws::String ComposeObjectRequest::SerializePayload() const
return payload_doc.ConvertToString();
}


void ComposeObjectRequest::AddQueryStringParameters(Aws::Http::URI & /*uri*/) const
{
}
Expand Down
14 changes: 12 additions & 2 deletions src/IO/S3/Requests.h
Expand Up @@ -107,10 +107,20 @@ using ListObjectsV2Request = ExtendedRequest<Model::ListObjectsV2Request>;
using ListObjectsRequest = ExtendedRequest<Model::ListObjectsRequest>;
using GetObjectRequest = ExtendedRequest<Model::GetObjectRequest>;

class UploadPartRequest : public ExtendedRequest<Model::UploadPartRequest>
{
public:
void SetAdditionalCustomHeaderValue(const Aws::String& headerName, const Aws::String& headerValue) override;
};

class CompleteMultipartUploadRequest : public ExtendedRequest<Model::CompleteMultipartUploadRequest>
{
public:
void SetAdditionalCustomHeaderValue(const Aws::String& headerName, const Aws::String& headerValue) override;
};

using CreateMultipartUploadRequest = ExtendedRequest<Model::CreateMultipartUploadRequest>;
using CompleteMultipartUploadRequest = ExtendedRequest<Model::CompleteMultipartUploadRequest>;
using AbortMultipartUploadRequest = ExtendedRequest<Model::AbortMultipartUploadRequest>;
using UploadPartRequest = ExtendedRequest<Model::UploadPartRequest>;
using UploadPartCopyRequest = ExtendedRequest<Model::UploadPartCopyRequest>;

using PutObjectRequest = ExtendedRequest<Model::PutObjectRequest>;
Expand Down

0 comments on commit c6129a2

Please sign in to comment.