forked from JelinYao/HttpInterface
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSocketHttp.h
More file actions
34 lines (31 loc) · 991 Bytes
/
Copy pathSocketHttp.h
File metadata and controls
34 lines (31 loc) · 991 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#pragma once
#include <string>
#include <map>
using std::wstring;
using std::string;
using std::map;
#include <WinSock2.h>
#include "httpHeader.h"
class CHttpSocket
: public ISocketHttp
{
public:
CHttpSocket();
virtual ~CHttpSocket();
virtual bool DownloadFile(LPCWSTR lpUrl, LPCWSTR lpFilePath);
virtual void SetDownloadCallback(IHttpCallback* pCallback, void* pParam);
virtual HttpInterfaceError GetErrorCode() { return m_paramsData.errcode; }
virtual LPCWSTR GetIpAddr()const { return m_strIpAddr.c_str(); }
virtual void FreeInstance() { delete this; }
virtual bool DownloadToMem(LPCWSTR lpUrl, OUT void** ppBuffer, OUT int* nSize);
virtual void AddHeader(LPCSTR key, LPCSTR value);
virtual int GetResponseCode() { return m_nResponseCode; }
protected:
bool InitSocket(const string& strHostName, const WORD sPort);
private:
int m_nResponseCode;
SOCKET m_socket;
wstring m_strIpAddr;
CHttpHeader m_header;
HttpParamsData m_paramsData;
};