]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_asio_client.h
import ceph 15.2.10
[ceph.git] / ceph / src / rgw / rgw_asio_client.h
CommitLineData
7c673cae 1// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
9f95a23c 2// vim: ts=8 sw=2 smarttab ft=cpp
11fdf7f2 3
7c673cae
FG
4#ifndef RGW_ASIO_CLIENT_H
5#define RGW_ASIO_CLIENT_H
6
7#include <boost/asio/ip/tcp.hpp>
b32b8144
FG
8#include <boost/beast/core.hpp>
9#include <boost/beast/http.hpp>
11fdf7f2 10#include "include/ceph_assert.h"
7c673cae
FG
11
12#include "rgw_client_io.h"
13
14namespace rgw {
15namespace asio {
16
b32b8144
FG
17namespace beast = boost::beast;
18using parser_type = beast::http::request_parser<beast::http::buffer_body>;
7c673cae
FG
19
20class ClientIO : public io::RestfulClient,
21 public io::BuffererSink {
f64942e4 22 protected:
7c673cae 23 parser_type& parser;
f64942e4
AA
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;
7c673cae 29
7c673cae
FG
30 RGWEnv env;
31
32 rgw::io::StaticOutputBufferer<> txbuf;
33
7c673cae 34 public:
f64942e4
AA
35 ClientIO(parser_type& parser, bool is_ssl,
36 const endpoint_type& local_endpoint,
37 const endpoint_type& remote_endpoint);
7c673cae
FG
38 ~ClientIO() override;
39
3a9019d9 40 int init_env(CephContext *cct) override;
7c673cae
FG
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 boost::string_ref& name,
46 const boost::string_ref& value) override;
47 size_t send_content_length(uint64_t len) override;
48 size_t complete_header() override;
49
7c673cae
FG
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