-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHttpConnect.h
More file actions
56 lines (42 loc) · 1.2 KB
/
HttpConnect.h
File metadata and controls
56 lines (42 loc) · 1.2 KB
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
49
50
51
52
53
54
55
56
#pragma once
#include <Windows.h>
#include <string>
#include <sstream>
#include <stdexcept>
#include <map>
#include <winhttp.h>
#pragma comment(lib, "WinHTTP.lib")
#pragma hdrstop
#include "Request.h"
#include "Response.h"
/*
int main() {
// Create an instance of WinHttpWrapper
CHttpConnect wrapper;
// Send a GET request to example.com and print the response
std::wstring url = L"https://jsonplaceholder.typicode.com/posts/1";
CRequest request(L"GET", url, L"", {});
CResponse response = wrapper.SendRequest(request);
std::cout << "Status code: " << response.GetStatusCode() << std::endl;
std::cout << "Headers:" << std::endl;
for (const auto& header : response.GetHeaders()) {
std::wcout << header.first << L": " << header.second << std::endl;
}
std::wcout << L"Response body: " << response.GetBody() << std::endl;
return 0;
}
*/
#ifdef WINSYSHTTP_EXPORTS
#define WINSYSHTTP_API __declspec(dllexport)
#else
#define WINSYSHTTP_API __declspec(dllimport)
#endif
class WINSYSHTTP_API CHttpConnect
{
public:
CHttpConnect();
virtual ~CHttpConnect();
virtual CResponse SendRequest(const CRequest& request);
private:
HINTERNET session_;
};