forked from awwit/httpserverapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClientHttp1.cpp
More file actions
29 lines (21 loc) · 774 Bytes
/
ClientHttp1.cpp
File metadata and controls
29 lines (21 loc) · 774 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
#include "ClientHttp1.h"
namespace HttpClient
{
ClientHttp1::ClientHttp1(Socket::Adapter *sock) : ClientProtocol(sock)
{
}
bool ClientHttp1::sendHeaders(const Http::StatusCode status, std::vector<std::pair<std::string, std::string> > &headers, const std::chrono::milliseconds &timeout, const bool endStream) const
{
std::string out = "HTTP/1.1 " + std::to_string(static_cast<int>(status) ) + "\r\n";
for (auto const &h : headers)
{
out += h.first + ": " + h.second + "\r\n";
}
out += "\r\n";
return this->sock->nonblock_send(out, timeout) > 0;
}
long ClientHttp1::sendData(const void *src, const size_t size, const std::chrono::milliseconds &timeout, const bool endStream) const
{
return this->sock->nonblock_send(src, size, timeout);
}
};