]>
Commit | Line | Data |
---|---|---|
7c673cae | 1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
9f95a23c | 2 | // vim: ts=8 sw=2 smarttab ft=cpp |
11fdf7f2 | 3 | |
7c673cae FG |
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 | |
1e59de90 | 11 | * License version 2.1, as published by the Free Software |
7c673cae | 12 | * Foundation. See file COPYING. |
1e59de90 | 13 | * |
7c673cae | 14 | */ |
11fdf7f2 | 15 | |
9f95a23c | 16 | #pragma once |
1e59de90 | 17 | |
7c673cae FG |
18 | #include "rgw_rest_s3.h" |
19 | ||
20 | class RGWHandler_REST_S3Website : public RGWHandler_REST_S3 { | |
94b18763 | 21 | std::string original_object_name; // object name before retarget() |
224ce89b | 22 | bool web_dir() const; |
7c673cae | 23 | protected: |
f67539c2 | 24 | int retarget(RGWOp *op, RGWOp **new_op, optional_yield y) override; |
7c673cae FG |
25 | // TODO: this should be virtual I think, and ensure that it's always |
26 | // overridden, but that conflates that op_get/op_head are defined in this | |
27 | // class and call this; and don't need to be overridden later. | |
28 | virtual RGWOp *get_obj_op(bool get_data) { return NULL; } | |
29 | RGWOp *op_get() override; | |
30 | RGWOp *op_head() override; | |
31 | // Only allowed to use GET+HEAD | |
32 | RGWOp *op_put() override { return NULL; } | |
33 | RGWOp *op_delete() override { return NULL; } | |
34 | RGWOp *op_post() override { return NULL; } | |
35 | RGWOp *op_copy() override { return NULL; } | |
36 | RGWOp *op_options() override { return NULL; } | |
37 | ||
20effc67 | 38 | int serve_errordoc(const DoutPrefixProvider *dpp, int http_ret, const std::string &errordoc_key, optional_yield y); |
7c673cae FG |
39 | public: |
40 | using RGWHandler_REST_S3::RGWHandler_REST_S3; | |
41 | ~RGWHandler_REST_S3Website() override = default; | |
94b18763 | 42 | |
1e59de90 | 43 | int init(rgw::sal::Driver* driver, req_state *s, rgw::io::BasicClient* cio) override; |
20effc67 | 44 | int error_handler(int err_no, std::string *error_content, optional_yield y) override; |
7c673cae FG |
45 | }; |
46 | ||
47 | class RGWHandler_REST_Service_S3Website : public RGWHandler_REST_S3Website { | |
48 | protected: | |
49 | RGWOp *get_obj_op(bool get_data) override; | |
50 | public: | |
51 | using RGWHandler_REST_S3Website::RGWHandler_REST_S3Website; | |
52 | ~RGWHandler_REST_Service_S3Website() override = default; | |
53 | }; | |
54 | ||
55 | class RGWHandler_REST_Obj_S3Website : public RGWHandler_REST_S3Website { | |
56 | protected: | |
57 | RGWOp *get_obj_op(bool get_data) override; | |
58 | public: | |
59 | using RGWHandler_REST_S3Website::RGWHandler_REST_S3Website; | |
60 | ~RGWHandler_REST_Obj_S3Website() override = default; | |
61 | }; | |
62 | ||
63 | /* The cross-inheritance from Obj to Bucket is deliberate! | |
64 | * S3Websites do NOT support any bucket operations | |
65 | */ | |
66 | class RGWHandler_REST_Bucket_S3Website : public RGWHandler_REST_S3Website { | |
67 | protected: | |
68 | RGWOp *get_obj_op(bool get_data) override; | |
69 | public: | |
70 | using RGWHandler_REST_S3Website::RGWHandler_REST_S3Website; | |
71 | ~RGWHandler_REST_Bucket_S3Website() override = default; | |
72 | }; | |
73 | ||
74 | // TODO: do we actually need this? | |
75 | class RGWGetObj_ObjStore_S3Website : public RGWGetObj_ObjStore_S3 | |
76 | { | |
77 | friend class RGWHandler_REST_S3Website; | |
78 | private: | |
79 | bool is_errordoc_request; | |
80 | public: | |
81 | RGWGetObj_ObjStore_S3Website() : is_errordoc_request(false) {} | |
82 | explicit RGWGetObj_ObjStore_S3Website(bool is_errordoc_request) : is_errordoc_request(false) { this->is_errordoc_request = is_errordoc_request; } | |
83 | ~RGWGetObj_ObjStore_S3Website() override {} | |
f67539c2 | 84 | int send_response_data_error(optional_yield y) override; |
7c673cae FG |
85 | int send_response_data(bufferlist& bl, off_t ofs, off_t len) override; |
86 | // We override RGWGetObj_ObjStore::get_params here, to allow ignoring all | |
87 | // conditional params for error pages. | |
f67539c2 | 88 | int get_params(optional_yield y) override { |
7c673cae FG |
89 | if (is_errordoc_request) { |
90 | range_str = NULL; | |
91 | if_mod = NULL; | |
92 | if_unmod = NULL; | |
93 | if_match = NULL; | |
94 | if_nomatch = NULL; | |
95 | return 0; | |
96 | } else { | |
f67539c2 | 97 | return RGWGetObj_ObjStore_S3::get_params(y); |
7c673cae FG |
98 | } |
99 | } | |
100 | }; |