Move policies to internal (#1985)
This commit is contained in:
parent
e396888726
commit
ddd7a093f4
@ -4,6 +4,7 @@
|
||||
|
||||
### Breaking Changes
|
||||
|
||||
- Removed from `Azure::Core::Http::Policies` namespace: `HttpPolicyOrder`, `TransportPolicy`, `RetryPolicy`, `RequestIdPolicy`, `TelemetryPolicy`, `BearerTokenAuthenticationPolicy`, `LogPolicy`.
|
||||
- Renamed `Azure::Core::Http::RawResponse::GetBodyStream()` to `ExtractBodyStream()`.
|
||||
|
||||
## 1.0.0-beta.7 (2021-03-11)
|
||||
|
||||
@ -199,15 +199,15 @@ namespace Azure { namespace Core { namespace Http {
|
||||
}
|
||||
}
|
||||
|
||||
namespace Policies {
|
||||
namespace Policies { namespace _internal {
|
||||
class RetryPolicy;
|
||||
}
|
||||
}} // namespace Policies::_internal
|
||||
|
||||
/**
|
||||
* @brief HTTP request.
|
||||
*/
|
||||
class Request {
|
||||
friend class Azure::Core::Http::Policies::RetryPolicy;
|
||||
friend class Azure::Core::Http::Policies::_internal::RetryPolicy;
|
||||
#if defined(TESTING_BUILD)
|
||||
// make tests classes friends to validate set Retry
|
||||
friend class Azure::Core::Test::TestHttp_getters_Test;
|
||||
|
||||
@ -30,24 +30,91 @@ namespace Azure { namespace Core { namespace Http { namespace Policies {
|
||||
|
||||
namespace _detail {
|
||||
std::shared_ptr<HttpTransport> GetTransportAdapter();
|
||||
}
|
||||
AZ_CORE_DLLEXPORT extern Azure::Core::CaseInsensitiveSet const g_defaultAllowedHttpHeaders;
|
||||
} // namespace _detail
|
||||
|
||||
/**
|
||||
* @brief Define the order of execution of and Http policy when a request is sent to the server.
|
||||
* @brief Telemetry options.
|
||||
*
|
||||
*/
|
||||
enum class HttpPolicyOrder
|
||||
struct TelemetryOptions
|
||||
{
|
||||
/**
|
||||
* @brief The policy would be invoked once per request invocation (service call).
|
||||
* @brief The Application ID is the last part of the user agent for telemetry.
|
||||
*
|
||||
* @remark This option allows an end-user to create an SDK client and report telemetry with a
|
||||
* specific ID for it. The default is an empty string.
|
||||
*
|
||||
*/
|
||||
PerCall,
|
||||
std::string ApplicationId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Retry options.
|
||||
*/
|
||||
struct RetryOptions
|
||||
{
|
||||
/**
|
||||
* @brief The policy would be invoked every time the request is retried.
|
||||
* @brief Maximum number of attempts to retry.
|
||||
*/
|
||||
int MaxRetries = 3;
|
||||
|
||||
/**
|
||||
* @brief Mimimum amount of time between retry attempts.
|
||||
*/
|
||||
std::chrono::milliseconds RetryDelay = std::chrono::seconds(4);
|
||||
|
||||
/**
|
||||
* @brief Mimimum amount of time between retry attempts.
|
||||
*/
|
||||
decltype(RetryDelay) MaxRetryDelay = std::chrono::minutes(2);
|
||||
|
||||
/**
|
||||
* @brief HTTP status codes to retry on.
|
||||
*/
|
||||
std::set<HttpStatusCode> StatusCodes{
|
||||
HttpStatusCode::RequestTimeout,
|
||||
HttpStatusCode::InternalServerError,
|
||||
HttpStatusCode::BadGateway,
|
||||
HttpStatusCode::ServiceUnavailable,
|
||||
HttpStatusCode::GatewayTimeout,
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Log options.
|
||||
*/
|
||||
struct LogOptions
|
||||
{
|
||||
/**
|
||||
* @brief HTTP query parameters that are allowed to be logged.
|
||||
*/
|
||||
std::set<std::string> AllowedHttpQueryParameters;
|
||||
|
||||
/**
|
||||
* @brief HTTP headers that are allowed to be logged.
|
||||
*/
|
||||
Azure::Core::CaseInsensitiveSet AllowedHttpHeaders = _detail::g_defaultAllowedHttpHeaders;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Transport options.
|
||||
*
|
||||
*/
|
||||
struct TransportOptions
|
||||
{
|
||||
/**
|
||||
* @brief Set the #Azure::Core::Http::HttpTransport that the transport policy will use to send
|
||||
* and receive requests and responses over the wire.
|
||||
*
|
||||
* @remark When no option is set, the default transport adapter on non-Windows platforms is
|
||||
* the curl transport adapter and winhttp transport adapter on Windows.
|
||||
*
|
||||
* @remark When using a custom transport adapter, the implementation for
|
||||
* `AzureSdkGetCustomHttpTransport` must be linked in the end-user application.
|
||||
*
|
||||
*/
|
||||
PerRetry
|
||||
std::shared_ptr<HttpTransport> Transport = _detail::GetTransportAdapter();
|
||||
};
|
||||
|
||||
class NextHttpPolicy;
|
||||
@ -67,8 +134,8 @@ namespace Azure { namespace Core { namespace Http { namespace Policies {
|
||||
*
|
||||
* @param context #Azure::Core::Context so that operation can be cancelled.
|
||||
* @param request An #Azure::Core::Http::Request being sent.
|
||||
* @param policy #Azure::Core::Http::Policies::NextHttpPolicy to invoke after this policy has
|
||||
* been applied.
|
||||
* @param policy #Azure::Core::Http::Policies::NextHttpPolicy to invoke after this
|
||||
* policy has been applied.
|
||||
*
|
||||
* @return An #Azure::Core::Http::RawResponse after this policy, and all subsequent HTTP
|
||||
* policies in the stack sequence of policies have been applied.
|
||||
@ -130,301 +197,217 @@ namespace Azure { namespace Core { namespace Http { namespace Policies {
|
||||
std::unique_ptr<RawResponse> Send(Request& request, Context const& context);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The options for the #Azure::Core::Http::TransportPolicy.
|
||||
*
|
||||
*/
|
||||
struct TransportOptions
|
||||
{
|
||||
/**
|
||||
* @brief Set the #Azure::Core::Http::HttpTransport that the transport policy will use to send
|
||||
* and receive requests and responses over the wire.
|
||||
*
|
||||
* @remark When no option is set, the default transport adapter on non-Windows platforms is
|
||||
* the curl transport adapter and winhttp transport adapter on Windows.
|
||||
*
|
||||
* @remark When using a custom transport adapter, the implementation for
|
||||
* `AzureSdkGetCustomHttpTransport` must be linked in the end-user application.
|
||||
*
|
||||
*/
|
||||
std::shared_ptr<HttpTransport> Transport = _detail::GetTransportAdapter();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Applying this policy sends an HTTP request over the wire.
|
||||
* @remark This policy must be the bottom policy in the stack of the HTTP policy stack.
|
||||
*/
|
||||
class TransportPolicy : public HttpPolicy {
|
||||
private:
|
||||
TransportOptions m_options;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct an HTTP transport policy.
|
||||
*
|
||||
* @param options #Azure::Core::Http::Policies::TransportOptions.
|
||||
*/
|
||||
explicit TransportPolicy(TransportOptions options = TransportOptions())
|
||||
: m_options(std::move(options))
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<TransportPolicy>(*this);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Options for the #Azure::Core::Http::Policies::RetryPolicy.
|
||||
*/
|
||||
struct RetryOptions
|
||||
{
|
||||
/**
|
||||
* @brief Maximum number of attempts to retry.
|
||||
*/
|
||||
int MaxRetries = 3;
|
||||
namespace _internal {
|
||||
|
||||
/**
|
||||
* @brief Mimimum amount of time between retry attempts.
|
||||
* @brief Applying this policy sends an HTTP request over the wire.
|
||||
* @remark This policy must be the bottom policy in the stack of the HTTP policy stack.
|
||||
*/
|
||||
std::chrono::milliseconds RetryDelay = std::chrono::seconds(4);
|
||||
class TransportPolicy : public HttpPolicy {
|
||||
private:
|
||||
TransportOptions m_options;
|
||||
|
||||
/**
|
||||
* @brief Mimimum amount of time between retry attempts.
|
||||
*/
|
||||
decltype(RetryDelay) MaxRetryDelay = std::chrono::minutes(2);
|
||||
public:
|
||||
/**
|
||||
* @brief Construct an HTTP transport policy.
|
||||
*
|
||||
* @param options #Azure::Core::Http::Policies::TransportOptions.
|
||||
*/
|
||||
explicit TransportPolicy(TransportOptions options = TransportOptions())
|
||||
: m_options(std::move(options))
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief HTTP status codes to retry on.
|
||||
*/
|
||||
std::set<HttpStatusCode> StatusCodes{
|
||||
HttpStatusCode::RequestTimeout,
|
||||
HttpStatusCode::InternalServerError,
|
||||
HttpStatusCode::BadGateway,
|
||||
HttpStatusCode::ServiceUnavailable,
|
||||
HttpStatusCode::GatewayTimeout,
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<TransportPolicy>(*this);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override;
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief HTTP retry policy.
|
||||
*/
|
||||
class RetryPolicy : public HttpPolicy {
|
||||
private:
|
||||
RetryOptions m_retryOptions;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructs HTTP retry policy with the provided #Azure::Core::Http::Policies::RetryOptions.
|
||||
* @brief HTTP retry policy.
|
||||
*/
|
||||
class RetryPolicy : public HttpPolicy {
|
||||
private:
|
||||
RetryOptions m_retryOptions;
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructs HTTP retry policy with the provided #Azure::Core::Http::Policies::RetryOptions.
|
||||
*
|
||||
* @param options #Azure::Core::Http::Policies::RetryOptions.
|
||||
*/
|
||||
explicit RetryPolicy(RetryOptions options) : m_retryOptions(std::move(options)) {}
|
||||
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<RetryPolicy>(*this);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override;
|
||||
|
||||
/**
|
||||
* @brief Get the Retry Count from the context.
|
||||
*
|
||||
* @remark The sentinel `-1` is returned if there is no information in the \p Context about
|
||||
* #RetryPolicy is trying to send a request. Then `0` is returned for the first try of sending
|
||||
* a request by the #RetryPolicy. Any subsequent retry will be referenced with a number
|
||||
* greater than 0.
|
||||
*
|
||||
* @param context The context used to call send request.
|
||||
* @return A positive number indicating the current intent to send the request.
|
||||
*/
|
||||
static int GetRetryNumber(Context const& context);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief HTTP Request ID policy.
|
||||
*
|
||||
* @param options #Azure::Core::Http::Policies::RetryOptions.
|
||||
* @details Applies an HTTP header with a unique ID to each HTTP request, so that each
|
||||
* individual request can be traced for troubleshooting.
|
||||
*/
|
||||
explicit RetryPolicy(RetryOptions options) : m_retryOptions(std::move(options)) {}
|
||||
class RequestIdPolicy : public HttpPolicy {
|
||||
private:
|
||||
constexpr static const char* RequestIdHeader = "x-ms-client-request-id";
|
||||
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<RetryPolicy>(*this);
|
||||
}
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs HTTP request ID policy.
|
||||
*/
|
||||
explicit RequestIdPolicy() {}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override;
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<RequestIdPolicy>(*this);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override
|
||||
{
|
||||
auto uuid = Uuid::CreateUuid().ToString();
|
||||
|
||||
request.SetHeader(RequestIdHeader, uuid);
|
||||
return nextHttpPolicy.Send(request, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Get the Retry Count from the context.
|
||||
* @brief HTTP telemetry policy.
|
||||
*
|
||||
* @remark The sentinel `-1` is returned if there is no information in the \p Context about
|
||||
* #RetryPolicy is trying to send a request. Then `0` is returned for the first try of sending
|
||||
* a request by the #RetryPolicy. Any subsequent retry will be referenced with a number
|
||||
* greater than 0.
|
||||
* @details Applies an HTTP header with a component name and version to each HTTP request,
|
||||
* includes Azure SDK version information, and operating system information.
|
||||
* @remark See https://azure.github.io/azure-sdk/general_azurecore.html#telemetry-policy.
|
||||
*/
|
||||
class TelemetryPolicy : public HttpPolicy {
|
||||
std::string const m_telemetryId;
|
||||
|
||||
static std::string BuildTelemetryId(
|
||||
std::string const& componentName,
|
||||
std::string const& componentVersion,
|
||||
std::string const& applicationId);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct HTTP telemetry policy.
|
||||
*
|
||||
* @param componentName Azure SDK component name (e.g. "storage.blobs").
|
||||
* @param componentVersion Azure SDK component version (e.g. "11.0.0").
|
||||
* @param options The optional parameters for the policy (e.g. "AzCopy")
|
||||
*/
|
||||
explicit TelemetryPolicy(
|
||||
std::string const& componentName,
|
||||
std::string const& componentVersion,
|
||||
TelemetryOptions options = TelemetryOptions())
|
||||
: m_telemetryId(BuildTelemetryId(componentName, componentVersion, options.ApplicationId))
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<TelemetryPolicy>(*this);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Bearer Token authentication policy.
|
||||
*/
|
||||
class BearerTokenAuthenticationPolicy : public HttpPolicy {
|
||||
private:
|
||||
std::shared_ptr<Credentials::TokenCredential const> const m_credential;
|
||||
Credentials::TokenRequestContext m_tokenRequestContext;
|
||||
|
||||
mutable Credentials::AccessToken m_accessToken;
|
||||
mutable std::mutex m_accessTokenMutex;
|
||||
|
||||
BearerTokenAuthenticationPolicy(BearerTokenAuthenticationPolicy const&) = delete;
|
||||
void operator=(BearerTokenAuthenticationPolicy const&) = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a Bearer Token authentication policy.
|
||||
*
|
||||
* @param credential An #Azure::Core::TokenCredential to use with this policy.
|
||||
* @param tokenRequestContext #Azure::Core::Credentials::TokenRequestContext.
|
||||
*/
|
||||
explicit BearerTokenAuthenticationPolicy(
|
||||
std::shared_ptr<Credentials::TokenCredential const> credential,
|
||||
Credentials::TokenRequestContext tokenRequestContext)
|
||||
: m_credential(std::move(credential)),
|
||||
m_tokenRequestContext(std::move(tokenRequestContext))
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<BearerTokenAuthenticationPolicy>(
|
||||
m_credential, m_tokenRequestContext);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy policy,
|
||||
Context const& context) const override;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Logs every HTTP request.
|
||||
*
|
||||
* @param context The context used to call send request.
|
||||
* @return A positive number indicating the current intent to send the request.
|
||||
* @details Logs every HTTP request and response.
|
||||
* @remark See Azure::Core::Diagnostics::Logger.
|
||||
*/
|
||||
static int GetRetryNumber(Context const& context);
|
||||
};
|
||||
class LogPolicy : public HttpPolicy {
|
||||
LogOptions m_options;
|
||||
|
||||
/**
|
||||
* @brief HTTP Request ID policy.
|
||||
*
|
||||
* @details Applies an HTTP header with a unique ID to each HTTP request, so that each
|
||||
* individual request can be traced for troubleshooting.
|
||||
*/
|
||||
class RequestIdPolicy : public HttpPolicy {
|
||||
private:
|
||||
constexpr static const char* RequestIdHeader = "x-ms-client-request-id";
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs HTTP logging policy.
|
||||
*/
|
||||
explicit LogPolicy(LogOptions options) : m_options(std::move(options)) {}
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs HTTP request ID policy.
|
||||
*/
|
||||
explicit RequestIdPolicy() {}
|
||||
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<RequestIdPolicy>(*this);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override
|
||||
{
|
||||
auto uuid = Uuid::CreateUuid().ToString();
|
||||
|
||||
request.SetHeader(RequestIdHeader, uuid);
|
||||
return nextHttpPolicy.Send(request, ctx);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The options for the #Azure::Core::Http::Policies::TelemetryPolicy
|
||||
*
|
||||
*/
|
||||
struct TelemetryOptions
|
||||
{
|
||||
/**
|
||||
* @brief The Application id is the last part of the user agent for telemetry.
|
||||
*
|
||||
* @remark This option allows an end-user to create an SDK client and report telemetry with a
|
||||
* specific ID for it. The default is an empty string.
|
||||
*
|
||||
*/
|
||||
std::string ApplicationId;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief HTTP telemetry policy.
|
||||
*
|
||||
* @details Applies an HTTP header with a component name and version to each HTTP request,
|
||||
* includes Azure SDK version information, and operating system information.
|
||||
* @remark See https://azure.github.io/azure-sdk/general_azurecore.html#telemetry-policy.
|
||||
*/
|
||||
class TelemetryPolicy : public HttpPolicy {
|
||||
std::string const m_telemetryId;
|
||||
|
||||
static std::string BuildTelemetryId(
|
||||
std::string const& componentName,
|
||||
std::string const& componentVersion,
|
||||
std::string const& applicationId);
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct HTTP telemetry policy.
|
||||
*
|
||||
* @param componentName Azure SDK component name (e.g. "storage.blobs").
|
||||
* @param componentVersion Azure SDK component version (e.g. "11.0.0").
|
||||
* @param options The optional parameters for the policy (e.g. "AzCopy")
|
||||
*/
|
||||
explicit TelemetryPolicy(
|
||||
std::string const& componentName,
|
||||
std::string const& componentVersion,
|
||||
TelemetryOptions options = TelemetryOptions())
|
||||
: m_telemetryId(BuildTelemetryId(componentName, componentVersion, options.ApplicationId))
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<TelemetryPolicy>(*this);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Bearer Token authentication policy.
|
||||
*/
|
||||
class BearerTokenAuthenticationPolicy : public HttpPolicy {
|
||||
private:
|
||||
std::shared_ptr<Credentials::TokenCredential const> const m_credential;
|
||||
Credentials::TokenRequestContext m_tokenRequestContext;
|
||||
|
||||
mutable Credentials::AccessToken m_accessToken;
|
||||
mutable std::mutex m_accessTokenMutex;
|
||||
|
||||
BearerTokenAuthenticationPolicy(BearerTokenAuthenticationPolicy const&) = delete;
|
||||
void operator=(BearerTokenAuthenticationPolicy const&) = delete;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Construct a Bearer Token authentication policy.
|
||||
*
|
||||
* @param credential An #Azure::Core::TokenCredential to use with this policy.
|
||||
* @param tokenRequestContext #Azure::Core::Credentials::TokenRequestContext.
|
||||
*/
|
||||
explicit BearerTokenAuthenticationPolicy(
|
||||
std::shared_ptr<Credentials::TokenCredential const> credential,
|
||||
Credentials::TokenRequestContext tokenRequestContext)
|
||||
: m_credential(std::move(credential)), m_tokenRequestContext(std::move(tokenRequestContext))
|
||||
{
|
||||
}
|
||||
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<BearerTokenAuthenticationPolicy>(m_credential, m_tokenRequestContext);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy policy,
|
||||
Context const& context) const override;
|
||||
};
|
||||
|
||||
namespace _detail {
|
||||
AZ_CORE_DLLEXPORT extern Azure::Core::CaseInsensitiveSet const g_defaultAllowedHttpHeaders;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Options for Azure::Core::Http::LogPolicy.
|
||||
*/
|
||||
struct LogOptions
|
||||
{
|
||||
/**
|
||||
* @brief HTTP query parameters that are allowed to be logged.
|
||||
*/
|
||||
std::set<std::string> AllowedHttpQueryParameters;
|
||||
|
||||
/**
|
||||
* @brief HTTP headers that are allowed to be logged.
|
||||
*/
|
||||
Azure::Core::CaseInsensitiveSet AllowedHttpHeaders = _detail::g_defaultAllowedHttpHeaders;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Logs every HTTP request.
|
||||
*
|
||||
* @details Logs every HTTP request and response.
|
||||
* @remark See Azure::Core::Diagnostics::Logger.
|
||||
*/
|
||||
class LogPolicy : public HttpPolicy {
|
||||
LogOptions m_options;
|
||||
|
||||
public:
|
||||
/**
|
||||
* @brief Constructs HTTP logging policy.
|
||||
*/
|
||||
explicit LogPolicy(LogOptions options) : m_options(std::move(options)) {}
|
||||
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<LogPolicy>(*this);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override;
|
||||
};
|
||||
std::unique_ptr<HttpPolicy> Clone() const override
|
||||
{
|
||||
return std::make_unique<LogPolicy>(*this);
|
||||
}
|
||||
|
||||
std::unique_ptr<RawResponse> Send(
|
||||
Request& request,
|
||||
NextHttpPolicy nextHttpPolicy,
|
||||
Context const& ctx) const override;
|
||||
};
|
||||
} // namespace _internal
|
||||
}}}} // namespace Azure::Core::Http::Policies
|
||||
|
||||
@ -37,8 +37,8 @@ namespace Azure { namespace Core { namespace Http { namespace _internal {
|
||||
/**
|
||||
* @brief Construct HTTP pipeline with the sequence of HTTP policies provided.
|
||||
*
|
||||
* @param policies A sequence of #Azure::Core::Http::Policies::HttpPolicy representing a stack,
|
||||
* first element corresponding to the top of the stack.
|
||||
* @param policies A sequence of #Azure::Core::Http::Policies::HttpPolicy
|
||||
* representing a stack, first element corresponding to the top of the stack.
|
||||
*
|
||||
* @throw `std::invalid_argument` when policies is empty.
|
||||
*/
|
||||
@ -101,14 +101,16 @@ namespace Azure { namespace Core { namespace Http { namespace _internal {
|
||||
}
|
||||
|
||||
// Request Id
|
||||
m_policies.emplace_back(std::make_unique<Azure::Core::Http::Policies::RequestIdPolicy>());
|
||||
m_policies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::RequestIdPolicy>());
|
||||
// Telemetry
|
||||
m_policies.emplace_back(std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>(
|
||||
telemetryServiceName, telemetryServiceVersion, clientOptions.Telemetry));
|
||||
m_policies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>(
|
||||
telemetryServiceName, telemetryServiceVersion, clientOptions.Telemetry));
|
||||
|
||||
// Retry policy
|
||||
m_policies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::RetryPolicy>(clientOptions.Retry));
|
||||
m_policies.emplace_back(std::make_unique<Azure::Core::Http::Policies::_internal::RetryPolicy>(
|
||||
clientOptions.Retry));
|
||||
|
||||
// service-specific per retry policies.
|
||||
for (auto& policy : perRetryPolicies)
|
||||
@ -123,18 +125,19 @@ namespace Azure { namespace Core { namespace Http { namespace _internal {
|
||||
|
||||
// logging - won't update request
|
||||
m_policies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::LogPolicy>(clientOptions.Log));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::LogPolicy>(clientOptions.Log));
|
||||
|
||||
// transport
|
||||
m_policies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(clientOptions.Transport));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(
|
||||
clientOptions.Transport));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Construct HTTP pipeline with the sequence of HTTP policies provided.
|
||||
*
|
||||
* @param policies A sequence of #Azure::Core::Http::Policies::HttpPolicy representing a stack,
|
||||
* first element corresponding to the top of the stack.
|
||||
* @param policies A sequence of #Azure::Core::Http::Policies::HttpPolicy
|
||||
* representing a stack, first element corresponding to the top of the stack.
|
||||
*
|
||||
* @throw `std::invalid_argument` when policies is empty.
|
||||
*/
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
using Azure::Core::Context;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
|
||||
std::unique_ptr<RawResponse> BearerTokenAuthenticationPolicy::Send(
|
||||
Request& request,
|
||||
|
||||
@ -14,6 +14,7 @@ using Azure::Core::Context;
|
||||
using namespace Azure::Core;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
|
||||
namespace {
|
||||
std::string RedactedPlaceholder = "REDACTED";
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
using Azure::Core::Context;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
|
||||
namespace {
|
||||
typedef decltype(RetryOptions::RetryDelay) Delay;
|
||||
|
||||
@ -95,6 +95,7 @@ std::string TrimString(std::string s)
|
||||
using Azure::Core::Context;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
|
||||
std::string TelemetryPolicy::BuildTelemetryId(
|
||||
std::string const& componentName,
|
||||
|
||||
@ -15,6 +15,7 @@ using Azure::Core::Context;
|
||||
using namespace Azure::Core::IO;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
|
||||
std::shared_ptr<HttpTransport> Azure::Core::Http::Policies::_detail::GetTransportAdapter()
|
||||
{
|
||||
|
||||
@ -34,7 +34,8 @@ namespace Azure { namespace Core { namespace Test {
|
||||
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
|
||||
Azure::Core::Http::Policies::TransportOptions options;
|
||||
options.Transport = transportAdapter;
|
||||
auto transportPolicy = std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(options);
|
||||
auto transportPolicy
|
||||
= std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(options);
|
||||
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.emplace_back(std::move(transportPolicy));
|
||||
@ -64,7 +65,8 @@ namespace Azure { namespace Core { namespace Test {
|
||||
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
|
||||
Azure::Core::Http::Policies::TransportOptions options;
|
||||
options.Transport = transportAdapter;
|
||||
auto transportPolicy = std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(options);
|
||||
auto transportPolicy
|
||||
= std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(options);
|
||||
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.emplace_back(std::move(transportPolicy));
|
||||
@ -98,7 +100,7 @@ namespace Azure { namespace Core { namespace Test {
|
||||
|
||||
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
|
||||
auto transportPolicy =
|
||||
std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(transportAdapter);
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(transportAdapter);
|
||||
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.emplace_back(std::move(transportPolicy));
|
||||
@ -124,7 +126,7 @@ namespace Azure { namespace Core { namespace Test {
|
||||
|
||||
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
|
||||
auto transportPolicy =
|
||||
std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(transportAdapter);
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(transportAdapter);
|
||||
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.emplace_back(std::move(transportPolicy));
|
||||
@ -150,7 +152,7 @@ namespace Azure { namespace Core { namespace Test {
|
||||
|
||||
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
|
||||
auto transportPolicy =
|
||||
std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(transportAdapter);
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(transportAdapter);
|
||||
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.emplace_back(std::move(transportPolicy));
|
||||
@ -180,7 +182,8 @@ namespace Azure { namespace Core { namespace Test {
|
||||
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
|
||||
Azure::Core::Http::Policies::TransportOptions options;
|
||||
options.Transport = transportAdapter;
|
||||
auto transportPolicy = std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(options);
|
||||
auto transportPolicy
|
||||
= std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(options);
|
||||
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.emplace_back(std::move(transportPolicy));
|
||||
@ -211,7 +214,8 @@ namespace Azure { namespace Core { namespace Test {
|
||||
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>();
|
||||
Azure::Core::Http::Policies::TransportOptions options;
|
||||
options.Transport = transportAdapter;
|
||||
auto transportPolicy = std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(options);
|
||||
auto transportPolicy
|
||||
= std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(options);
|
||||
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.emplace_back(std::move(transportPolicy));
|
||||
@ -245,7 +249,8 @@ namespace Azure { namespace Core { namespace Test {
|
||||
auto transportAdapter = std::make_shared<Azure::Core::Http::CurlTransport>(curlOptions);
|
||||
Azure::Core::Http::Policies::TransportOptions options;
|
||||
options.Transport = transportAdapter;
|
||||
auto transportPolicy = std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(options);
|
||||
auto transportPolicy
|
||||
= std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(options);
|
||||
|
||||
{
|
||||
// use inner scope to remove the pipeline and make sure we don't keep the connection in the
|
||||
|
||||
@ -12,7 +12,7 @@ TEST(Pipeline, createPipeline)
|
||||
// Construct pipeline without exception
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
|
||||
EXPECT_NO_THROW(Azure::Core::Http::_internal::HttpPipeline pipeline(policies));
|
||||
}
|
||||
@ -30,7 +30,7 @@ TEST(Pipeline, clonePipeline)
|
||||
// Construct pipeline without exception and clone
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
|
||||
Azure::Core::Http::_internal::HttpPipeline pipeline(policies);
|
||||
EXPECT_NO_THROW(Azure::Core::Http::_internal::HttpPipeline pipeline2(pipeline));
|
||||
|
||||
@ -38,7 +38,10 @@ struct TestRetryPolicySharedState : public Azure::Core::Http::Policies::HttpPoli
|
||||
Azure::Core::Http::Policies::NextHttpPolicy nextHttpPolicy,
|
||||
Azure::Core::Context const& ctx) const override
|
||||
{
|
||||
EXPECT_EQ(retryCounterState, Azure::Core::Http::Policies::RetryPolicy::GetRetryNumber(ctx));
|
||||
EXPECT_EQ(
|
||||
retryCounterState,
|
||||
Azure::Core::Http::Policies::_internal::RetryPolicy::GetRetryNumber(ctx));
|
||||
|
||||
retryCounterState += 1;
|
||||
return nextHttpPolicy.Send(request, ctx);
|
||||
}
|
||||
@ -83,7 +86,7 @@ public:
|
||||
Azure::Core::Http::Policies::NextHttpPolicy,
|
||||
Azure::Core::Context const& context) const override
|
||||
{
|
||||
auto retryNumber = Azure::Core::Http::Policies::RetryPolicy::GetRetryNumber(context);
|
||||
auto retryNumber = Azure::Core::Http::Policies::_internal::RetryPolicy::GetRetryNumber(context);
|
||||
if (retryNumber == m_successAfter)
|
||||
{
|
||||
auto response = std::make_unique<Azure::Core::Http::RawResponse>(
|
||||
@ -104,13 +107,13 @@ TEST(Policy, throwWhenNoTransportPolicy)
|
||||
// Construct pipeline without exception
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
|
||||
Azure::Core::Http::_internal::HttpPipeline pipeline(policies);
|
||||
Azure::Core::Url url("");
|
||||
@ -124,13 +127,13 @@ TEST(Policy, throwWhenNoTransportPolicyMessage)
|
||||
// Construct pipeline without exception
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::TelemetryPolicy>("test", "test"));
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TelemetryPolicy>("test", "test"));
|
||||
|
||||
Azure::Core::Http::_internal::HttpPipeline pipeline(policies);
|
||||
Azure::Core::Url url("");
|
||||
@ -150,8 +153,9 @@ TEST(Policy, RetryPolicyCounter)
|
||||
{
|
||||
using namespace Azure::Core;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::_internal;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
// Clean the validation global state
|
||||
retryCounterState = 0;
|
||||
|
||||
@ -177,8 +181,9 @@ TEST(Policy, RetryPolicyRetryCycle)
|
||||
{
|
||||
using namespace Azure::Core;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::_internal;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
// Clean the validation global state
|
||||
retryCounterState = 0;
|
||||
|
||||
@ -200,8 +205,9 @@ TEST(Policy, RetryPolicyKeepContext)
|
||||
{
|
||||
using namespace Azure::Core;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::_internal;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
// Clean the validation global state
|
||||
retryCounterState = 0;
|
||||
|
||||
|
||||
@ -50,7 +50,7 @@ TEST(SimplifiedHeader, core)
|
||||
std::vector<uint8_t> buffer(10);
|
||||
EXPECT_NO_THROW(Azure::Core::IO::MemoryBodyStream mb(buffer));
|
||||
}
|
||||
EXPECT_NO_THROW(Azure::Core::Http::Policies::TelemetryPolicy tp("", ""));
|
||||
EXPECT_NO_THROW(Azure::Core::Http::Policies::_internal::TelemetryPolicy tp("", ""));
|
||||
}
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
@ -7,8 +7,9 @@
|
||||
|
||||
using namespace Azure::Core;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::_internal;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
|
||||
namespace {
|
||||
|
||||
|
||||
@ -44,10 +44,11 @@ namespace Azure { namespace Core { namespace Test {
|
||||
opt.RetryDelay = std::chrono::milliseconds(10);
|
||||
|
||||
// Retry policy will help to prevent server-occasionally-errors
|
||||
policies.push_back(std::make_unique<Azure::Core::Http::Policies::RetryPolicy>(opt));
|
||||
policies.push_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::RetryPolicy>(opt));
|
||||
// Will get transport policy options from test param
|
||||
// auto param = GetParam();
|
||||
policies.push_back(std::make_unique<Azure::Core::Http::Policies::TransportPolicy>(
|
||||
policies.push_back(std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>(
|
||||
GetParam().TransportAdapter));
|
||||
|
||||
m_pipeline = std::make_unique<Azure::Core::Http::_internal::HttpPipeline>(policies);
|
||||
|
||||
@ -15,7 +15,8 @@ using namespace Azure::Security::KeyVault::Common::_internal;
|
||||
TEST(KeyVaultPipeline, initPipeline)
|
||||
{
|
||||
std::vector<std::unique_ptr<Azure::Core::Http::Policies::HttpPolicy>> policies;
|
||||
policies.emplace_back(std::make_unique<Azure::Core::Http::Policies::TransportPolicy>());
|
||||
policies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::TransportPolicy>());
|
||||
Azure::Core::Url url("urlTest");
|
||||
Azure::Core::_internal::ClientOptions options;
|
||||
Azure::Core::Http::_internal::HttpPipeline pipeline(
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
using namespace Azure::Security::KeyVault::Keys;
|
||||
using namespace Azure::Core::Http;
|
||||
using namespace Azure::Core::Http::Policies;
|
||||
using namespace Azure::Core::Http::Policies::_internal;
|
||||
|
||||
namespace {
|
||||
struct RequestWithContinuationToken
|
||||
|
||||
@ -82,7 +82,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Azure::Core::Credentials::TokenRequestContext tokenContext;
|
||||
tokenContext.Scopes.emplace_back(_internal::StorageScope);
|
||||
perRetryPolicies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::BearerTokenAuthenticationPolicy>(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::BearerTokenAuthenticationPolicy>(
|
||||
credential, tokenContext));
|
||||
}
|
||||
perOperationPolicies.emplace_back(
|
||||
|
||||
@ -78,7 +78,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Azure::Core::Credentials::TokenRequestContext tokenContext;
|
||||
tokenContext.Scopes.emplace_back(_internal::StorageScope);
|
||||
perRetryPolicies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::BearerTokenAuthenticationPolicy>(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::BearerTokenAuthenticationPolicy>(
|
||||
credential, tokenContext));
|
||||
}
|
||||
perOperationPolicies.emplace_back(
|
||||
|
||||
@ -73,7 +73,7 @@ namespace Azure { namespace Storage { namespace Blobs {
|
||||
Azure::Core::Credentials::TokenRequestContext tokenContext;
|
||||
tokenContext.Scopes.emplace_back(_internal::StorageScope);
|
||||
perRetryPolicies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::BearerTokenAuthenticationPolicy>(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::BearerTokenAuthenticationPolicy>(
|
||||
credential, tokenContext));
|
||||
}
|
||||
perOperationPolicies.emplace_back(
|
||||
|
||||
@ -20,7 +20,8 @@ namespace Azure { namespace Storage { namespace _internal {
|
||||
|| request.GetMethod() == Azure::Core::Http::HttpMethod::Head)
|
||||
&& !m_secondaryHost.empty() && replicaStatus && *replicaStatus;
|
||||
|
||||
if (considerSecondary && Azure::Core::Http::Policies::RetryPolicy::GetRetryNumber(ctx) > 0)
|
||||
if (considerSecondary
|
||||
&& Azure::Core::Http::Policies::_internal::RetryPolicy::GetRetryNumber(ctx) > 0)
|
||||
{
|
||||
// switch host
|
||||
if (request.GetUrl().GetHost() == m_primaryHost)
|
||||
|
||||
@ -89,7 +89,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
Azure::Core::Credentials::TokenRequestContext tokenContext;
|
||||
tokenContext.Scopes.emplace_back(_internal::StorageScope);
|
||||
perRetryPolicies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::BearerTokenAuthenticationPolicy>(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::BearerTokenAuthenticationPolicy>(
|
||||
credential, tokenContext));
|
||||
}
|
||||
perOperationPolicies.emplace_back(
|
||||
|
||||
@ -126,7 +126,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
Azure::Core::Credentials::TokenRequestContext tokenContext;
|
||||
tokenContext.Scopes.emplace_back(_internal::StorageScope);
|
||||
perRetryPolicies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::BearerTokenAuthenticationPolicy>(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::BearerTokenAuthenticationPolicy>(
|
||||
credential, tokenContext));
|
||||
}
|
||||
perOperationPolicies.emplace_back(
|
||||
|
||||
@ -128,7 +128,7 @@ namespace Azure { namespace Storage { namespace Files { namespace DataLake {
|
||||
Azure::Core::Credentials::TokenRequestContext tokenContext;
|
||||
tokenContext.Scopes.emplace_back(_internal::StorageScope);
|
||||
perRetryPolicies.emplace_back(
|
||||
std::make_unique<Azure::Core::Http::Policies::BearerTokenAuthenticationPolicy>(
|
||||
std::make_unique<Azure::Core::Http::Policies::_internal::BearerTokenAuthenticationPolicy>(
|
||||
credential, tokenContext));
|
||||
}
|
||||
perOperationPolicies.emplace_back(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user