-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconnection.h
More file actions
35 lines (25 loc) · 734 Bytes
/
connection.h
File metadata and controls
35 lines (25 loc) · 734 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
#pragma once
#include "request.h"
#include "response.h"
#include <vector>
#include <functional>
#include <WS2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
namespace forceinline {
namespace http {
class connection {
public:
connection( std::string_view hostname ) : m_hostname( hostname ) { }
~connection( );
void connect( );
void close( );
void make_request( http::request* request, std::function< void( const http::response& ) > callback = nullptr );
private:
WSADATA m_wsa_data = { };
bool m_connected = false;
std::string m_hostname = { };
SOCKET m_socket = INVALID_SOCKET;
std::vector< char > m_buffer = std::vector< char >( 1024 );
};
} // namespace http
} // namespace forceinline