-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathAsyncHttpSample.cpp
More file actions
49 lines (37 loc) · 1020 Bytes
/
Copy pathAsyncHttpSample.cpp
File metadata and controls
49 lines (37 loc) · 1020 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// AsyncHttpSample.cpp : Defines the entry point for the console application.
// Sample on clean and tidy way of making async WinApi http requests
// API used: WinInet
// Not suitable for Windows Server
#include "stdafx.h"
#include <conio.h>
#include "AsyncHttpRequest.h"
#include "AsyncHttpResponse.h"
class AsyncAsyncHttpRequestHost : AsyncHttpRequest::Host
{
public:
AsyncAsyncHttpRequestHost(string aURL)
{
HttpMakeRequest("GET", aURL);
}
~AsyncAsyncHttpRequestHost()
{
}
virtual void OnAsyncHttpRequestComplete(AsyncHttpRequest* apAsyncHttpRequest, DWORD adwResult)
{
printf("Response:\n%s", apAsyncHttpRequest->GetResponse()->GetBody().c_str());
printf("Press any key to continue...");
}
};
int _tmain(int argc, _TCHAR* argv[])
{
printf("AsyncHttpSample - making WinApi async request nice\n");
if(argc < 2)
{
printf("Usage: AsyncHttpSample <URL>");
return 0;
}
printf("GETting %s", argv[1]);
AsyncAsyncHttpRequestHost host(Convert_UTF16_UTF8(argv[1]));
_getch();
return 0;
}