-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathWinWebClientPlugin.h
48 lines (44 loc) · 1.02 KB
/
WinWebClientPlugin.h
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#ifndef __WINWEBCLIENTPLUGIN_H__
#define __WINWEBCLIENTPLUGIN_H__
#include <TCFoundation/TCWebClient.h>
#include <winhttp.h>
class WinWebClientPlugin: public TCWebClient::Plugin
{
public:
WinWebClientPlugin(void);
virtual bool isSupportedURLScheme(const char* urlScheme);
virtual TCByte* fetchURL(const char* url, int& length, TCWebClient* webClient);
static void registerPlugin(void);
private:
class HttpHandle
{
public:
HttpHandle() : handle(NULL) {}
HttpHandle(HINTERNET handle) : handle(handle) {}
~HttpHandle()
{
release();
}
bool isValid() { return handle != NULL; }
HINTERNET get() { return handle; }
void release()
{
if (handle != NULL)
{
WinHttpCloseHandle(handle);
handle = NULL;
}
}
void acquire(HINTERNET value)
{
release();
handle = value;
}
private:
HINTERNET handle;
};
bool openSession(TCWebClient* webClient);
static WinWebClientPlugin* plugin;
HttpHandle hSession;
};
#endif // __WINWEBCLIENTPLUGIN_H__