MiddleWares_YiHe 郑州颐和医院随访系统中间件

CHttpUtil.h 811B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include<string>
  3. using namespace std;
  4. #define USE_OPENSSL
  5. #define CURL_STATICLIB
  6. #include"../3rd/curl/include/curl/curl.h"
  7. #pragma comment(lib, "ws2_32.lib")
  8. #pragma comment(lib, "wldap32.lib")
  9. #pragma comment(lib, "../3rd/curl/lib/libcurl.lib")
  10. #pragma comment(lib, "../3rd/curl/lib/libcurl_a.lib")
  11. class CHttpUtil
  12. {
  13. SINGLETON_DECLARE(CHttpUtil)
  14. public:
  15. // http GET
  16. CURLcode curl_get_req(const std::string &url, std::string &response);
  17. // http POST
  18. CURLcode curl_post_req(const string &url, const string &postParams, string &response);
  19. private:
  20. CHttpUtil();
  21. ~CHttpUtil();
  22. // reply of the requery
  23. static size_t req_reply(void *ptr, size_t size, size_t nmemb, void *stream);
  24. string GBKToUTF8(const std::string& strGBK);
  25. string UTF8ToGBK(const std::string& strUTF8);
  26. };