Skip to content

Prevent infinite loop during proxy authentication #986

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

Merged
merged 3 commits into from
Dec 4, 2018
Merged
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
32 changes: 18 additions & 14 deletions Release/src/http/client/http_client_winhttp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1723,23 +1723,27 @@ class winhttp_client final : public _http_client_communicator
}
}

static utility::string_t get_request_url(HINTERNET hRequestHandle)
static std::wstring get_request_url(HINTERNET hRequestHandle)
{
DWORD urlSize{ 0 };
if(FALSE == WinHttpQueryOption(hRequestHandle, WINHTTP_OPTION_URL, nullptr, &urlSize) || urlSize == 0)
std::wstring url;
auto urlSize = static_cast<unsigned long>(url.capacity()) * 2; // use initial small string optimization capacity
for (;;)
{
return U("");
}

auto urlwchar = new WCHAR[urlSize / sizeof(WCHAR)];

WinHttpQueryOption(hRequestHandle, WINHTTP_OPTION_URL, (void*)urlwchar, &urlSize);

utility::string_t url(urlwchar);

delete[] urlwchar;
url.resize(urlSize / sizeof(wchar_t));
if (WinHttpQueryOption(hRequestHandle, WINHTTP_OPTION_URL, &url[0], &urlSize))
{
url.resize(wcslen(url.c_str()));
return url;
}

return url;
const auto lastError = GetLastError();
if (lastError != ERROR_INSUFFICIENT_BUFFER || urlSize == 0)
{
url.clear();
url.shrink_to_fit();
return url;
}
}
}

// Returns true if we handle successfully and resending the request
Expand Down