file_copy_task.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #pragma once
  2. #include <stdint.h>
  3. #include <map>
  4. #include <string>
  5. #include "Poco/Runnable.h"
  6. #include "cos_defines.h"
  7. #include "util/base_op_util.h"
  8. namespace qcloud_cos {
  9. class FileCopyTask : public Poco::Runnable {
  10. public:
  11. FileCopyTask(const std::string& host,
  12. const std::string& path,
  13. const bool is_https,
  14. const BaseOpUtil& op_util,
  15. uint64_t conn_timeout_in_ms,
  16. uint64_t recv_timeout_in_ms);
  17. ~FileCopyTask() {}
  18. void run();
  19. void CopyTask();
  20. bool IsTaskSuccess() const;
  21. int GetHttpStatus() const;
  22. std::string GetTaskResp() const;
  23. std::map<std::string, std::string> GetRespHeaders() const;
  24. void SetParams(const std::map<std::string, std::string>& params);
  25. void SetHeaders(const std::map<std::string, std::string>& headers);
  26. void SetVerifyCert(bool verify_cert);
  27. void SetCaLocation(const std::string& ca_location);
  28. void SetSslCtxCb(SSLCtxCallback cb, void *data);
  29. std::string GetErrMsg() const { return m_err_msg; }
  30. std::string GetEtag() const { return m_etag; }
  31. std::string GetLastModified() const { return m_last_modified; }
  32. private:
  33. std::string m_host;
  34. std::string m_path;
  35. bool m_is_https;
  36. std::map<std::string, std::string> m_headers;
  37. std::map<std::string, std::string> m_params;
  38. uint64_t m_conn_timeout_in_ms;
  39. uint64_t m_recv_timeout_in_ms;
  40. std::string m_resp;
  41. bool m_is_task_success;
  42. int m_http_status;
  43. std::map<std::string, std::string> m_resp_headers;
  44. std::string m_err_msg;
  45. std::string m_etag;
  46. std::string m_last_modified;
  47. bool m_verify_cert;
  48. std::string m_ca_location;
  49. SSLCtxCallback m_ssl_ctx_cb;
  50. void *m_user_data;
  51. BaseOpUtil m_op_util;
  52. void SendRequestOnce(std::string domain);
  53. };
  54. } // namespace qcloud_cos