]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_asio_client.h
a595b0351997ba452472c2bf7dd5f9ead1beebcf
[ceph.git] / ceph / src / rgw / rgw_asio_client.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #ifndef RGW_ASIO_CLIENT_H
5 #define RGW_ASIO_CLIENT_H
6
7 #include <boost/asio/ip/tcp.hpp>
8 #include <boost/beast/core.hpp>
9 #include <boost/beast/http.hpp>
10 #include "include/ceph_assert.h"
11
12 #include "rgw_client_io.h"
13
14 namespace rgw {
15 namespace asio {
16
17 namespace beast = boost::beast;
18 using parser_type = beast::http::request_parser<beast::http::buffer_body>;
19
20 class ClientIO : public io::RestfulClient,
21 public io::BuffererSink {
22 protected:
23 parser_type& parser;
24 private:
25 const bool is_ssl;
26 using endpoint_type = boost::asio::ip::tcp::endpoint;
27 endpoint_type local_endpoint;
28 endpoint_type remote_endpoint;
29
30 RGWEnv env;
31
32 rgw::io::StaticOutputBufferer<> txbuf;
33
34 public:
35 ClientIO(parser_type& parser, bool is_ssl,
36 const endpoint_type& local_endpoint,
37 const endpoint_type& remote_endpoint);
38 ~ClientIO() override;
39
40 int init_env(CephContext *cct) override;
41 size_t complete_request() override;
42 void flush() override;
43 size_t send_status(int status, const char *status_name) override;
44 size_t send_100_continue() override;
45 size_t send_header(const std::string_view& name,
46 const std::string_view& value) override;
47 size_t send_content_length(uint64_t len) override;
48 size_t complete_header() override;
49
50 size_t send_body(const char* buf, size_t len) override {
51 return write_data(buf, len);
52 }
53
54 RGWEnv& get_env() noexcept override {
55 return env;
56 }
57 };
58
59 } // namespace asio
60 } // namespace rgw
61
62 #endif // RGW_ASIO_CLIENT_H