My Project
|
00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 #pragma once 00029 00030 #pragma comment( lib, "Wininet.lib" ) 00031 00032 #include "Define.h" 00033 #include <Wininet.h> 00034 #include <string> 00035 #include "SallyHelper.h" 00036 #include "HttpSendRequestThread.h" 00037 00038 namespace SallyAPI 00039 { 00040 namespace Network 00041 { 00047 00048 enum NETWORK_RETURN {SUCCESS, ERROR_PREPARE, ERROR_HTTP_TIMEOUT, ERROR_OPEN, ERROR_NOTHING_READ}; 00049 00058 00059 class DLL_API_SALLY NetworkHelper 00060 { 00061 private: 00062 NetworkHelper(); 00063 ~NetworkHelper(); 00064 public: 00065 static SallyAPI::Network::NETWORK_RETURN GetHTTPText(const std::string& server, int port, 00066 const std::string& request, int* byteRead, std::string* response, const std::string& proxy, 00067 const std::string& proxyBypass, DWORD iFlag = 0, int timeoutSeconds = 10, std::string* headerData = NULL, 00068 std::string* postData = NULL); 00069 static SallyAPI::Network::NETWORK_RETURN GetHTTPContent(const std::string& server, int port, 00070 const std::string& request, int* byteRead, char** response, const std::string& proxy, 00071 const std::string& proxyBypass, DWORD iFlag = 0, int timeoutSeconds = 10, std::string* headerData = NULL, 00072 std::string* postData = NULL); 00073 static SallyAPI::Network::NETWORK_RETURN GetFileContent(const std::string& server, int port, 00074 const std::string& request, int* byteRead, HANDLE hFile, const std::string& proxy, 00075 const std::string& proxyBypass, DWORD iFlag = 0, int timeoutSeconds = 10, std::string* headerData = NULL, 00076 std::string* postData = NULL); 00077 static std::string URLEncode(const std::string& stringToEncode); 00078 static std::string URLDecode(const std::string& stringToDecode); 00079 static std::string HTMLEncode(const std::string& stringToEncode); 00080 static bool DownloadFile(const std::string& server, int port, const std::string& request, const std::string& imageFile, const std::string& proxy, const std::string& proxyBypass); 00081 static void GetHeaderData(HINTERNET httpRequest, std::string* headerData); 00082 static void OpenURL(const std::string& url); 00083 }; 00084 } 00085 }