| 123456789101112131415161718192021222324252627282930313233 |
- #pragma once
- #include<string>
- using namespace std;
- #define USE_OPENSSL
- #define CURL_STATICLIB
- #include"../3rd/curl/include/curl/curl.h"
- #pragma comment(lib, "ws2_32.lib")
- #pragma comment(lib, "wldap32.lib")
- #pragma comment(lib, "../3rd/curl/lib/libcurl.lib")
- #pragma comment(lib, "../3rd/curl/lib/libcurl_a.lib")
- class CHttpUtil
- {
- SINGLETON_DECLARE(CHttpUtil)
- public:
- // http GET
- CURLcode curl_get_req(const std::string &url, std::string &response);
- // http POST
- CURLcode curl_post_req(const string &url, const string &postParams, string &response);
-
- private:
- CHttpUtil();
- ~CHttpUtil();
- // reply of the requery
- static size_t req_reply(void *ptr, size_t size, size_t nmemb, void *stream);
- string GBKToUTF8(const std::string& strGBK);
- string UTF8ToGBK(const std::string& strUTF8);
- };
|