CommonRequest.cc 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright 1999-2019 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/core/CommonRequest.h>
  17. namespace AlibabaCloud {
  18. CommonRequest::CommonRequest(RequestPattern pattern):
  19. ServiceRequest("", ""),
  20. domain_(),
  21. queryParams_(),
  22. httpMethod_(HttpRequest::Get),
  23. requestPattern_(pattern) {
  24. }
  25. CommonRequest::~CommonRequest() {
  26. }
  27. std::string CommonRequest::domain()const {
  28. return domain_;
  29. }
  30. void CommonRequest::setDomain(const std::string &domain) {
  31. domain_ = domain;
  32. }
  33. CommonRequest::RequestPattern CommonRequest::requestPattern() const {
  34. return requestPattern_;
  35. }
  36. void CommonRequest::setRequestPattern(RequestPattern pattern) {
  37. requestPattern_ = pattern;
  38. }
  39. void CommonRequest::setHttpMethod(HttpRequest::Method method) {
  40. httpMethod_ = method;
  41. }
  42. HttpRequest::Method CommonRequest::httpMethod() const {
  43. return httpMethod_;
  44. }
  45. CommonRequest::ParameterValueType CommonRequest::queryParameter(
  46. const ParameterNameType &name) const {
  47. ParameterCollection::const_iterator it = queryParams_.find(name);
  48. if (it == queryParams_.end()) {
  49. return ParameterValueType("");
  50. }
  51. return it->second;
  52. }
  53. CommonRequest::ParameterCollection CommonRequest::queryParameters() const {
  54. return queryParams_;
  55. }
  56. void CommonRequest::setQueryParameter(const ParameterNameType &name,
  57. const ParameterValueType &value) {
  58. queryParams_[name] = value;
  59. }
  60. CommonRequest::ParameterValueType CommonRequest::headerParameter(
  61. const ParameterNameType &name) const {
  62. const ParameterCollection::const_iterator it = headerParams_.find(name);
  63. if (it == headerParams_.end()) {
  64. return ParameterValueType("");
  65. }
  66. return it->second;
  67. }
  68. CommonRequest::ParameterCollection CommonRequest::headerParameters() const {
  69. return headerParams_;
  70. }
  71. void CommonRequest::setHeaderParameter(const ParameterNameType &name,
  72. const ParameterValueType &value) {
  73. headerParams_[name] = value;
  74. }
  75. } // namespace AlibabaCloud