HttpClient.h 980 B

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include <afxinet.h>
  3. #include <string>
  4. #include "IInputFiled.h"
  5. #include <vector>
  6. using namespace std;
  7. #define IE_AGENT _T("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)")
  8. class CHttpClient
  9. {
  10. public:
  11. enum {SUCCESS=0,FAILURE =1,OUTTIME=2};
  12. public:
  13. CHttpClient(LPCTSTR strAgent = IE_AGENT);
  14. virtual ~CHttpClient(void);
  15. int HttpGet(LPCTSTR strUrl, LPCTSTR strPostData, string &strResponse);
  16. int HttpPost(LPCTSTR strUrl, LPCTSTR strPostData, string &strResponse);
  17. int HttpPostFile(LPCTSTR strUrl,std::vector<CInputFiled*>& inputs,string &strResponse);
  18. int HttpDownload( LPCTSTR url, LPCTSTR post_data, std::vector<char> &data );
  19. private:
  20. int ExecuteRequest(LPCTSTR strMethod, LPCTSTR strUrl, LPCTSTR strPostData, string &strResponse);
  21. void Clear();
  22. private:
  23. CInternetSession *m_pSession;
  24. CHttpConnection *m_pConnection;
  25. CHttpFile *m_pHttpFile;
  26. public:
  27. int SetSendHeader(CString send);
  28. private:
  29. CString MySendHeader;
  30. };