Skip to content

Avoid spurious errors when handling HTTP responses without body #498

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 1 commit into from
Jul 9, 2017
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
10 changes: 9 additions & 1 deletion Release/src/http/client/http_client_asio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,9 +1229,17 @@ class asio_context : public request_context, public std::enable_shared_from_this
}
}

// Check for HEAD requests and status codes which cannot contain a
// message body in HTTP/1.1 (see 3.3.3/1 of the RFC 7230).
//
// note: need to check for 'chunked' here as well, azure storage sends both
// transfer-encoding:chunked and content-length:0 (although HTTP says not to)
if (m_request.method() == U("HEAD") || (!needChunked && m_content_length == 0))
const auto status = m_response.status_code();
if (m_request.method() == U("HEAD")
|| (status >= 100 && status < 200)
|| status == status_codes::NoContent
|| status == status_codes::NotModified
|| (!needChunked && m_content_length == 0))
{
// we can stop early - no body
const auto &progress = m_request._get_impl()->_progress_handler();
Expand Down