]> git.proxmox.com Git - ceph.git/blob - ceph/src/rgw/rgw_rest_s3website.h
update sources to ceph Nautilus 14.2.1
[ceph.git] / ceph / src / rgw / rgw_rest_s3website.h
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 /*
5 * Ceph - scalable distributed file system
6 *
7 * Copyright (C) 2015 Robin H. Johnson <robin.johnson@dreamhost.com>
8 *
9 * This is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License version 2.1, as published by the Free Software
12 * Foundation. See file COPYING.
13 *
14 */
15
16 #ifndef CEPH_RGW_REST_S3WEBSITE_H
17 #define CEPH_RGW_REST_S3WEBSITE_H
18
19 #include "rgw_rest_s3.h"
20
21 class RGWHandler_REST_S3Website : public RGWHandler_REST_S3 {
22 std::string original_object_name; // object name before retarget()
23 bool web_dir() const;
24 protected:
25 int retarget(RGWOp *op, RGWOp **new_op) override;
26 // TODO: this should be virtual I think, and ensure that it's always
27 // overridden, but that conflates that op_get/op_head are defined in this
28 // class and call this; and don't need to be overridden later.
29 virtual RGWOp *get_obj_op(bool get_data) { return NULL; }
30 RGWOp *op_get() override;
31 RGWOp *op_head() override;
32 // Only allowed to use GET+HEAD
33 RGWOp *op_put() override { return NULL; }
34 RGWOp *op_delete() override { return NULL; }
35 RGWOp *op_post() override { return NULL; }
36 RGWOp *op_copy() override { return NULL; }
37 RGWOp *op_options() override { return NULL; }
38
39 int serve_errordoc(int http_ret, const string &errordoc_key);
40 public:
41 using RGWHandler_REST_S3::RGWHandler_REST_S3;
42 ~RGWHandler_REST_S3Website() override = default;
43
44 int init(RGWRados *store, req_state *s, rgw::io::BasicClient* cio) override;
45 int error_handler(int err_no, string *error_content) override;
46 };
47
48 class RGWHandler_REST_Service_S3Website : public RGWHandler_REST_S3Website {
49 protected:
50 RGWOp *get_obj_op(bool get_data) override;
51 public:
52 using RGWHandler_REST_S3Website::RGWHandler_REST_S3Website;
53 ~RGWHandler_REST_Service_S3Website() override = default;
54 };
55
56 class RGWHandler_REST_Obj_S3Website : public RGWHandler_REST_S3Website {
57 protected:
58 RGWOp *get_obj_op(bool get_data) override;
59 public:
60 using RGWHandler_REST_S3Website::RGWHandler_REST_S3Website;
61 ~RGWHandler_REST_Obj_S3Website() override = default;
62 };
63
64 /* The cross-inheritance from Obj to Bucket is deliberate!
65 * S3Websites do NOT support any bucket operations
66 */
67 class RGWHandler_REST_Bucket_S3Website : public RGWHandler_REST_S3Website {
68 protected:
69 RGWOp *get_obj_op(bool get_data) override;
70 public:
71 using RGWHandler_REST_S3Website::RGWHandler_REST_S3Website;
72 ~RGWHandler_REST_Bucket_S3Website() override = default;
73 };
74
75 // TODO: do we actually need this?
76 class RGWGetObj_ObjStore_S3Website : public RGWGetObj_ObjStore_S3
77 {
78 friend class RGWHandler_REST_S3Website;
79 private:
80 bool is_errordoc_request;
81 public:
82 RGWGetObj_ObjStore_S3Website() : is_errordoc_request(false) {}
83 explicit RGWGetObj_ObjStore_S3Website(bool is_errordoc_request) : is_errordoc_request(false) { this->is_errordoc_request = is_errordoc_request; }
84 ~RGWGetObj_ObjStore_S3Website() override {}
85 int send_response_data_error() override;
86 int send_response_data(bufferlist& bl, off_t ofs, off_t len) override;
87 // We override RGWGetObj_ObjStore::get_params here, to allow ignoring all
88 // conditional params for error pages.
89 int get_params() override {
90 if (is_errordoc_request) {
91 range_str = NULL;
92 if_mod = NULL;
93 if_unmod = NULL;
94 if_match = NULL;
95 if_nomatch = NULL;
96 return 0;
97 } else {
98 return RGWGetObj_ObjStore_S3::get_params();
99 }
100 }
101 };
102
103 #endif