]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_os_lib.cc
import ceph pacific 16.2.5
[ceph.git] / ceph / src / rgw / rgw_os_lib.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab ft=cpp
3
4 #include "rgw_rest.h"
5 #include "rgw_rest_s3.h"
6 #include "rgw_rest_user.h"
7 #include "rgw_os_lib.h"
8 #include "rgw_file.h"
9 #include "rgw_lib_frontend.h"
10
11 namespace rgw {
12
13 /* static */
14 int RGWHandler_Lib::init_from_header(rgw::sal::RGWRadosStore *store,
15 struct req_state *s)
16 {
17 string req;
18 string first;
19
20 const char *req_name = s->relative_uri.c_str();
21 const char *p;
22
23 /* skip request_params parsing, rgw_file should not be
24 * seeing any */
25 if (*req_name == '?') {
26 p = req_name;
27 } else {
28 p = s->info.request_params.c_str();
29 }
30
31 s->info.args.set(p);
32 s->info.args.parse(s);
33
34 if (*req_name != '/')
35 return 0;
36
37 req_name++;
38
39 if (!*req_name)
40 return 0;
41
42 req = req_name;
43 int pos = req.find('/');
44 if (pos >= 0) {
45 first = req.substr(0, pos);
46 } else {
47 first = req;
48 }
49
50 if (s->bucket_name.empty()) {
51 s->bucket_name = std::move(first);
52 if (pos >= 0) {
53 // XXX ugh, another copy
54 string encoded_obj_str = req.substr(pos+1);
55 s->object = store->get_object(rgw_obj_key(encoded_obj_str, s->info.args.get("versionId")));
56 }
57 } else {
58 s->object = store->get_object(rgw_obj_key(req_name, s->info.args.get("versionId")));
59 }
60 return 0;
61 } /* init_from_header */
62
63 } /* namespace rgw */