Skip to content
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
30 changes: 20 additions & 10 deletions sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,17 +622,27 @@ std::unique_ptr<RawResponse> WinHttpTransport::SendRequestAndGetResponse(
std::string reasonPhrase;
DWORD sizeOfReasonPhrase = sizeOfHeaders;

if (WinHttpQueryHeaders(
handleManager->m_requestHandle,
WINHTTP_QUERY_STATUS_TEXT,
WINHTTP_HEADER_NAME_BY_INDEX,
outputBuffer.data(),
&sizeOfReasonPhrase,
WINHTTP_NO_HEADER_INDEX))
// HTTP/2 does not support reason phrase, refer to
// https://www.rfc-editor.org/rfc/rfc7540#section-8.1.2.4.
if (majorVersion == 1)
{
start = outputBuffer.begin();
reasonPhrase
= WideStringToString(std::wstring(start, start + sizeOfReasonPhrase / sizeof(WCHAR)));
if (WinHttpQueryHeaders(
handleManager->m_requestHandle,
WINHTTP_QUERY_STATUS_TEXT,
WINHTTP_HEADER_NAME_BY_INDEX,
outputBuffer.data(),
&sizeOfReasonPhrase,
WINHTTP_NO_HEADER_INDEX))
{
// even with HTTP/1.1, we cannot assume that reason phrase is set since it is optional
// according to https://www.rfc-editor.org/rfc/rfc2616.html#section-6.1.1.
if (sizeOfReasonPhrase > 0)
{
start = outputBuffer.begin();
reasonPhrase
= WideStringToString(std::wstring(start, start + sizeOfReasonPhrase / sizeof(WCHAR)));
}
}
}

// Allocate the instance of the response on the heap with a shared ptr so this memory gets
Expand Down