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