Skip to content

Commit 324bd29

Browse files
committed
refactor: centralize aws-chunked encoding in ChunkingInterceptor
Move aws-chunked encoding logic from individual HTTP clients to a centralized ChunkingInterceptor for better separation of concerns. - Add ChunkingInterceptor to handle aws-chunked encoding at request level - Remove custom chunking logic from CRT, Curl, and Windows HTTP clients - Simplify HTTP clients to focus on transport-only responsibilities - Maintain full backwards compatibility with existing APIs
1 parent 66cd9f3 commit 324bd29

File tree

10 files changed

+187
-82
lines changed

10 files changed

+187
-82
lines changed

src/aws-cpp-sdk-core/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ file(GLOB AWS_INTERNAL_HEADERS "include/aws/core/internal/*.h")
5151
file(GLOB NET_HEADERS "include/aws/core/net/*.h")
5252
file(GLOB HTTP_HEADERS "include/aws/core/http/*.h")
5353
file(GLOB HTTP_STANDARD_HEADERS "include/aws/core/http/standard/*.h")
54+
file(GLOB HTTP_INTERCEPTOR_HEADERS "include/aws/core/http/interceptor/*.h")
5455
file(GLOB CONFIG_HEADERS "include/aws/core/config/*.h")
5556
file(GLOB CONFIG_DEFAULTS_HEADERS "include/aws/core/config/defaults/*.h")
5657
file(GLOB ENDPOINT_HEADERS "include/aws/core/endpoint/*.h")
@@ -106,6 +107,7 @@ file(GLOB AWS_INTERNAL_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/internal/*.cpp
106107
file(GLOB AWS_MODEL_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/aws/model/*.cpp")
107108
file(GLOB HTTP_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/http/*.cpp")
108109
file(GLOB HTTP_STANDARD_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/http/standard/*.cpp")
110+
file(GLOB HTTP_INTERCEPTOR_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/http/interceptor/*.cpp")
109111
file(GLOB CONFIG_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/config/*.cpp")
110112
file(GLOB CONFIG_DEFAULTS_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/config/defaults/*.cpp")
111113
file(GLOB ENDPOINT_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/source/endpoint/*.cpp")
@@ -225,6 +227,7 @@ file(GLOB AWS_NATIVE_SDK_COMMON_SRC
225227
${AWS_AUTH_BEARER_TOKEN_PROVIDER_SOURCE}
226228
${AWS_CLIENT_SOURCE}
227229
${HTTP_STANDARD_SOURCE}
230+
${HTTP_INTERCEPTOR_SOURCE}
228231
${HTTP_CLIENT_SOURCE}
229232
${CRT_HTTP_SOURCE}
230233
${CONFIG_SOURCE}
@@ -258,6 +261,7 @@ file(GLOB AWS_NATIVE_SDK_COMMON_HEADERS
258261
${NET_HEADERS}
259262
${HTTP_HEADERS}
260263
${HTTP_STANDARD_HEADERS}
264+
${HTTP_INTERCEPTOR_HEADERS}
261265
${CONFIG_HEADERS}
262266
${CONFIG_DEFAULTS_HEADERS}
263267
${ENDPOINT_HEADERS}
@@ -397,6 +401,7 @@ if(MSVC)
397401
source_group("Header Files\\aws\\core\\net" FILES ${NET_HEADERS})
398402
source_group("Header Files\\aws\\core\\http" FILES ${HTTP_HEADERS})
399403
source_group("Header Files\\aws\\core\\http\\standard" FILES ${HTTP_STANDARD_HEADERS})
404+
source_group("Header Files\\aws\\core\\http\\interceptor" FILES ${HTTP_INTERCEPTOR_HEADERS})
400405
source_group("Header Files\\aws\\core\\config" FILES ${CONFIG_HEADERS})
401406
source_group("Header Files\\aws\\core\\config\\defaults" FILES ${CONFIG_DEFAULTS_HEADERS})
402407
source_group("Header Files\\aws\\core\\endpoint" FILES ${ENDPOINT_HEADERS})
@@ -465,6 +470,7 @@ if(MSVC)
465470
source_group("Source Files\\net\\windows" FILES ${NET_SOURCE})
466471
source_group("Source Files\\http" FILES ${HTTP_SOURCE})
467472
source_group("Source Files\\http\\standard" FILES ${HTTP_STANDARD_SOURCE})
473+
source_group("Source Files\\http\\interceptor" FILES ${HTTP_INTERCEPTOR_SOURCE})
468474
source_group("Source Files\\config" FILES ${CONFIG_SOURCE})
469475
source_group("Source Files\\config\\defaults" FILES ${CONFIG_DEFAULTS_SOURCE})
470476
source_group("Source Files\\endpoint" FILES ${ENDPOINT_SOURCE})
@@ -679,6 +685,7 @@ install (FILES ${AWS_INTERNAL_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core
679685
install (FILES ${NET_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/net)
680686
install (FILES ${HTTP_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/http)
681687
install (FILES ${HTTP_STANDARD_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/http/standard)
688+
install (FILES ${HTTP_INTERCEPTOR_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/http/interceptor)
682689
install (FILES ${CONFIG_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/config/)
683690
install (FILES ${CONFIG_DEFAULTS_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/config/defaults)
684691
install (FILES ${ENDPOINT_HEADERS} DESTINATION ${INCLUDE_DIRECTORY}/aws/core/endpoint)

src/aws-cpp-sdk-core/include/aws/core/client/ClientConfiguration.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,16 @@ namespace Aws
7878
WHEN_REQUIRED,
7979
};
8080

81+
/**
82+
* Control whether ChunkingInterceptor applies aws-chunked encoding.
83+
* ENABLE: Apply aws-chunked encoding for requests with checksums (default)
84+
* DISABLE: Skip ChunkingInterceptor, rely on signer for chunking
85+
*/
86+
enum class UseAwsChunkedEncoding {
87+
ENABLE,
88+
DISABLE,
89+
};
90+
8191
struct RequestCompressionConfig {
8292
UseRequestCompression useRequestCompression=UseRequestCompression::ENABLE;
8393
size_t requestMinCompressionSizeBytes = 10240;
@@ -493,6 +503,12 @@ namespace Aws
493503
* https://docs.aws.amazon.com/sdkref/latest/guide/feature-account-endpoints.html
494504
*/
495505
Aws::String accountIdEndpointMode = "preferred";
506+
507+
/**
508+
* Control whether ChunkingInterceptor applies aws-chunked encoding.
509+
* Default ENABLE for backward compatibility.
510+
*/
511+
UseAwsChunkedEncoding useAwsChunkedEncoding = UseAwsChunkedEncoding::ENABLE;
496512
/**
497513
* Configuration structure for credential providers in the AWS SDK.
498514
* This structure allows passing configuration options to credential providers
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#pragma once
7+
8+
#include <aws/core/Core_EXPORTS.h>
9+
#include <smithy/interceptor/Interceptor.h>
10+
#include <aws/core/http/HttpRequest.h>
11+
12+
namespace Aws
13+
{
14+
namespace Http
15+
{
16+
/**
17+
* Interceptor that handles aws-chunked encoding for streaming requests.
18+
* Wraps request body with AwsChunkedStream and sets content-encoding headers.
19+
*/
20+
class ChunkingInterceptor : public smithy::interceptor::Interceptor {
21+
public:
22+
explicit ChunkingInterceptor(Aws::Client::UseAwsChunkedEncoding useAwsChunkedEncoding = Aws::Client::UseAwsChunkedEncoding::ENABLE)
23+
: m_useAwsChunkedEncoding(useAwsChunkedEncoding) {}
24+
~ChunkingInterceptor() override = default;
25+
26+
ModifyRequestOutcome ModifyBeforeSigning(smithy::interceptor::InterceptorContext& context) override;
27+
ModifyResponseOutcome ModifyBeforeDeserialization(smithy::interceptor::InterceptorContext& context) override;
28+
29+
private:
30+
bool ShouldApplyAwsChunking(const std::shared_ptr<Aws::Http::HttpRequest>& request) const;
31+
Aws::Client::UseAwsChunkedEncoding m_useAwsChunkedEncoding;
32+
};
33+
34+
} // namespace Http
35+
} // namespace Aws

