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