You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
913 B
C++

#include "webcc/http_client.h"
8 years ago
#include "boost/asio/connect.hpp"
#include "boost/asio/read.hpp"
#include "boost/asio/write.hpp"
namespace webcc {
HttpClient::HttpClient(std::size_t buffer_size)
: HttpClientBase(buffer_size), socket_(io_context_) {
}
void HttpClient::SocketConnect(const Endpoints& endpoints,
boost::system::error_code* ec) {
boost::asio::connect(socket_, endpoints, *ec);
7 years ago
}
void HttpClient::SocketWrite(const HttpRequest& request,
boost::system::error_code* ec) {
boost::asio::write(socket_, request.ToBuffers(), *ec);
}
void HttpClient::SocketAsyncReadSome(std::vector<char>& buffer,
ReadHandler handler) {
socket_.async_read_some(boost::asio::buffer(buffer), handler);
}
void HttpClient::SocketClose(boost::system::error_code* ec) {
socket_.close(*ec);
}
} // namespace webcc