http_sender.h 4.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. // Copyright (c) 2017, Tencent Inc.
  2. // All rights reserved.
  3. //
  4. // Author: sevenyou <sevenyou@tencent.com>
  5. // Created: 07/18/17
  6. // Description:
  7. #ifndef HTTP_SENDER_H
  8. #define HTTP_SENDER_H
  9. #pragma once
  10. #include <stdint.h>
  11. #include <map>
  12. #include <string>
  13. #include "trsf/transfer_handler.h"
  14. namespace qcloud_cos {
  15. class HttpSender {
  16. public:
  17. static int SendRequest(const SharedTransferHandler& handler,
  18. const std::string& http_method,
  19. const std::string& url_str,
  20. const std::map<std::string, std::string>& req_params,
  21. const std::map<std::string, std::string>& req_headers,
  22. const std::string& req_body,
  23. uint64_t conn_timeout_in_ms,
  24. uint64_t recv_timeout_in_ms,
  25. std::map<std::string, std::string>* resp_headers,
  26. std::string* resp_body, std::string* err_msg,
  27. bool is_check_md5 = false,
  28. bool is_verify_cert = true,
  29. const std::string& ca_location = "");
  30. static int SendRequest(const SharedTransferHandler& handler,
  31. const std::string& http_method,
  32. const std::string& url_str,
  33. const std::map<std::string, std::string>& req_params,
  34. const std::map<std::string, std::string>& req_headers,
  35. const std::string& req_body,
  36. uint64_t conn_timeout_in_ms,
  37. uint64_t recv_timeout_in_ms,
  38. std::map<std::string, std::string>* resp_headers,
  39. std::ostream& resp_stream, std::string* err_msg,
  40. bool is_check_md5 = false,
  41. bool is_verify_cert = true,
  42. const std::string& ca_location = "");
  43. static int SendRequest(const SharedTransferHandler& handler,
  44. const std::string& http_method,
  45. const std::string& url_str,
  46. const std::map<std::string, std::string>& req_params,
  47. const std::map<std::string, std::string>& req_headers,
  48. std::istream& is, uint64_t conn_timeout_in_ms,
  49. uint64_t recv_timeout_in_ms,
  50. std::map<std::string, std::string>* resp_headers,
  51. std::string* resp_body, std::string* err_msg,
  52. bool is_check_md5 = false,
  53. bool is_verify_cert = true,
  54. const std::string& ca_location = "");
  55. static int SendRequest(const SharedTransferHandler& handler,
  56. const std::string& http_method,
  57. const std::string& url_str,
  58. const std::map<std::string, std::string>& req_params,
  59. const std::map<std::string, std::string>& req_headers,
  60. std::istream& is, uint64_t conn_timeout_in_ms,
  61. uint64_t recv_timeout_in_ms,
  62. std::map<std::string, std::string>* resp_headers,
  63. std::ostream& resp_stream, std::string* err_msg,
  64. bool is_check_md5 = false,
  65. bool is_verify_cert = true,
  66. const std::string& ca_location = "");
  67. static int SendRequest(const SharedTransferHandler& handler,
  68. const std::string& http_method,
  69. const std::string& url_str,
  70. const std::map<std::string, std::string>& req_params,
  71. const std::map<std::string, std::string>& req_headers,
  72. const std::string& req_body,
  73. uint64_t conn_timeout_in_ms,
  74. uint64_t recv_timeout_in_ms,
  75. std::map<std::string, std::string>* resp_headers,
  76. std::string* xml_err_str, std::ostream& resp_stream,
  77. std::string* err_msg, uint64_t* real_byte,
  78. bool is_check_md5 = false,
  79. bool is_verify_cert = true,
  80. const std::string& ca_location = "");
  81. };
  82. } // namespace qcloud_cos
  83. #endif // HTTP_SENDER_H