diff --git a/Release/src/http/client/http_client_asio.cpp b/Release/src/http/client/http_client_asio.cpp index 6a6786dcf5..2183c9c389 100644 --- a/Release/src/http/client/http_client_asio.cpp +++ b/Release/src/http/client/http_client_asio.cpp @@ -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();