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.

41 lines
1.0 KiB
C

#ifndef WEBCC_HTTP_CLIENT_H_
#define WEBCC_HTTP_CLIENT_H_
8 years ago
#include "webcc/http_client_base.h"
8 years ago
namespace webcc {
8 years ago
// HTTP client in synchronous mode.
// A request will not return until the response is received or timeout occurs.
// Don't use the same HttpClient object in multiple threads.
class HttpClient : public HttpClientBase {
public:
explicit HttpClient(std::size_t buffer_size = 0);
7 years ago
~HttpClient() = default;
WEBCC_DELETE_COPY_ASSIGN(HttpClient);
private:
Error Connect(const HttpRequest& request) final {
return DoConnect(request, kHttpPort);
}
7 years ago
void SocketConnect(const Endpoints& endpoints,
boost::system::error_code* ec) final;
7 years ago
void SocketWrite(const HttpRequest& request,
boost::system::error_code* ec) final;
void SocketAsyncReadSome(std::vector<char>& buffer,
ReadHandler handler) final;
8 years ago
void SocketClose(boost::system::error_code* ec) final;
7 years ago
boost::asio::ip::tcp::socket socket_;
8 years ago
};
} // namespace webcc
8 years ago
#endif // WEBCC_HTTP_CLIENT_H_