Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid setting Cache-Control on WinHttp client; fix setting empty headers #2998

Merged
merged 1 commit into from
Jun 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've tried to remove this header without changing this option in the SDK (to preserve other WinHTTP request behavior on this option enabled). However, WinHTTP refused to remove it.

// 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
Loading