Skip to content

Commit

Permalink
Avoid setting Cache-Control on WinHttp client; fix setting empty head…
Browse files Browse the repository at this point in the history
…ers on WinHttp
  • Loading branch information
Sergey Ryabinin committed Jun 11, 2024
1 parent 34d9178 commit dcc8377
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -538,8 +538,11 @@ void* WinHttpSyncHttpClient::OpenRequest(const std::shared_ptr<HttpRequest>& req
{
LPCWSTR accept[2] = { nullptr, nullptr };

DWORD requestFlags = WINHTTP_FLAG_REFRESH |
(request->GetUri().GetScheme() == Scheme::HTTPS && m_verifySSL ? WINHTTP_FLAG_SECURE : 0);
DWORD requestFlags = request->GetUri().GetScheme() == Scheme::HTTPS && m_verifySSL ? WINHTTP_FLAG_SECURE : 0;
if (m_usingProxy) {
// Avoid force adding "Cache-Control: no-cache" header.
requestFlags |= WINHTTP_FLAG_REFRESH;
}

Aws::WString acceptHeader(L"*/*");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ void WinSyncHttpClient::AddHeadersToRequest(const std::shared_ptr<HttpRequest>&
}
else
{
// WinHttp does not accept empty header key or value
AWS_LOGSTREAM_DEBUG(GetLogTag(), "Empty header is ignored: " << header.first << ": " << header.second);
// DOUBLE SPACE after COLON, thanks, WinHTTP!
ss << header.first << ": " << "\r\n";
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,7 @@ namespace
GetObjectOutcome getObjectOutcome = Client->GetObject(getObjectRequest);
AWS_ASSERT_SUCCESS(getObjectOutcome);
ASSERT_EQ(contentLength, getObjectOutcome.GetResult().GetContentLength());
EXPECT_TRUE(getObjectOutcome.GetResult().GetCacheControl().empty());

// GET with range
getObjectRequest.SetRange("bytes=128-1024");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,7 @@ namespace
ss.str("");
ss << getObjectOutcome.GetResult().GetBody().rdbuf();
ASSERT_STREQ("Test Object", ss.str().c_str());
EXPECT_TRUE(getObjectOutcome.GetResult().GetCacheControl().empty());

HeadObjectRequest headObjectRequest;
headObjectRequest.SetBucket(fullBucketName);
Expand Down

0 comments on commit dcc8377

Please sign in to comment.