void WinHttpSyncHttpClient::DoAddHeaders(void* hHttpRequest, Aws::String& headerStr) const { Aws::WString wHeaderString = StringUtils::ToWString(headerStr.c_str()); WinHttpAddRequestHeaders(hHttpRequest, wHeaderString.c_str(), (DWORD)wHeaderString.length(), WINHTTP_ADDREQ_FLAG_REPLACE | WINHTTP_ADDREQ_FLAG_ADD); }
void WinHttpSyncHttpClient::DoAddHeaders(void* hHttpRequest, Aws::String& headerStr) const { Aws::WString wHeaderString = StringUtils::ToWString(headerStr.c_str()); if (!WinHttpAddRequestHeaders(hHttpRequest, wHeaderString.c_str(), (DWORD)wHeaderString.length(), WINHTTP_ADDREQ_FLAG_REPLACE | WINHTTP_ADDREQ_FLAG_ADD)) AWS_LOGSTREAM_ERROR(GetLogTag(), "Failed to add HTTP request headers with error code: " << GetLastError()); }
TEST(StringUtilsTest, TestStringNonAsciiToWString) { AWS_BEGIN_MEMORY_TEST(16, 10) Aws::String startString; const char startVal = 115; const char incrementVal = 10; const char loopCount = 10; for (char i = 0; i < loopCount; ++i) { startString.push_back(static_cast<char>(startVal + incrementVal * i)); } Aws::WString outString = StringUtils::ToWString(startString.c_str()); ASSERT_EQ(outString.length(), loopCount); AWS_END_MEMORY_TEST }