aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard
diff options
context:
space:
mode:
authorDevtools Arcadia <arcadia-devtools@yandex-team.ru>2022-02-07 18:08:42 +0300
committerDevtools Arcadia <arcadia-devtools@mous.vla.yp-c.yandex.net>2022-02-07 18:08:42 +0300
commit1110808a9d39d4b808aef724c861a2e1a38d2a69 (patch)
treee26c9fed0de5d9873cce7e00bc214573dc2195b7 /contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard
downloadydb-1110808a9d39d4b808aef724c861a2e1a38d2a69.tar.gz
intermediate changes
ref:cde9a383711a11544ce7e107a78147fb96cc4029
Diffstat (limited to 'contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard')
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard/StandardHttpRequest.cpp104
-rw-r--r--contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard/StandardHttpResponse.cpp46
2 files changed, 150 insertions, 0 deletions
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard/StandardHttpRequest.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard/StandardHttpRequest.cpp
new file mode 100644
index 0000000000..47a0ee4fac
--- /dev/null
+++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard/StandardHttpRequest.cpp
@@ -0,0 +1,104 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include <aws/core/http/standard/StandardHttpRequest.h>
+
+#include <aws/core/utils/StringUtils.h>
+
+#include <iostream>
+#include <algorithm>
+#include <cassert>
+
+using namespace Aws::Http;
+using namespace Aws::Http::Standard;
+using namespace Aws::Utils;
+
+static bool IsDefaultPort(const URI& uri)
+{
+ switch(uri.GetPort())
+ {
+ case 80:
+ return uri.GetScheme() == Scheme::HTTP;
+ case 443:
+ return uri.GetScheme() == Scheme::HTTPS;
+ default:
+ return false;
+ }
+}
+
+StandardHttpRequest::StandardHttpRequest(const URI& uri, HttpMethod method) :
+ HttpRequest(uri, method),
+ bodyStream(nullptr),
+ m_responseStreamFactory()
+{
+ if(IsDefaultPort(uri))
+ {
+ StandardHttpRequest::SetHeaderValue(HOST_HEADER, uri.GetAuthority());
+ }
+ else
+ {
+ Aws::StringStream host;
+ host << uri.GetAuthority() << ":" << uri.GetPort();
+ StandardHttpRequest::SetHeaderValue(HOST_HEADER, host.str());
+ }
+}
+
+HeaderValueCollection StandardHttpRequest::GetHeaders() const
+{
+ HeaderValueCollection headers;
+
+ for (HeaderValueCollection::const_iterator iter = headerMap.begin(); iter != headerMap.end(); ++iter)
+ {
+ headers.emplace(HeaderValuePair(iter->first, iter->second));
+ }
+
+ return headers;
+}
+
+const Aws::String& StandardHttpRequest::GetHeaderValue(const char* headerName) const
+{
+ auto iter = headerMap.find(headerName);
+ assert (iter != headerMap.end());
+ return iter->second;
+}
+
+void StandardHttpRequest::SetHeaderValue(const char* headerName, const Aws::String& headerValue)
+{
+ headerMap[StringUtils::ToLower(headerName)] = StringUtils::Trim(headerValue.c_str());
+}
+
+void StandardHttpRequest::SetHeaderValue(const Aws::String& headerName, const Aws::String& headerValue)
+{
+ headerMap[StringUtils::ToLower(headerName.c_str())] = StringUtils::Trim(headerValue.c_str());
+}
+
+void StandardHttpRequest::DeleteHeader(const char* headerName)
+{
+ headerMap.erase(StringUtils::ToLower(headerName));
+}
+
+bool StandardHttpRequest::HasHeader(const char* headerName) const
+{
+ return headerMap.find(StringUtils::ToLower(headerName)) != headerMap.end();
+}
+
+int64_t StandardHttpRequest::GetSize() const
+{
+ int64_t size = 0;
+
+ std::for_each(headerMap.cbegin(), headerMap.cend(), [&](const HeaderValueCollection::value_type& kvPair){ size += kvPair.first.length(); size += kvPair.second.length(); });
+
+ return size;
+}
+
+const Aws::IOStreamFactory& StandardHttpRequest::GetResponseStreamFactory() const
+{
+ return m_responseStreamFactory;
+}
+
+void StandardHttpRequest::SetResponseStreamFactory(const Aws::IOStreamFactory& factory)
+{
+ m_responseStreamFactory = factory;
+}
diff --git a/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard/StandardHttpResponse.cpp b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard/StandardHttpResponse.cpp
new file mode 100644
index 0000000000..92d7a062b6
--- /dev/null
+++ b/contrib/libs/aws-sdk-cpp/aws-cpp-sdk-core/source/http/standard/StandardHttpResponse.cpp
@@ -0,0 +1,46 @@
+/**
+ * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
+ * SPDX-License-Identifier: Apache-2.0.
+ */
+
+#include <aws/core/http/standard/StandardHttpResponse.h>
+
+#include <aws/core/utils/StringUtils.h>
+#include <aws/core/utils/memory/AWSMemory.h>
+
+#include <istream>
+
+using namespace Aws::Http;
+using namespace Aws::Http::Standard;
+using namespace Aws::Utils;
+
+
+HeaderValueCollection StandardHttpResponse::GetHeaders() const
+{
+ HeaderValueCollection headerValueCollection;
+
+ for (Aws::Map<Aws::String, Aws::String>::const_iterator iter = headerMap.begin(); iter != headerMap.end(); ++iter)
+ {
+ headerValueCollection.emplace(HeaderValuePair(iter->first, iter->second));
+ }
+
+ return headerValueCollection;
+}
+
+bool StandardHttpResponse::HasHeader(const char* headerName) const
+{
+ return headerMap.find(StringUtils::ToLower(headerName)) != headerMap.end();
+}
+
+const Aws::String& StandardHttpResponse::GetHeader(const Aws::String& headerName) const
+{
+ Aws::Map<Aws::String, Aws::String>::const_iterator foundValue = headerMap.find(StringUtils::ToLower(headerName.c_str()));
+ return foundValue->second;
+}
+
+void StandardHttpResponse::AddHeader(const Aws::String& headerName, const Aws::String& headerValue)
+{
+ headerMap[StringUtils::ToLower(headerName.c_str())] = headerValue;
+}
+
+