return state->exists;
}
+int RGWHandler_REST_S3Website::init(RGWRados *store, req_state *s,
+ RGWClientIO* cio)
+{
+ // save the original object name before retarget() replaces it with the
+ // result of get_effective_key(). the error_handler() needs the original
+ // object name for redirect handling
+ original_object_name = s->object.name;
+
+ return RGWHandler_REST_S3::init(store, s, cio);
+}
+
int RGWHandler_REST_S3Website::retarget(RGWOp* op, RGWOp** new_op) {
*new_op = op;
ldout(s->cct, 10) << __func__ << "Starting retarget" << dendl;
RGWBWRoutingRule rrule;
bool should_redirect =
- s->bucket_info.website_conf.should_redirect(s->object.name, http_error_code,
- &rrule);
+ s->bucket_info.website_conf.should_redirect(original_object_name,
+ http_error_code, &rrule);
if (should_redirect) {
const string& hostname = s->info.env->get("HTTP_HOST", "");
const string& protocol =
(s->info.env->get("SERVER_PORT_SECURE") ? "https" : "http");
int redirect_code = 0;
- rrule.apply_rule(protocol, hostname, s->object.name, &s->redirect,
- &redirect_code);
+ rrule.apply_rule(protocol, hostname, original_object_name,
+ &s->redirect, &redirect_code);
// Apply a custom HTTP response code
if (redirect_code > 0)
s->err.http_ret = redirect_code; // Apply a custom HTTP response code
#include "rgw_rest_s3.h"
class RGWHandler_REST_S3Website : public RGWHandler_REST_S3 {
+ std::string original_object_name; // object name before retarget()
bool web_dir() const;
protected:
int retarget(RGWOp *op, RGWOp **new_op);
public:
RGWHandler_REST_S3Website() : RGWHandler_REST_S3() {}
virtual ~RGWHandler_REST_S3Website() {}
+ int init(RGWRados *store, req_state *s, RGWClientIO* cio) override;
virtual int error_handler(int err_no, string *error_content);
};