CommonRequest.cc 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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("", ""), domain_(), queryParams_(),
  20. httpMethod_(HttpRequest::Get), requestPattern_(pattern) {}
  21. CommonRequest::~CommonRequest() {}
  22. std::string CommonRequest::domain() const { return domain_; }
  23. void CommonRequest::setDomain(const std::string &domain) { domain_ = domain; }
  24. CommonRequest::RequestPattern CommonRequest::requestPattern() const {
  25. return requestPattern_;
  26. }
  27. void CommonRequest::setRequestPattern(RequestPattern pattern) {
  28. requestPattern_ = pattern;
  29. }
  30. void CommonRequest::setHttpMethod(HttpRequest::Method method) {
  31. httpMethod_ = method;
  32. }
  33. HttpRequest::Method CommonRequest::httpMethod() const { return httpMethod_; }
  34. CommonRequest::ParameterValueType
  35. CommonRequest::queryParameter(const ParameterNameType &name) const {
  36. ParameterCollection::const_iterator it = queryParams_.find(name);
  37. if (it == queryParams_.end()) {
  38. return ParameterValueType("");
  39. }
  40. return it->second;
  41. }
  42. CommonRequest::ParameterCollection CommonRequest::queryParameters() const {
  43. return queryParams_;
  44. }
  45. void CommonRequest::setQueryParameter(const ParameterNameType &name,
  46. const ParameterValueType &value) {
  47. queryParams_[name] = value;
  48. }
  49. CommonRequest::ParameterValueType
  50. CommonRequest::headerParameter(const ParameterNameType &name) const {
  51. const ParameterCollection::const_iterator it = headerParams_.find(name);
  52. if (it == headerParams_.end()) {
  53. return ParameterValueType("");
  54. }
  55. return it->second;
  56. }
  57. CommonRequest::ParameterCollection CommonRequest::headerParameters() const {
  58. return headerParams_;
  59. }
  60. void CommonRequest::setHeaderParameter(const ParameterNameType &name,
  61. const ParameterValueType &value) {
  62. headerParams_[name] = value;
  63. }
  64. } // namespace AlibabaCloud