diff --git a/eng/pipelines/templates/stages/platform-matrix.json b/eng/pipelines/templates/stages/platform-matrix.json index 143149325..18f4db991 100644 --- a/eng/pipelines/templates/stages/platform-matrix.json +++ b/eng/pipelines/templates/stages/platform-matrix.json @@ -85,8 +85,13 @@ } }, "TargetPlatform": { - "Win32Api_debug_tests": { - "CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON -DBUILD_TRANSPORT_WINHTTP=ON -DMSVC_USE_STATIC_CRT=ON", + "Win32Api_debug_tests_curl": { + "CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DBUILD_TRANSPORT_CURL=ON -DMSVC_USE_STATIC_CRT=ON", + "BuildArgs": "--parallel 8 --config Debug", + "PublishMapFiles": "true" + }, + "Win32Api_debug_tests_winhttp": { + "CmakeArgs": " -DBUILD_TESTING=ON -DBUILD_PERFORMANCE_TESTS=ON -DRUN_LONG_UNIT_TESTS=ON -DMSVC_USE_STATIC_CRT=ON", "BuildArgs": "--parallel 8 --config Debug", "PublishMapFiles": "true" } diff --git a/sdk/core/azure-core/inc/azure/core/http/http.hpp b/sdk/core/azure-core/inc/azure/core/http/http.hpp index 0638a3f21..2f01b05df 100644 --- a/sdk/core/azure-core/inc/azure/core/http/http.hpp +++ b/sdk/core/azure-core/inc/azure/core/http/http.hpp @@ -311,6 +311,12 @@ namespace Azure { namespace Core { namespace Http { */ Azure::Core::IO::BodyStream* GetBodyStream() { return this->m_bodyStream; } + /** + * @brief Get HTTP body as #Azure::Core::IO::BodyStream. + * + */ + Azure::Core::IO::BodyStream const* GetBodyStream() const { return this->m_bodyStream; } + /** * @brief A value indicating whether the returned raw response for this request will be buffered * within a memory buffer or if it will be returned as a body stream instead. diff --git a/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp b/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp index 199d741f8..d1d92ab09 100644 --- a/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp +++ b/sdk/core/azure-core/src/http/winhttp/win_http_transport.cpp @@ -202,13 +202,32 @@ std::string GetHeadersAsString(Azure::Core::Http::Request const& request) { std::string requestHeaderString; - for (auto const& header : request.GetHeaders()) + // request.GetHeaders() aggregates the pre- and post-retry headers into a single map. Capture it + // so we don't recalculate the merge multiple times. + auto requestHeaders = request.GetHeaders(); + + for (auto const& header : requestHeaders) { requestHeaderString += header.first; // string (key) requestHeaderString += ": "; requestHeaderString += header.second; // string's value requestHeaderString += "\r\n"; } + + // The test recording infrastructure requires that a Patch verb have a Content-Length header, + // because it does not distinguish between requests with and without a body if there's no + // Content-Length header. + if (request.GetMethod() == HttpMethod::Patch) + { + if (requestHeaders.find("Content-Length") == requestHeaders.end()) + { + if (request.GetBodyStream() == nullptr || request.GetBodyStream()->Length() == 0) + { + requestHeaderString += "Content-Length: 0\r\n"; + } + } + } + requestHeaderString += "\r\n"; return requestHeaderString;