-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathConnection.cpp
More file actions
36 lines (32 loc) · 807 Bytes
/
Connection.cpp
File metadata and controls
36 lines (32 loc) · 807 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
#include "Connection.h"
#include <exception>
Connection::Connection(const std::string& other_url, std::stringstream& stream)
: url(other_url), streamhandle(stream)
{
try
{
resolve_connection();
}
catch (cURLpp::RuntimeError& e)
{
std::cerr << e.what() << " at " << url << '\n';
}
catch (cURLpp::LogicError& e)
{
std::cerr << e.what() << " at " << url << '\n';
}
}
void Connection::resolve_connection()
{
cURLpp::Easy socket;
socket.setOpt(new curlpp::options::SslVerifyPeer(false));
cURLpp::options::WriteStream write(&streamhandle);
socket.setOpt(write);
if (Manager::instance().Config->show_http)
{
socket.setOpt(new cURLpp::options::Verbose(true));
}
socket.setOpt(new cURLpp::options::FollowLocation(true));
socket.setOpt(cURLpp::options::Url(url));
socket.perform();
}