1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
8 #include "rgw_loadgen.h"
9 #include "rgw_auth_s3.h"
12 #define dout_subsys ceph_subsys_rgw
14 void RGWLoadGenRequestEnv::set_date(utime_t& tm)
16 date_str = rgw_to_asctime(tm);
19 int RGWLoadGenRequestEnv::sign(RGWAccessKey& access_key)
21 map<string, string> meta_map;
22 map<string, string> sub_resources;
24 string canonical_header;
27 rgw_create_s3_canonical_header(request_method.c_str(),
28 nullptr, /* const char *content_md5 */
36 headers["HTTP_DATE"] = date_str;
38 /* FIXME(rzarzynski): kill the dependency on g_ceph_context. */
39 const auto signature = static_cast<std::string>(
40 rgw::auth::s3::get_v2_signature(g_ceph_context, canonical_header,
42 headers["HTTP_AUTHORIZATION"] = \
43 std::string("AWS ") + access_key.id + ":" + signature;
51 size_t RGWLoadGenIO::write_data(const char* const buf,
57 size_t RGWLoadGenIO::read_data(char* const buf, const size_t len)
59 const size_t read_len = std::min(left_to_read,
60 static_cast<uint64_t>(len));
61 left_to_read -= read_len;
65 void RGWLoadGenIO::flush()
69 size_t RGWLoadGenIO::complete_request()
74 void RGWLoadGenIO::init_env(CephContext *cct)
78 left_to_read = req->content_length;
81 snprintf(buf, sizeof(buf), "%lld", (long long)req->content_length);
82 env.set("CONTENT_LENGTH", buf);
84 env.set("CONTENT_TYPE", req->content_type.c_str());
85 env.set("HTTP_DATE", req->date_str.c_str());
87 for (map<string, string>::iterator iter = req->headers.begin(); iter != req->headers.end(); ++iter) {
88 env.set(iter->first.c_str(), iter->second.c_str());
91 env.set("REQUEST_METHOD", req->request_method.c_str());
92 env.set("REQUEST_URI", req->uri.c_str());
93 env.set("QUERY_STRING", req->query_string.c_str());
94 env.set("SCRIPT_URI", req->uri.c_str());
97 snprintf(port_buf, sizeof(port_buf), "%d", req->port);
98 env.set("SERVER_PORT", port_buf);
101 size_t RGWLoadGenIO::send_status(const int status,
102 const char* const status_name)
107 size_t RGWLoadGenIO::send_100_continue()
112 size_t RGWLoadGenIO::send_header(const boost::string_ref& name,
113 const boost::string_ref& value)
118 size_t RGWLoadGenIO::complete_header()
123 size_t RGWLoadGenIO::send_content_length(const uint64_t len)