src/aws-cpp-sdk-core/source/auth/signer/AWSAuthV4Signer.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,14 @@ bool AWSAuthV4Signer::SignRequestWithCreds(Aws::Http::HttpRequest& request, cons
229229
request.DeleteHeader(checksumHeaderValue.c_str());
230230
request.SetHeaderValue(Http::AWS_TRAILER_HEADER, checksumHeaderValue);
231231
request.SetTransferEncoding(CHUNKED_VALUE);
232-
request.HasContentEncoding()
233-
? request.SetContentEncoding(Aws::String{Http::AWS_CHUNKED_VALUE} + "," + request.GetContentEncoding())
234-
: request.SetContentEncoding(Http::AWS_CHUNKED_VALUE);
232+
if (!request.HasContentEncoding()) {
233+
request.SetContentEncoding(Http::AWS_CHUNKED_VALUE);
234+
} else {
235+
Aws::String currentEncoding = request.GetContentEncoding();
236+
if (currentEncoding.find(Http::AWS_CHUNKED_VALUE) == Aws::String::npos) {
237+
request.SetContentEncoding(Aws::String{Http::AWS_CHUNKED_VALUE} + "," + currentEncoding);
238+
}
239+
}
235240

236241
if (request.HasHeader(Http::CONTENT_LENGTH_HEADER)) {
237242
request.SetHeaderValue(Http::DECODED_CONTENT_LENGTH_HEADER, request.GetHeaderValue(Http::CONTENT_LENGTH_HEADER));

src/aws-cpp-sdk-core/source/client/AWSClient.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646

4747
#include <smithy/tracing/TracingUtils.h>
4848
#include <smithy/client/features/ChecksumInterceptor.h>
49+
#include <aws/core/http/interceptor/ChunkingInterceptor.h>
4950

5051
#include <cstring>
5152
#include <cassert>
@@ -139,7 +140,7 @@ AWSClient::AWSClient(const Aws::Client::ClientConfiguration& configuration,
139140
m_enableClockSkewAdjustment(configuration.enableClockSkewAdjustment),
140141
m_requestCompressionConfig(configuration.requestCompressionConfig),
141142
m_userAgentInterceptor{Aws::MakeShared<smithy::client::UserAgentInterceptor>(AWS_CLIENT_LOG_TAG, configuration, m_retryStrategy->GetStrategyName(), m_serviceName)},
142-
m_interceptors{Aws::MakeShared<smithy::client::ChecksumInterceptor>(AWS_CLIENT_LOG_TAG), m_userAgentInterceptor}
143+
m_interceptors{Aws::MakeShared<smithy::client::ChecksumInterceptor>(AWS_CLIENT_LOG_TAG), Aws::MakeShared<Aws::Http::ChunkingInterceptor>(AWS_CLIENT_LOG_TAG), m_userAgentInterceptor}
143144
{
144145
}
145146

@@ -165,7 +166,7 @@ AWSClient::AWSClient(const Aws::Client::ClientConfiguration& configuration,
165166
m_enableClockSkewAdjustment(configuration.enableClockSkewAdjustment),
166167
m_requestCompressionConfig(configuration.requestCompressionConfig),
167168
m_userAgentInterceptor{Aws::MakeShared<smithy::client::UserAgentInterceptor>(AWS_CLIENT_LOG_TAG, configuration, m_retryStrategy->GetStrategyName(), m_serviceName)},
168-
m_interceptors{Aws::MakeShared<smithy::client::ChecksumInterceptor>(AWS_CLIENT_LOG_TAG, configuration), m_userAgentInterceptor}
169+
m_interceptors{Aws::MakeShared<smithy::client::ChecksumInterceptor>(AWS_CLIENT_LOG_TAG, configuration), Aws::MakeShared<Aws::Http::ChunkingInterceptor>(AWS_CLIENT_LOG_TAG), m_userAgentInterceptor}
169170
{
170171
}
171172

src/aws-cpp-sdk-core/source/client/UserAgent.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,15 @@ Aws::String UserAgent::SerializeWithFeatures(const Aws::Set<UserAgentFeature>& f
182182
SerializeMetadata(METADATA, m_compilerMetadata);
183183
}
184184

185+
// Add HTTP client metadata
186+
#if AWS_SDK_USE_CRT_HTTP
187+
SerializeMetadata(METADATA, "http#crt");
188+
#elif ENABLE_CURL_CLIENT
189+
SerializeMetadata(METADATA, "http#curl");
190+
#elif ENABLE_WINDOWS_CLIENT
191+
SerializeMetadata(METADATA, "http#winhttp");
192+
#endif
193+
185194
// metrics
186195
Aws::Vector<Aws::String> encodedMetrics{};
187196

src/aws-cpp-sdk-core/source/http/crt/CRTHttpClient.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#include <aws/core/utils/crypto/Hash.h>
1010
#include <aws/core/utils/logging/LogMacros.h>
1111
#include <aws/core/utils/ratelimiter/RateLimiterInterface.h>
12-
#include <aws/core/utils/stream/AwsChunkedStream.h>
1312
#include <aws/crt/http/HttpConnectionManager.h>
1413
#include <aws/crt/http/HttpRequestResponse.h>
1514

@@ -379,11 +378,7 @@ namespace Aws
379378
if (request->GetContentBody())
380379
{
381380
bool isStreaming = request->IsEventStreamRequest();
382-
if (request->HasHeader(Aws::Http::CONTENT_ENCODING_HEADER) && request->GetHeaderValue(Aws::Http::CONTENT_ENCODING_HEADER) == Aws::Http::AWS_CHUNKED_VALUE) {
383-
crtRequest->SetBody(Aws::MakeShared<Aws::Utils::Stream::AwsChunkedStream<>>(CRT_HTTP_CLIENT_TAG, request.get(), request->GetContentBody()));
384-
} else {
385-
crtRequest->SetBody(Aws::MakeShared<SDKAdaptingInputStream>(CRT_HTTP_CLIENT_TAG, m_configuration.writeRateLimiter, request->GetContentBody(), *this, *request, isStreaming));
386-
}
381+
crtRequest->SetBody(Aws::MakeShared<SDKAdaptingInputStream>(CRT_HTTP_CLIENT_TAG, m_configuration.writeRateLimiter, request->GetContentBody(), *this, *request, isStreaming));
387382
}
388383

389384
Crt::Http::HttpRequestOptions requestOptions;

src/aws-cpp-sdk-core/source/http/curl/CurlHttpClient.cpp

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
#include <aws/core/utils/crypto/Hash.h>
1515
#include <aws/core/utils/logging/LogMacros.h>
1616
#include <aws/core/utils/ratelimiter/RateLimiterInterface.h>
17-
#include <aws/core/utils/stream/AwsChunkedStream.h>
1817
#include <aws/core/utils/stream/ConcurrentStreamBuf.h>
1918

2019
#include <algorithm>
@@ -155,21 +154,16 @@ static const char* CURL_HTTP_CLIENT_TAG = "CurlHttpClient";
155154
struct CurlReadCallbackContext
156155
{
157156
CurlReadCallbackContext(const CurlHttpClient* client, CURL* curlHandle, HttpRequest* request,
158-
Aws::Utils::RateLimits::RateLimiterInterface* limiter,
159-
std::shared_ptr<AwsChunkedStream<>> chunkedStream = nullptr)
157+
Aws::Utils::RateLimits::RateLimiterInterface* limiter)
160158
: m_client(client),
161159
m_curlHandle(curlHandle),
162160
m_rateLimiter(limiter),
163-
m_request(request),
164-
m_chunkEnd(false),
165-
m_chunkedStream{std::move(chunkedStream)} {}
161+
m_request(request) {}
166162

167163
const CurlHttpClient* m_client;
168164
CURL* m_curlHandle;
169165
Aws::Utils::RateLimits::RateLimiterInterface* m_rateLimiter;
170166
HttpRequest* m_request;
171-
bool m_chunkEnd;
172-
std::shared_ptr<Stream::AwsChunkedStream<>> m_chunkedStream;
173167
};
174168

175169
static int64_t GetContentLengthFromHeader(CURL* connectionHandle,
@@ -315,8 +309,6 @@ static size_t ReadBody(char* ptr, size_t size, size_t nmemb, void* userdata, boo
315309
const std::shared_ptr<Aws::IOStream>& ioStream = request->GetContentBody();
316310

317311
size_t amountToRead = size * nmemb;
318-
bool isAwsChunked = request->HasHeader(Aws::Http::CONTENT_ENCODING_HEADER) &&
319-
request->GetHeaderValue(Aws::Http::CONTENT_ENCODING_HEADER).find(Aws::Http::AWS_CHUNKED_VALUE) != Aws::String::npos;
320312

321313
if (ioStream != nullptr && amountToRead > 0)
322314
{
@@ -334,8 +326,6 @@ static size_t ReadBody(char* ptr, size_t size, size_t nmemb, void* userdata, boo
334326
return 0;
335327
}
336328
amountRead = (size_t)ioStream->readsome(ptr, amountToRead);
337-
} else if (isAwsChunked && context->m_chunkedStream != nullptr) {
338-
amountRead = context->m_chunkedStream->BufferedRead(ptr, amountToRead);
339329
} else {
340330
ioStream->read(ptr, amountToRead);
341331
amountRead = static_cast<size_t>(ioStream->gcount());
@@ -380,13 +370,6 @@ static size_t SeekBody(void* userdata, curl_off_t offset, int origin)
380370
return CURL_SEEKFUNC_FAIL;
381371
}
382372

383-
// fail seek for aws-chunk encoded body as the length and offset is unknown
384-
if (context->m_request &&
385-
context->m_request->HasHeader(Aws::Http::CONTENT_ENCODING_HEADER) &&
386-
context->m_request->GetHeaderValue(Aws::Http::CONTENT_ENCODING_HEADER).find(Aws::Http::AWS_CHUNKED_VALUE) != Aws::String::npos)
387-
{
388-
return CURL_SEEKFUNC_FAIL;
389-
}
390373

391374
HttpRequest* request = context->m_request;
392375
const std::shared_ptr<Aws::IOStream>& ioStream = request->GetContentBody();
@@ -713,13 +696,7 @@ std::shared_ptr<HttpResponse> CurlHttpClient::MakeRequest(const std::shared_ptr<
713696

714697
CurlWriteCallbackContext writeContext(this, connectionHandle ,request.get(), response.get(), readLimiter);
715698

716-
const auto readContext = [this, &connectionHandle, &request, &writeLimiter]() -> CurlReadCallbackContext {
717-
if (request->GetContentBody() != nullptr) {
718-
auto chunkedBodyPtr = Aws::MakeShared<AwsChunkedStream<>>(CURL_HTTP_CLIENT_TAG, request.get(), request->GetContentBody());
719-
return {this, connectionHandle, request.get(), writeLimiter, std::move(chunkedBodyPtr)};
720-
}
721-
return {this, connectionHandle, request.get(), writeLimiter};
722-
}();
699+
CurlReadCallbackContext readContext(this, connectionHandle, request.get(), writeLimiter);
723700

724701
SetOptCodeForHttpMethod(connectionHandle, request);
725702

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
/**
2+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
* SPDX-License-Identifier: Apache-2.0.
4+
*/
5+
6+
#include <aws/core/http/interceptor/ChunkingInterceptor.h>
7+
#include <aws/core/utils/stream/AwsChunkedStream.h>
8+
#include <smithy/client/common/AwsSmithyClientUtils.h>
9+
10+
namespace Aws {
11+
namespace Http {
12+
13+
class AwsChunkedIOStream : public Aws::IOStream {
14+
public:
15+
AwsChunkedIOStream(const std::shared_ptr<Aws::IOStream>& originalBody, Aws::Http::HttpRequest* request)
16+
: Aws::IOStream(&m_streambuf), m_chunkStream(request, originalBody) {}
17+
18+
private:
19+
class ChunkedStreamBuf : public std::streambuf {
20+
public:
21+
ChunkedStreamBuf(Aws::Utils::Stream::AwsChunkedStream<>& chunkStream) : m_chunkStream(chunkStream) {}
22+
23+
protected:
24+
int_type underflow() override {
25+
if (gptr() < egptr()) {
26+
return traits_type::to_int_type(*gptr());
27+
}
28+
29+
size_t bytesRead = m_chunkStream.BufferedRead(m_buffer, sizeof(m_buffer));
30+
if (bytesRead == 0) {
31+
return traits_type::eof();
32+
}
33+
34+
setg(m_buffer, m_buffer, m_buffer + bytesRead);
35+
return traits_type::to_int_type(*gptr());
36+
}
37+
38+
std::streamsize showmanyc() override {
39+
return egptr() - gptr();
40+
}
41+
42+
private:
43+
Aws::Utils::Stream::AwsChunkedStream<>& m_chunkStream;
44+
char m_buffer[8192];
45+
};
46+
47+
Aws::Utils::Stream::AwsChunkedStream<> m_chunkStream;
48+
ChunkedStreamBuf m_streambuf{m_chunkStream};
49+
};
50+
51+
ChunkingInterceptor::ModifyRequestOutcome ChunkingInterceptor::ModifyBeforeSigning(
52+
smithy::interceptor::InterceptorContext& context) {
53+
auto request = context.GetTransmitRequest();
54+
55+
if (m_useAwsChunkedEncoding == Aws::Client::UseAwsChunkedEncoding::DISABLE) {
56+
return request;
57+
}
58+
59+
if (!ShouldApplyAwsChunking(request)) {
60+
return request;
61+
}
62+
63+
auto originalBody = request->GetContentBody();
64+
if (!originalBody) {
65+
return request;
66+
}
67+
68+
auto chunkedBody = Aws::MakeShared<AwsChunkedIOStream>(
69+
"ChunkingInterceptor", originalBody, request.get());
70+
71+
request->AddContentBody(chunkedBody);
72+
73+
// Set Transfer-Encoding: chunked for aws-chunked requests (only if not already set)
74+
if (!request->HasTransferEncoding()) {
75+
request->SetTransferEncoding("chunked");
76+
}
77+
78+
// Move Content-Length to x-amz-decoded-content-length and remove Content-Length
79+
if (request->HasHeader("Content-Length")) {
80+
auto contentLength = request->GetHeaderValue("Content-Length");
81+
request->SetHeaderValue("x-amz-decoded-content-length", contentLength);
82+
request->DeleteHeader("Content-Length");
83+
}
84+
85+
smithy::client::Utils::AppendHeaderValueToRequest(request, CONTENT_ENCODING_HEADER, AWS_CHUNKED_VALUE);
86+
87+
return request;
88+
}
89+
90+
ChunkingInterceptor::ModifyResponseOutcome ChunkingInterceptor::ModifyBeforeDeserialization(
91+
smithy::interceptor::InterceptorContext& context) {
92+
return context.GetTransmitResponse();
93+
}
94+
95+
bool ChunkingInterceptor::ShouldApplyAwsChunking(const std::shared_ptr<Aws::Http::HttpRequest>& request) const {
96+
if (!request || !request->GetContentBody()) {
97+
return false;
98+
}
99+
const auto& hashPair = request->GetRequestHash();
100+
return hashPair.second != nullptr;
101+
}
102+
103+
} // namespace Http
104+
} // namespace Aws

0 commit comments

Comments
 (0)