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