9#include <aws/core/http/HttpRequest.h>
13#include <aws/core/http/HttpClient.h>
14#include <aws/core/utils/HashingUtils.h>
15#include <aws/core/utils/crypto/MD5.h>
16#include <aws/core/utils/logging/LogMacros.h>
39 assert(!header.empty());
41 if (!httpRequest->HasHeader(header.c_str()))
43 httpRequest->SetHeaderValue(header, value);
47 Aws::String contentEncoding = httpRequest->GetHeaderValue(header.c_str());
48 contentEncoding.append(
",").append(value);
49 httpRequest->SetHeaderValue(header, contentEncoding);
54 const std::shared_ptr<Aws::IOStream>& body,
55 const std::shared_ptr<Aws::Http::HttpClient>& httpClient,
61 httpRequest->AddContentBody(body);
70 if (httpRequest->GetMethod() == HttpMethod::HTTP_POST || httpRequest->GetMethod() ==
91 if (!httpClient->SupportsChunkedTransferEncoding())
94 "This http client doesn't support transfer-encoding:chunked. " <<
95 "The request may fail if it's not a seekable stream.");
98 "Found body, but content-length has not been set, attempting to compute content-length");
99 body->seekg(0, body->end);
100 auto streamSize = body->tellg();
101 body->seekg(0, body->beg);
104 httpRequest->SetContentLength(ss.str());
110 ", attempting to compute content-md5");
120 auto md5HashResult = hash.
Calculate(*body);
122 if (md5HashResult.IsSuccess())
133 if (response->HasClientError())
136 static const int SUCCESS_RESPONSE_MIN = 200;
137 static const int SUCCESS_RESPONSE_MAX = 299;
139 const int responseCode =
static_cast<int>(response->GetResponseCode());
140 return responseCode < SUCCESS_RESPONSE_MIN || responseCode > SUCCESS_RESPONSE_MAX;
148 if (awsDateHeaderIter != headers.end())
150 return DateTime(awsDateHeaderIter->second.c_str(), DateFormat::AutoDetect);
152 else if (dateHeaderIter != headers.end())
154 return DateTime(dateHeaderIter->second.c_str(), DateFormat::AutoDetect);
const Aws::Http::HeaderValueCollection & GetResponseHeaders() const
virtual HashResult Calculate(const Aws::String &str) override
static Aws::String Base64Encode(const ByteBuffer &byteBuffer)
static Aws::String ToLower(const char *source)
static Aws::Utils::DateTime GetServerTimeFromError(const ClientError &error)
static void AppendHeaderValueToRequest(const std::shared_ptr< Aws::Http::HttpRequest > &httpRequest, const Aws::String &header, const Aws::String &value)
static bool DoesResponseGenerateError(const std::shared_ptr< Aws::Http::HttpResponse > &response)
Aws::Utils::DateTime DateTime
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::Http::HeaderValueCollection HeaderValueCollection
AWS_CORE_API const char CHUNKED_VALUE[]
AWS_CORE_API const char CONTENT_LENGTH_HEADER[]
AWS_CORE_API const char DATE_HEADER[]
AWS_CORE_API const char CONTENT_MD5_HEADER[]
AWS_CORE_API const char AWS_DATE_HEADER[]
Aws::Map< Aws::String, Aws::String > HeaderValueCollection
std::basic_stringstream< char, std::char_traits< char >, Aws::Allocator< char > > StringStream
std::basic_string< char, std::char_traits< char >, Aws::Allocator< char > > String
static const char AWS_SMITHY_CLIENT_UTILS_TAG[]