Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 0 additions & 55 deletions sdk/core/azure-core/inc/azure/core/http/policies/policy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -427,59 +427,4 @@ namespace Azure { namespace Core { namespace Http { namespace Policies {
Context const& ctx) const override;
};

namespace _internal {
/**
* @brief #Azure::Core::Http::Policies::_internal::ValuePolicy options.
*/
struct ValueOptions
{
CaseInsensitiveMap HeaderValues;
std::map<std::string, std::string> QueryValues;
};

/**
* @brief Value policy.
*
* @details Applies key-value pair values to each HTTP request (either HTTP headers or query
* parameters).
*/
class ValuePolicy : public HttpPolicy {
Comment on lines -430 to -446

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI, this is the type of change we wouldn't (easily) be able to make post-GA. Even if we no longer have any users within the repo, if we GA'd a package that used it at some point, we'd have to keep such internal types around.

private:
ValueOptions m_options;

public:
/**
* @brief Construct a #Azure::Core::Http::Policies::_internal::ValuePolicy with the
* #Azure::Core::Http::Policies::_internal::ValueOptions provided.
* @param options #Azure::Core::Http::Policies::_internal::ValueOptions.
*/
explicit ValuePolicy(ValueOptions options) : m_options(std::move(options)) {}

std::unique_ptr<HttpPolicy> Clone() const override
{
return std::make_unique<ValuePolicy>(*this);
}

std::unique_ptr<RawResponse> Send(
Request& request,
NextHttpPolicy nextHttpPolicy,
Context const& ctx) const override
{
for (auto const& hdrPair : m_options.HeaderValues)
{
request.SetHeader(hdrPair.first, hdrPair.second);
}

{
auto& url = request.GetUrl();
for (auto const& qryPair : m_options.QueryValues)
{
url.AppendQueryParameter(qryPair.first, qryPair.second);
}
}

return nextHttpPolicy.Send(request, ctx);
}
};
} // namespace _internal
}}}} // namespace Azure::Core::Http::Policies
28 changes: 0 additions & 28 deletions sdk/core/azure-core/test/ut/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,34 +124,6 @@ TEST(Policy, throwWhenNoTransportPolicyMessage)
}
}

TEST(Policy, ValuePolicy)
{
using namespace Azure::Core;
using namespace Azure::Core::Http;
using namespace Azure::Core::Http::Policies;
using namespace Azure::Core::Http::_internal;

Azure::Core::Http::Policies::_internal::ValueOptions options
= {{{"hdrkey1", "HdrVal1"}, {"hdrkey2", "HdrVal2"}},
{{"QryKey1", "QryVal1"}, {"QryKey2", "QryVal2"}}};

std::vector<std::unique_ptr<HttpPolicy>> policies;
policies.emplace_back(
std::make_unique<Azure::Core::Http::Policies::_internal::ValuePolicy>(options));
policies.emplace_back(std::make_unique<NoOpPolicy>());
HttpPipeline pipeline(policies);

Request request(HttpMethod::Get, Url("https:://www.example.com"));

pipeline.Send(request, Context::GetApplicationContext());

auto headers = request.GetHeaders();
auto queryParams = request.GetUrl().GetQueryParameters();

ASSERT_EQ(headers, decltype(headers)({{"hdrkey1", "HdrVal1"}, {"hdrkey2", "HdrVal2"}}));
ASSERT_EQ(queryParams, decltype(queryParams)({{"QryKey1", "QryVal1"}, {"QryKey2", "QryVal2"}}));
}

TEST(Policy, RetryPolicyCounter)
{
using namespace Azure::Core;
Expand Down