8 #ifndef _INC_cWinHttp_H
9 #define _INC_cWinHttp_H
10 #ifndef NO_PRAGMA_ONCE
14 #include "../Net/cNetAddr.h"
15 #include "../Http/cHttpCommon.h"
27 class cWinHttpSession;
28 class cWinHttpConnection;
42 : m_h(INVALID_HANDLE_VALUE)
50 void AttachHandle(HINTERNET h)
60 bool isValidHandle()
const
62 return m_h !=
HANDLE_NULL && m_h != INVALID_HANDLE_VALUE ;
64 HINTERNET get_Handle()
const
68 virtual cWinHttpSession* GetSession()
const = 0;
79 typedef cWinHttpBase SUPER_t;
81 cWinHttpRequest(cWinHttpConnection* pConnection,
HTTPVERB_TYPE nVerb, LPCWSTR pstrObjectName,
82 IN LPCWSTR pwszReferrer, IN LPCWSTR FAR * ppwszAcceptTypes, DWORD dwFlags = 0);
83 virtual cWinHttpSession* GetSession()
const;
86 bool ReceiveResponse();
89 cWinHttpConnection* m_pConnection;
91 typedef cRefPtr<cWinHttpRequest> cWinHttpRequestPtr;
102 typedef cWinHttpBase SUPER_t;
104 cWinHttpConnection(cWinHttpSession* pSession,
105 LPCWSTR pstrServer,
NET_PORT_t nPort = k_NET_PORT_INVALID,
107 ~cWinHttpConnection();
109 cWinHttpRequestPtr OpenRequest(
HTTPVERB_TYPE nVerb, LPCWSTR pstrObjectName, IN LPCWSTR pwszReferrer, IN LPCWSTR FAR * ppwszAcceptTypes, DWORD dwFlags = 0);
111 virtual cWinHttpSession* GetSession()
const
119 return m_strServerName;
123 cWinHttpSession* m_pSession;
128 typedef cRefPtr<cWinHttpConnection> cWinHttpConnectionPtr;
132 class GRAYLIB_LINK cWinHttpSession :
public cWinHttpBase
138 typedef cWinHttpBase SUPER_t;
139 friend class cWinHttpRequest;
140 friend class cWinHttpSession;
143 cWinHttpSession(LPCWSTR pstrAgent =
nullptr,
144 DWORD dwAccessType = WINHTTP_ACCESS_TYPE_DEFAULT_PROXY,
145 IN LPCWSTR pwszProxyName = WINHTTP_NO_PROXY_NAME,
146 IN LPCWSTR pwszProxyBypass = WINHTTP_NO_PROXY_BYPASS,
147 IN DWORD dwFlags = 0);
150 cWinHttpConnectionPtr GetHttpConnection(LPCWSTR pstrServer,
151 NET_PORT_t nPort = k_NET_PORT_INVALID, DWORD dwFlags = 0);
153 bool EnableStatusCallback(
bool bEnable =
true);
155 virtual cWinHttpSession* GetSession()
const
157 return const_cast<cWinHttpSession*
>(
this);
161 virtual void OnStatusCallback(cWinHttpBase* pContext, DWORD dwInternetStatus,
162 LPVOID lpvStatusInformation, DWORD dwStatusInformationLength);
168 static void CALLBACK OnStatusCallbackStatic(IN HINTERNET hInternet,
169 IN DWORD_PTR dwContext,
170 IN DWORD dwInternetStatus,
171 IN LPVOID lpvStatusInformation OPTIONAL,
172 IN DWORD dwStatusInformationLength);
175 bool m_bCallbackEnabled;
179 :
public cWinHttpSession
184 typedef cWinHttpSession SUPER_t;
190 virtual cStringA get_ConnectName()
const override;
194 virtual void OnStatusCallback(cWinHttpBase* pContext, DWORD dwInternetStatus,
195 LPVOID lpvStatusInformation, DWORD dwStatusInformationLength);
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
#define HANDLE_NULL
Invalid OS handle for _WIN32. Not invalid OS handle for linux.
Definition: cOSHandle.h:21
WORD NET_PORT_t
WinINet calls ports NET_PORT_t INTERNET_PORT = a service.
Definition: cNetPort.h:21
HTTPVERB_TYPE
Definition: cHttpCommon.h:36
UNITTEST2_PREDEF(cQuadtree)
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
cStringT< char > cStringA
Definition: cString.h:635
cString CString
Definition: cString.h:639
UINT64 FILE_SIZE_t
similar to STREAM_POS_t size_t
Definition: cFileStatus.h:31