-
Notifications
You must be signed in to change notification settings - Fork 5
/
httpreader.h
54 lines (42 loc) · 1.15 KB
/
httpreader.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
49
50
51
52
53
54
#ifndef HTTPREADER_H
#define HTTPREADER_H
#include <boost/beast/core.hpp>
#include <boost/beast/http.hpp>
#include <boost/beast/version.hpp>
#include <boost/asio/ssl/error.hpp>
#include <boost/asio/ssl/stream.hpp>
#include <boost/asio/ip/tcp.hpp>
#include <string>
namespace beast = boost::beast; // from <boost/beast.hpp>
namespace http = boost::beast::http; // from <boost/beast/http.hpp>
namespace net = boost::asio; // from <boost/asio.hpp>
namespace ssl = net::ssl; // from <boost/asio/ssl.hpp>
using namespace std;
using tcp = boost::asio::ip::tcp; // from <boost/asio/ip/tcp.hpp>
class HttpReader
{
private:
string httpAddress;
string m_scheme;
string m_user;
string m_host;
string m_port;
string m_path;
string m_query;
string m_fragment;
bool m_isSSL;
tcp::socket *m_stream;
time_t m_lastConnectionTime;
beast::flat_buffer m_buffer;
net::io_context m_ioc;
bool parseUri(const string &uri);
bool connectSSL();
string readSSL();
public:
HttpReader(string uri);
~HttpReader();
bool connect();
void close();
string read();
};
#endif // HTTPREADER_H