Adding some request header
when constructing request
This commit is contained in:
@@ -23,6 +23,7 @@ RpcServiceRequest::RpcServiceRequest(const std::string &product,
|
||||
const std::string &action)
|
||||
: ServiceRequest(product, version) {
|
||||
setActionName(action);
|
||||
setHeader(std::string("x-acs-action"), action);
|
||||
}
|
||||
|
||||
RpcServiceRequest::~RpcServiceRequest() {}
|
||||
|
||||
@@ -25,7 +25,9 @@ ServiceRequest::ServiceRequest(const std::string &product,
|
||||
: content_(nullptr), contentSize_(0), params_(), product_(product),
|
||||
resourcePath_("/"), version_(version), scheme_("https"),
|
||||
connectTimeout_(kInvalidTimeout), readTimeout_(kInvalidTimeout),
|
||||
method_(HttpRequest::Method::Get) {}
|
||||
method_(HttpRequest::Method::Get) {
|
||||
setHeader(std::string("x-acs-version"), version);
|
||||
}
|
||||
|
||||
ServiceRequest::ServiceRequest(const ServiceRequest &other)
|
||||
: content_(nullptr), contentSize_(other.contentSize_),
|
||||
|
||||
@@ -15,4 +15,5 @@ TEST(test_RpcServiceRequest, basic) {
|
||||
EXPECT_TRUE(rpc.actionName() == action);
|
||||
EXPECT_TRUE(rpc.product() == product);
|
||||
EXPECT_TRUE(rpc.version() == version);
|
||||
EXPECT_EQ(string("testAction"), rpc.getHeader(string("x-acs-action")));
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace {
|
||||
|
||||
TestServiceRequest sr1("ECS", "1.0");
|
||||
TestServiceRequest sr2(sr1);
|
||||
EXPECT_EQ(string("1.0"), sr1.getHeader(string("x-acs-version")));
|
||||
|
||||
sr1.addParameter("k1", "v1");
|
||||
sr2.addParameter("k2", "v2");
|
||||
|
||||
Reference in New Issue
Block a user