#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_rgw
-int RGWRESTSimpleRequest::get_status()
+int RGWHTTPSimpleRequest::get_status()
{
int retcode = get_req_retcode();
if (retcode < 0) {
return status;
}
-int RGWRESTSimpleRequest::handle_header(const string& name, const string& val)
+int RGWHTTPSimpleRequest::handle_header(const string& name, const string& val)
{
if (name == "CONTENT_LENGTH") {
string err;
return 0;
}
-int RGWRESTSimpleRequest::receive_header(void *ptr, size_t len)
+int RGWHTTPSimpleRequest::receive_header(void *ptr, size_t len)
{
char line[len + 1];
return status;
}
-int RGWRESTSimpleRequest::send_data(void *ptr, size_t len)
+int RGWHTTPSimpleRequest::send_data(void *ptr, size_t len)
{
if (!send_iter)
return 0;
return len;
}
-int RGWRESTSimpleRequest::receive_data(void *ptr, size_t len)
+int RGWHTTPSimpleRequest::receive_data(void *ptr, size_t len)
{
size_t cp_len, left_len;
}
-void RGWRESTSimpleRequest::append_param(string& dest, const string& name, const string& val)
+void RGWHTTPSimpleRequest::append_param(string& dest, const string& name, const string& val)
{
if (dest.empty()) {
dest.append("?");
}
}
-void RGWRESTSimpleRequest::get_params_str(map<string, string>& extra_args, string& dest)
+void RGWHTTPSimpleRequest::get_params_str(map<string, string>& extra_args, string& dest)
{
map<string, string>::iterator miter;
for (miter = extra_args.begin(); miter != extra_args.end(); ++miter) {
}
}
-int RGWRESTSimpleRequest::sign_request(RGWAccessKey& key, RGWEnv& env, req_info& info)
+static int sign_request(CephContext *cct, RGWAccessKey& key, RGWEnv& env, req_info& info)
{
/* don't sign if no key is provided */
if (key.key.empty()) {
new_env.set("HTTP_DATE", date_str.c_str());
- int ret = sign_request(key, new_env, new_info);
+ int ret = sign_request(cct, key, new_env, new_info);
if (ret < 0) {
ldout(cct, 0) << "ERROR: failed to sign request" << dendl;
return ret;
grants_by_type_add_perm(grants_by_type, perm.get_permissions(), grant);
}
add_grants_headers(grants_by_type, new_env, new_info.x_meta_map);
- ret = sign_request(key, new_env, new_info);
+ ret = sign_request(cct, key, new_env, new_info);
if (ret < 0) {
ldout(cct, 0) << "ERROR: failed to sign request" << dendl;
return ret;
new_info.init_meta_info(NULL);
if (key) {
- int ret = sign_request(*key, new_env, new_info);
+ int ret = sign_request(cct, *key, new_env, new_info);
if (ret < 0) {
ldout(cct, 0) << "ERROR: failed to sign request" << dendl;
return ret;
class RGWGetDataCB;
-class RGWRESTSimpleRequest : public RGWHTTPClient {
+class RGWHTTPSimpleRequest : public RGWHTTPClient {
protected:
int http_status;
int status;
void append_param(string& dest, const string& name, const string& val);
void get_params_str(map<string, string>& extra_args, string& dest);
- int sign_request(RGWAccessKey& key, RGWEnv& env, req_info& info);
public:
- RGWRESTSimpleRequest(CephContext *_cct, const string& _method, const string& _url,
+ RGWHTTPSimpleRequest(CephContext *_cct, const string& _method, const string& _url,
param_vec_t *_headers, param_vec_t *_params) : RGWHTTPClient(_cct, _method, _url),
http_status(0), status(0),
send_iter(NULL),
bufferlist& get_response() { return response; }
- int execute(RGWAccessKey& key, const char *method, const char *resource);
- int forward_request(RGWAccessKey& key, req_info& info, size_t max_response, bufferlist *inbl, bufferlist *outbl);
-
map<string, string>& get_out_headers() { return out_headers; }
int get_http_status() { return http_status; }
int get_status();
};
+class RGWRESTSimpleRequest : public RGWHTTPSimpleRequest {
+public:
+ RGWRESTSimpleRequest(CephContext *_cct, const string& _method, const string& _url,
+ param_vec_t *_headers, param_vec_t *_params) : RGWHTTPSimpleRequest(_cct, _method, _url, _headers, _params) {}
+
+ int execute(RGWAccessKey& key, const char *method, const char *resource);
+ int forward_request(RGWAccessKey& key, req_info& info, size_t max_response, bufferlist *inbl, bufferlist *outbl);
+};
+
class RGWRESTStreamWriteRequest : public RGWRESTSimpleRequest {
Mutex lock;
RGWGetDataCB *get_out_cb() { return cb; }
};
-class RGWHTTPStreamRWRequest : public RGWRESTSimpleRequest {
+class RGWHTTPStreamRWRequest : public RGWHTTPSimpleRequest {
Mutex lock;
Mutex write_lock;
RGWGetDataCB *cb;
int receive_data(void *ptr, size_t len) override;
RGWHTTPStreamRWRequest(CephContext *_cct, const string& _method, const string& _url, RGWGetDataCB *_cb,
- param_vec_t *_headers, param_vec_t *_params) : RGWRESTSimpleRequest(_cct, _method, _url, _headers, _params),
- lock("RGWRESTStreamRWRequest"), write_lock("RGWRESTStreamRWRequest::write_lock"), cb(_cb) {
+ param_vec_t *_headers, param_vec_t *_params) : RGWHTTPSimpleRequest(_cct, _method, _url, _headers, _params),
+ lock("RGWHTTPStreamRWRequest"), write_lock("RGWHTTPStreamRWRequest::write_lock"), cb(_cb) {
}
virtual ~RGWHTTPStreamRWRequest() override {}