Rename IsBufferedDownload to ShouldBufferResponse to avoid using a (#2210)
storage specific verb in general purpose Request object.
This commit is contained in:
parent
23136690af
commit
a103e51869
@ -9,7 +9,7 @@
|
||||
### Breaking Changes
|
||||
|
||||
- Removed `Context::GetApplicationContext()` in favor of a new static data member `Context::ApplicationContext`.
|
||||
- Renamed `Request::IsDownloadViaStream()` to `IsBufferedDownload()`.
|
||||
- Renamed `Request::IsDownloadViaStream()` to `ShouldBufferResponse()`.
|
||||
- Removed the `Azure::Core::Http::Request` ctor overload that takes both a `bodyStream` and a `bufferedDownload` boolean since it is not useful.
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
@ -148,7 +148,7 @@ namespace Azure { namespace Core { namespace Http {
|
||||
|
||||
// flag to know where to insert header
|
||||
bool m_retryModeEnabled{false};
|
||||
bool m_isBufferedDownload{true};
|
||||
bool m_shouldBufferResponse{true};
|
||||
|
||||
// Expected to be called by a Retry policy to reset all headers set after this function was
|
||||
// previously called
|
||||
@ -160,16 +160,16 @@ namespace Azure { namespace Core { namespace Http {
|
||||
* @param httpMethod HTTP method.
|
||||
* @param url URL.
|
||||
* @param bodyStream #Azure::Core::IO::BodyStream.
|
||||
* @param bufferedDownload A boolean value indicating whether download should use a buffer
|
||||
* for the response or return a body stream instead.
|
||||
* @param shouldBufferResponse A boolean value indicating whether the returned response should
|
||||
* be buffered or returned as a body stream instead.
|
||||
*/
|
||||
explicit Request(
|
||||
HttpMethod httpMethod,
|
||||
Url url,
|
||||
Azure::Core::IO::BodyStream* bodyStream,
|
||||
bool bufferedDownload)
|
||||
bool shouldBufferResponse)
|
||||
: m_method(std::move(httpMethod)), m_url(std::move(url)), m_bodyStream(bodyStream),
|
||||
m_retryModeEnabled(false), m_isBufferedDownload(bufferedDownload)
|
||||
m_retryModeEnabled(false), m_shouldBufferResponse(shouldBufferResponse)
|
||||
{
|
||||
}
|
||||
|
||||
@ -191,10 +191,10 @@ namespace Azure { namespace Core { namespace Http {
|
||||
*
|
||||
* @param httpMethod HTTP method.
|
||||
* @param url URL.
|
||||
* @param bufferedDownload A boolean value indicating whether download should use a buffer
|
||||
* for the response or return a body stream instead.
|
||||
* @param shouldBufferResponse A boolean value indicating whether the returned response should
|
||||
* be buffered or returned as a body stream instead.
|
||||
*/
|
||||
explicit Request(HttpMethod httpMethod, Url url, bool bufferedDownload);
|
||||
explicit Request(HttpMethod httpMethod, Url url, bool shouldBufferResponse);
|
||||
|
||||
/**
|
||||
* @brief Construct an #Azure::Core::Http::Request.
|
||||
@ -241,10 +241,10 @@ namespace Azure { namespace Core { namespace Http {
|
||||
Azure::Core::IO::BodyStream* GetBodyStream() { return this->m_bodyStream; }
|
||||
|
||||
/**
|
||||
* @brief A value indicating whether download will return the raw response within a memory
|
||||
* buffer or if it will provide a body stream instead.
|
||||
* @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.
|
||||
*/
|
||||
bool IsBufferedDownload() { return this->m_isBufferedDownload; }
|
||||
bool ShouldBufferResponse() { return this->m_shouldBufferResponse; }
|
||||
|
||||
/**
|
||||
* @brief Get URL.
|
||||
|
||||
@ -176,8 +176,8 @@ void Azure::Core::Http::_detail::RawResponseHelpers::InsertHeaderWithValidation(
|
||||
headers[headerName] = headerValue;
|
||||
}
|
||||
|
||||
Request::Request(HttpMethod httpMethod, Url url, bool bufferedDownload)
|
||||
: Request(httpMethod, std::move(url), NullBodyStream::GetNullBodyStream(), bufferedDownload)
|
||||
Request::Request(HttpMethod httpMethod, Url url, bool shouldBufferResponse)
|
||||
: Request(httpMethod, std::move(url), NullBodyStream::GetNullBodyStream(), shouldBufferResponse)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -51,8 +51,8 @@ std::unique_ptr<RawResponse> TransportPolicy::Send(
|
||||
* - If ReadToEnd() fails while downloading all the response, the retry policy will make sure to
|
||||
* re-send the request to re-start the download.
|
||||
*
|
||||
* - If the request returns error (statusCode >= 300), even if `request.IsBufferedDownload()`, the
|
||||
* response will be download to the response's buffer.
|
||||
* - If the request returns error (statusCode >= 300), even if `request.ShouldBufferResponse()`,
|
||||
*the response will be download to the response's buffer.
|
||||
*
|
||||
***********************************************************************************
|
||||
*
|
||||
@ -63,13 +63,13 @@ std::unique_ptr<RawResponse> TransportPolicy::Send(
|
||||
|
||||
// special case to return a response with BodyStream to read directly from socket
|
||||
// Return only if response did not fail.
|
||||
if (!request.IsBufferedDownload() && statusCode < 300)
|
||||
if (!request.ShouldBufferResponse() && statusCode < 300)
|
||||
{
|
||||
return response;
|
||||
}
|
||||
|
||||
// At this point, either the request is `bufferedDownload` or it return with an error code. The
|
||||
// entire payload needs must be downloaded to the response's buffer.
|
||||
// At this point, either the request is `shouldBufferResponse` or it return with an error code.
|
||||
// The entire payload needs must be downloaded to the response's buffer.
|
||||
auto bodyStream = response->ExtractBodyStream();
|
||||
response->SetBody(bodyStream->ReadToEnd(ctx));
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user