]>
git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_asio_client.h
038be51411c6a443bece5459fe878ab0e69880cf
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
6 #include <boost/asio/ip/tcp.hpp>
7 #include <boost/beast/core.hpp>
8 #include <boost/beast/http.hpp>
9 #include "include/assert.h"
11 #include "rgw_client_io.h"
16 namespace beast
= boost::beast
;
17 using parser_type
= beast::http::request_parser
<beast::http::buffer_body
>;
19 class ClientIO
: public io::RestfulClient
,
20 public io::BuffererSink
{
22 using tcp
= boost::asio::ip::tcp
;
25 beast::flat_buffer
& buffer
; //< parse buffer
29 rgw::io::StaticOutputBufferer
<> txbuf
;
31 size_t write_data(const char *buf
, size_t len
) override
;
32 size_t read_data(char *buf
, size_t max
);
35 ClientIO(tcp::socket
& socket
, parser_type
& parser
,
36 beast::flat_buffer
& buffer
);
39 void init_env(CephContext
*cct
) override
;
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
;
49 size_t recv_body(char* buf
, size_t max
) override
{
50 return read_data(buf
, max
);
53 size_t send_body(const char* buf
, size_t len
) override
{
54 return write_data(buf
, len
);
57 RGWEnv
& get_env() noexcept override
{
65 #endif // RGW_ASIO_CLIENT_H