parent
ed1908efa1
commit
dacd6aa6c1
@ -5,6 +5,7 @@
|
||||
### New Features
|
||||
|
||||
- Added a WinHTTP-based `HttpTransport` called `WinHttpTransport` and use that as the default `TransportPolicyOptions.Transport` on Windows when sending and receiving requests and responses over the wire.
|
||||
- Added `Range` type to `Azure::Core::Http` namespace.
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
|
||||
@ -11,8 +11,10 @@
|
||||
#include "azure/core/exception.hpp"
|
||||
#include "azure/core/http/body_stream.hpp"
|
||||
#include "azure/core/internal/contract.hpp"
|
||||
#include "azure/core/nullable.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@ -175,6 +177,26 @@ namespace Azure { namespace Core { namespace Http {
|
||||
NetworkAuthenticationRequired = 511, ///< HTTP 511 Network Authentication Required.
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Defines a range of bytes within an HTTP resource, starting at an `Offset` and ending at
|
||||
* `Offset + Length - 1` inclusively.
|
||||
*
|
||||
*/
|
||||
struct Range
|
||||
{
|
||||
/**
|
||||
* @brief The starting point of the HTTP Range.
|
||||
*
|
||||
*/
|
||||
int64_t Offset = 0;
|
||||
|
||||
/**
|
||||
* @brief The size of the HTTP Range.
|
||||
*
|
||||
*/
|
||||
Azure::Core::Nullable<int64_t> Length;
|
||||
};
|
||||
|
||||
/**
|
||||
* HTTP request method.
|
||||
*/
|
||||
@ -486,10 +508,10 @@ namespace Azure { namespace Core { namespace Http {
|
||||
*/
|
||||
explicit Request(HttpMethod httpMethod, Url url, bool downloadViaStream)
|
||||
: Request(
|
||||
httpMethod,
|
||||
std::move(url),
|
||||
NullBodyStream::GetNullBodyStream(),
|
||||
downloadViaStream)
|
||||
httpMethod,
|
||||
std::move(url),
|
||||
NullBodyStream::GetNullBodyStream(),
|
||||
downloadViaStream)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,8 @@
|
||||
|
||||
#include "azure/core/http/http.hpp"
|
||||
|
||||
#include <utility>
|
||||
|
||||
void Azure::Core::Http::Details::InsertHeaderWithValidation(
|
||||
std::map<std::string, std::string>& headers,
|
||||
std::string const& headerName,
|
||||
|
||||
@ -7,6 +7,7 @@
|
||||
#include <azure/core/http/http.hpp>
|
||||
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
using namespace Azure::Core;
|
||||
@ -129,4 +130,33 @@ namespace Azure { namespace Core { namespace Test {
|
||||
response.GetHeaders(),
|
||||
(std::pair<std::string, std::string>("valid3", "header3")));
|
||||
}
|
||||
|
||||
// HTTP Range
|
||||
TEST(TestHttp, Range)
|
||||
{
|
||||
{
|
||||
Http::Range r{10, 1};
|
||||
EXPECT_EQ(r.Offset, 10);
|
||||
EXPECT_TRUE(r.Length.HasValue());
|
||||
EXPECT_EQ(r.Length.GetValue(), 1);
|
||||
}
|
||||
{
|
||||
Http::Range r;
|
||||
r.Offset = 10;
|
||||
EXPECT_EQ(r.Offset, 10);
|
||||
EXPECT_FALSE(r.Length.HasValue());
|
||||
}
|
||||
{
|
||||
Http::Range r;
|
||||
r.Length = 10;
|
||||
EXPECT_EQ(r.Offset, 0);
|
||||
EXPECT_TRUE(r.Length.HasValue());
|
||||
EXPECT_EQ(r.Length.GetValue(), 10);
|
||||
}
|
||||
{
|
||||
Http::Range r;
|
||||
EXPECT_EQ(r.Offset, 0);
|
||||
EXPECT_FALSE(r.Length.HasValue());
|
||||
}
|
||||
}
|
||||
}}} // namespace Azure::Core::Test
|
||||
|
||||
Loading…
Reference in New Issue
Block a user