123456789101112131415161718192021222324252627282930313233343536 |
- #pragma once
- #include <afxinet.h>
- #include <string>
- #include "IInputFiled.h"
- #include <vector>
- using namespace std;
- #define IE_AGENT _T("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)")
- class CHttpClient
- {
- public:
- enum {SUCCESS=0,FAILURE =1,OUTTIME=2};
- public:
- CHttpClient(LPCTSTR strAgent = IE_AGENT);
- virtual ~CHttpClient(void);
- int HttpGet(LPCTSTR strUrl, LPCTSTR strPostData, string &strResponse);
- int HttpPost(LPCTSTR strUrl, LPCTSTR strPostData, string &strResponse);
- int HttpPostFile(LPCTSTR strUrl,std::vector<CInputFiled*>& inputs,string &strResponse);
- int HttpDownload( LPCTSTR url, LPCTSTR post_data, std::vector<char> &data );
- private:
- int ExecuteRequest(LPCTSTR strMethod, LPCTSTR strUrl, LPCTSTR strPostData, string &strResponse);
- void Clear();
- private:
- CInternetSession *m_pSession;
- CHttpConnection *m_pConnection;
- CHttpFile *m_pHttpFile;
- public:
- int SetSendHeader(CString send);
- private:
- CString MySendHeader;
- };
|