AWS SDK for C++

AWS SDK for C++ Version 1.11.440

Loading...
Searching...
No Matches
RequestPayloadCompression.h
1
6#pragma once
7
8#include <aws/core/AmazonWebServiceRequest.h>
9#include <aws/core/client/RequestCompression.h>
10#include <aws/core/http/HttpClient.h>
11#include <aws/core/http/HttpRequest.h>
12#include <smithy/client/common/AwsSmithyClientUtils.h>
13#include <iomanip>
14#include <cassert>
15
16namespace smithy
17{
18 namespace client
19 {
20 static const char AWS_CLIENT_REQUEST_COMPRESSION_LOG_TAG[] = "RequestPayloadCompression";
21
23 {
24 public:
26 const std::shared_ptr<Aws::Http::HttpRequest>& httpRequest,
27 const Aws::Client::CompressionAlgorithm& compressionAlgorithm,
28 const std::shared_ptr<Aws::Http::HttpClient>& httpClient)
29 {
30 if (Aws::Client::CompressionAlgorithm::NONE != compressionAlgorithm)
31 {
33 auto compressOutcome = rc.compress(pRequest->GetBody(), compressionAlgorithm);
34
35 if (compressOutcome.IsSuccess())
36 {
37 const Aws::String compressionAlgorithmId = Aws::Client::GetCompressionAlgorithmId(
38 compressionAlgorithm);
40 compressionAlgorithmId);
42 compressOutcome.GetResult(),
43 httpClient,
44 pRequest->ShouldComputeContentMd5(),
45 pRequest->IsStreaming() && pRequest->IsChunked() && httpClient->
46 SupportsChunkedTransferEncoding());
47 }
48 else
49 {
51 "Failed to compress request, submitting uncompressed");
53 pRequest->GetBody(),
54 httpClient,
55 pRequest->ShouldComputeContentMd5(),
56 pRequest->IsStreaming() && pRequest->IsChunked() && httpClient->
57 SupportsChunkedTransferEncoding());
58 }
59 }
60 }
61 };
62 }
63}
virtual std::shared_ptr< Aws::IOStream > GetBody() const =0
virtual bool ShouldComputeContentMd5() const
iostream_outcome compress(std::shared_ptr< Aws::IOStream > input, const CompressionAlgorithm &algorithm) const
static void AddCompressedContentBodyToRequest(const Aws::AmazonWebServiceRequest *pRequest, const std::shared_ptr< Aws::Http::HttpRequest > &httpRequest, const Aws::Client::CompressionAlgorithm &compressionAlgorithm, const std::shared_ptr< Aws::Http::HttpClient > &httpClient)
static void AppendHeaderValueToRequest(const std::shared_ptr< Aws::Http::HttpRequest > &httpRequest, const Aws::String &header, const Aws::String &value)
static void AddContentBodyToRequest(const std::shared_ptr< Aws::Http::HttpRequest > &httpRequest, const std::shared_ptr< Aws::IOStream > &body, const std::shared_ptr< Aws::Http::HttpClient > &httpClient, bool needsContentMd5, bool isChunked)
Aws::String AWS_CORE_API GetCompressionAlgorithmId(const CompressionAlgorithm &algorithm)
AWS_CORE_API const char CONTENT_ENCODING_HEADER[]
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
Definition AWSString.h:97
static const char AWS_CLIENT_REQUEST_COMPRESSION_LOG_TAG[]