]> git.proxmox.com Git - ceph.git/blame - ceph/src/rgw/rgw_loadgen.cc
update dh_systemd restart patch for pacific
[ceph.git] / ceph / src / rgw / rgw_loadgen.cc
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
7c673cae
FG
3
4#include <algorithm>
5#include <sstream>
6#include <string.h>
7
8#include "rgw_loadgen.h"
9#include "rgw_auth_s3.h"
10
11
12#define dout_subsys ceph_subsys_rgw
13
14void RGWLoadGenRequestEnv::set_date(utime_t& tm)
15{
c07f9fc5 16 date_str = rgw_to_asctime(tm);
7c673cae
FG
17}
18
19int RGWLoadGenRequestEnv::sign(RGWAccessKey& access_key)
20{
9f95a23c 21 meta_map_t meta_map;
7c673cae
FG
22 map<string, string> sub_resources;
23
24 string canonical_header;
25 string digest;
26
27 rgw_create_s3_canonical_header(request_method.c_str(),
28 nullptr, /* const char *content_md5 */
29 content_type.c_str(),
30 date_str.c_str(),
31 meta_map,
9f95a23c 32 meta_map_t{},
7c673cae
FG
33 uri.c_str(),
34 sub_resources,
35 canonical_header);
36
31f18b77
FG
37 headers["HTTP_DATE"] = date_str;
38 try {
39 /* FIXME(rzarzynski): kill the dependency on g_ceph_context. */
40 const auto signature = static_cast<std::string>(
41 rgw::auth::s3::get_v2_signature(g_ceph_context, canonical_header,
42 access_key.key));
43 headers["HTTP_AUTHORIZATION"] = \
44 std::string("AWS ") + access_key.id + ":" + signature;
45 } catch (int ret) {
7c673cae
FG
46 return ret;
47 }
48
7c673cae
FG
49 return 0;
50}
51
52size_t RGWLoadGenIO::write_data(const char* const buf,
53 const size_t len)
54{
55 return len;
56}
57
58size_t RGWLoadGenIO::read_data(char* const buf, const size_t len)
59{
60 const size_t read_len = std::min(left_to_read,
61 static_cast<uint64_t>(len));
62 left_to_read -= read_len;
63 return read_len;
64}
65
66void RGWLoadGenIO::flush()
67{
68}
69
70size_t RGWLoadGenIO::complete_request()
71{
72 return 0;
73}
74
3a9019d9 75int RGWLoadGenIO::init_env(CephContext *cct)
7c673cae
FG
76{
77 env.init(cct);
78
79 left_to_read = req->content_length;
80
81 char buf[32];
82 snprintf(buf, sizeof(buf), "%lld", (long long)req->content_length);
83 env.set("CONTENT_LENGTH", buf);
84
85 env.set("CONTENT_TYPE", req->content_type.c_str());
86 env.set("HTTP_DATE", req->date_str.c_str());
87
88 for (map<string, string>::iterator iter = req->headers.begin(); iter != req->headers.end(); ++iter) {
89 env.set(iter->first.c_str(), iter->second.c_str());
90 }
91
92 env.set("REQUEST_METHOD", req->request_method.c_str());
93 env.set("REQUEST_URI", req->uri.c_str());
94 env.set("QUERY_STRING", req->query_string.c_str());
95 env.set("SCRIPT_URI", req->uri.c_str());
96
97 char port_buf[16];
98 snprintf(port_buf, sizeof(port_buf), "%d", req->port);
99 env.set("SERVER_PORT", port_buf);
3a9019d9 100 return 0;
7c673cae
FG
101}
102
103size_t RGWLoadGenIO::send_status(const int status,
104 const char* const status_name)
105{
106 return 0;
107}
108
109size_t RGWLoadGenIO::send_100_continue()
110{
111 return 0;
112}
113
f67539c2
TL
114size_t RGWLoadGenIO::send_header(const std::string_view& name,
115 const std::string_view& value)
7c673cae
FG
116{
117 return 0;
118}
119
120size_t RGWLoadGenIO::complete_header()
121{
122 return 0;
123}
124
125size_t RGWLoadGenIO::send_content_length(const uint64_t len)
126{
127 return 0;
128}