{"action":"created","comment":{"url":"https://api.github.com/repos/ceph/ceph/pulls/comments/74936478","id":74936478,"diff_hunk":"@@ -1404,6 +1406,83 @@ RGWOp *RGWHandler_REST_Service_SWIFT::op_delete()\n   return NULL;\n }\n \n+static bool is_web_mode(const req_state * const s) {\n+  const boost::string_ref webmode = s->info.env->get(\"HTTP_X_WEB_MODE\", \"\");\n+  return webmode == \"true\";\n+}\n+\n+static bool is_website_req(const req_state * const s)\n+{\n+  /* Static website works only with the GET or HEAD method. Nothing more. */\n+  const std::set<boost::string_ref> ws_methods = { \"GET\", \"HEAD\" };\n+  if (ws_methods.count(s->info.method) == 0) {\n+    return false;\n+  }\n+\n+  /* We also need to handle early failures from the authentication system.\n+   * In such cases req_state::auth_identity may be empty. Website treats them\n+   * the same way as anonymous. */\n+  if (! s->auth_identity) {\n+    return true;\n+  }\n+\n+  /* Swift serves websites only for anonymous requests unless client explicitly\n+   * requested this behaviour by supplying X-Web-Mode HTTP header set to true. */\n+  if (s->auth_identity->is_anonymous() || is_web_mode(s)) {\n+    return true;\n+  }\n+\n+  return false;\n+}\n+\n+RGWOp* RGWHandler_REST_Bucket_SWIFT::get_ws_index_op()\n+{\n+  // retarget to get obj\n+  s->object = s->bucket_info.website_conf.get_swift_index_doc();\n+\n+  auto getop = new RGWGetObj_ObjStore_SWIFT;\n+  getop->set_get_data(true);\n+\n+  return getop;\n+}\n+\n+RGWOp* RGWHandler_REST_Bucket_SWIFT::get_ws_listing_op()\n+{\n+  return nullptr;\n+}\n+\n+int RGWHandler_REST_Bucket_SWIFT::retarget(RGWOp* op, RGWOp** new_op)\n+{\n+  ldout(s->cct, 10) << \"Starting retarget\" << dendl;\n+  RGWOp* op_override = nullptr;\n+\n+  /* In Swift static web content is served if the request is anonymous or\n+   * has W-Web-Mode HTTP header specified to true. */\n+  if (is_website_req(s)) {","path":"src/rgw/rgw_rest_swift.cc","position":null,"original_position":65,"commit_id":"b27f72e83a7d40030691d739d5591091086919e5","original_commit_id":"f615422a1f6a86f165a41ffe71b716e1224a41cb","user":{"login":"yehudasa","id":1036377,"avatar_url":"https://avatars.githubusercontent.com/u/1036377?v=3","gravatar_id":"","url":"https://api.github.com/users/yehudasa","html_url":"https://github.com/yehudasa","followers_url":"https://api.github.com/users/yehudasa/followers","following_url":"https://api.github.com/users/yehudasa/following{/other_user}","gists_url":"https://api.github.com/users/yehudasa/gists{/gist_id}","starred_url":"https://api.github.com/users/yehudasa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yehudasa/subscriptions","organizations_url":"https://api.github.com/users/yehudasa/orgs","repos_url":"https://api.github.com/users/yehudasa/repos","events_url":"https://api.github.com/users/yehudasa/events{/privacy}","received_events_url":"https://api.github.com/users/yehudasa/received_events","type":"User","site_admin":false},"body":"aren't there some prerequisites to do this? e.g., the current endpoint needs to handle static website so that we don't want to call this for every request. Is that handled somewhere else?","created_at":"2016-08-16T13:44:04Z","updated_at":"2016-08-16T13:44:04Z","html_url":"https://github.com/ceph/ceph/pull/9844#discussion_r74936478","pull_request_url":"https://api.github.com/repos/ceph/ceph/pulls/9844","_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph/pulls/comments/74936478"},"html":{"href":"https://github.com/ceph/ceph/pull/9844#discussion_r74936478"},"pull_request":{"href":"https://api.github.com/repos/ceph/ceph/pulls/9844"}}},"pull_request":{"url":"https://api.github.com/repos/ceph/ceph/pulls/9844","id":74606937,"html_url":"https://github.com/ceph/ceph/pull/9844","diff_url":"https://github.com/ceph/ceph/pull/9844.diff","patch_url":"https://github.com/ceph/ceph/pull/9844.patch","issue_url":"https://api.github.com/repos/ceph/ceph/issues/9844","number":9844,"state":"open","locked":false,"title":"rgw: add support for Static Website of Swift API","user":{"login":"rzarzynski","id":1891217,"avatar_url":"https://avatars.githubusercontent.com/u/1891217?v=3","gravatar_id":"","url":"https://api.github.com/users/rzarzynski","html_url":"https://github.com/rzarzynski","followers_url":"https://api.github.com/users/rzarzynski/followers","following_url":"https://api.github.com/users/rzarzynski/following{/other_user}","gists_url":"https://api.github.com/users/rzarzynski/gists{/gist_id}","starred_url":"https://api.github.com/users/rzarzynski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rzarzynski/subscriptions","organizations_url":"https://api.github.com/users/rzarzynski/orgs","repos_url":"https://api.github.com/users/rzarzynski/repos","events_url":"https://api.github.com/users/rzarzynski/events{/privacy}","received_events_url":"https://api.github.com/users/rzarzynski/received_events","type":"User","site_admin":false},"body":"Regression tests are clear.\r\n\r\nCC: @yehudasa, @cbodley ","created_at":"2016-06-21T12:59:50Z","updated_at":"2016-08-16T13:44:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"303a3d2a7b0894dbd5408b4ffac7bd3b5043fd7a","assignee":{"login":"cbodley","id":1928002,"avatar_url":"https://avatars.githubusercontent.com/u/1928002?v=3","gravatar_id":"","url":"https://api.github.com/users/cbodley","html_url":"https://github.com/cbodley","followers_url":"https://api.github.com/users/cbodley/followers","following_url":"https://api.github.com/users/cbodley/following{/other_user}","gists_url":"https://api.github.com/users/cbodley/gists{/gist_id}","starred_url":"https://api.github.com/users/cbodley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbodley/subscriptions","organizations_url":"https://api.github.com/users/cbodley/orgs","repos_url":"https://api.github.com/users/cbodley/repos","events_url":"https://api.github.com/users/cbodley/events{/privacy}","received_events_url":"https://api.github.com/users/cbodley/received_events","type":"User","site_admin":false},"assignees":[{"login":"cbodley","id":1928002,"avatar_url":"https://avatars.githubusercontent.com/u/1928002?v=3","gravatar_id":"","url":"https://api.github.com/users/cbodley","html_url":"https://github.com/cbodley","followers_url":"https://api.github.com/users/cbodley/followers","following_url":"https://api.github.com/users/cbodley/following{/other_user}","gists_url":"https://api.github.com/users/cbodley/gists{/gist_id}","starred_url":"https://api.github.com/users/cbodley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbodley/subscriptions","organizations_url":"https://api.github.com/users/cbodley/orgs","repos_url":"https://api.github.com/users/cbodley/repos","events_url":"https://api.github.com/users/cbodley/events{/privacy}","received_events_url":"https://api.github.com/users/cbodley/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ceph/ceph/pulls/9844/commits","review_comments_url":"https://api.github.com/repos/ceph/ceph/pulls/9844/comments","review_comment_url":"https://api.github.com/repos/ceph/ceph/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ceph/ceph/issues/9844/comments","statuses_url":"https://api.github.com/repos/ceph/ceph/statuses/b27f72e83a7d40030691d739d5591091086919e5","head":{"label":"rzarzynski:wip-rgw-swift-website","ref":"wip-rgw-swift-website","sha":"b27f72e83a7d40030691d739d5591091086919e5","user":{"login":"rzarzynski","id":1891217,"avatar_url":"https://avatars.githubusercontent.com/u/1891217?v=3","gravatar_id":"","url":"https://api.github.com/users/rzarzynski","html_url":"https://github.com/rzarzynski","followers_url":"https://api.github.com/users/rzarzynski/followers","following_url":"https://api.github.com/users/rzarzynski/following{/other_user}","gists_url":"https://api.github.com/users/rzarzynski/gists{/gist_id}","starred_url":"https://api.github.com/users/rzarzynski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rzarzynski/subscriptions","organizations_url":"https://api.github.com/users/rzarzynski/orgs","repos_url":"https://api.github.com/users/rzarzynski/repos","events_url":"https://api.github.com/users/rzarzynski/events{/privacy}","received_events_url":"https://api.github.com/users/rzarzynski/received_events","type":"User","site_admin":false},"repo":{"id":29937571,"name":"ceph","full_name":"rzarzynski/ceph","owner":{"login":"rzarzynski","id":1891217,"avatar_url":"https://avatars.githubusercontent.com/u/1891217?v=3","gravatar_id":"","url":"https://api.github.com/users/rzarzynski","html_url":"https://github.com/rzarzynski","followers_url":"https://api.github.com/users/rzarzynski/followers","following_url":"https://api.github.com/users/rzarzynski/following{/other_user}","gists_url":"https://api.github.com/users/rzarzynski/gists{/gist_id}","starred_url":"https://api.github.com/users/rzarzynski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rzarzynski/subscriptions","organizations_url":"https://api.github.com/users/rzarzynski/orgs","repos_url":"https://api.github.com/users/rzarzynski/repos","events_url":"https://api.github.com/users/rzarzynski/events{/privacy}","received_events_url":"https://api.github.com/users/rzarzynski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/rzarzynski/ceph","description":"Ceph is a distributed object, block, and file storage platform ","fork":true,"url":"https://api.github.com/repos/rzarzynski/ceph","forks_url":"https://api.github.com/repos/rzarzynski/ceph/forks","keys_url":"https://api.github.com/repos/rzarzynski/ceph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rzarzynski/ceph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rzarzynski/ceph/teams","hooks_url":"https://api.github.com/repos/rzarzynski/ceph/hooks","issue_events_url":"https://api.github.com/repos/rzarzynski/ceph/issues/events{/number}","events_url":"https://api.github.com/repos/rzarzynski/ceph/events","assignees_url":"https://api.github.com/repos/rzarzynski/ceph/assignees{/user}","branches_url":"https://api.github.com/repos/rzarzynski/ceph/branches{/branch}","tags_url":"https://api.github.com/repos/rzarzynski/ceph/tags","blobs_url":"https://api.github.com/repos/rzarzynski/ceph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rzarzynski/ceph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rzarzynski/ceph/git/refs{/sha}","trees_url":"https://api.github.com/repos/rzarzynski/ceph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rzarzynski/ceph/statuses/{sha}","languages_url":"https://api.github.com/repos/rzarzynski/ceph/languages","stargazers_url":"https://api.github.com/repos/rzarzynski/ceph/stargazers","contributors_url":"https://api.github.com/repos/rzarzynski/ceph/contributors","subscribers_url":"https://api.github.com/repos/rzarzynski/ceph/subscribers","subscription_url":"https://api.github.com/repos/rzarzynski/ceph/subscription","commits_url":"https://api.github.com/repos/rzarzynski/ceph/commits{/sha}","git_commits_url":"https://api.github.com/repos/rzarzynski/ceph/git/commits{/sha}","comments_url":"https://api.github.com/repos/rzarzynski/ceph/comments{/number}","issue_comment_url":"https://api.github.com/repos/rzarzynski/ceph/issues/comments{/number}","contents_url":"https://api.github.com/repos/rzarzynski/ceph/contents/{+path}","compare_url":"https://api.github.com/repos/rzarzynski/ceph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rzarzynski/ceph/merges","archive_url":"https://api.github.com/repos/rzarzynski/ceph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rzarzynski/ceph/downloads","issues_url":"https://api.github.com/repos/rzarzynski/ceph/issues{/number}","pulls_url":"https://api.github.com/repos/rzarzynski/ceph/pulls{/number}","milestones_url":"https://api.github.com/repos/rzarzynski/ceph/milestones{/number}","notifications_url":"https://api.github.com/repos/rzarzynski/ceph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rzarzynski/ceph/labels{/name}","releases_url":"https://api.github.com/repos/rzarzynski/ceph/releases{/id}","deployments_url":"https://api.github.com/repos/rzarzynski/ceph/deployments","created_at":"2015-01-27T22:12:49Z","updated_at":"2016-02-09T13:55:19Z","pushed_at":"2016-08-16T13:08:13Z","git_url":"git://github.com/rzarzynski/ceph.git","ssh_url":"git@github.com:rzarzynski/ceph.git","clone_url":"https://github.com/rzarzynski/ceph.git","svn_url":"https://github.com/rzarzynski/ceph","homepage":"http://ceph.com","size":167612,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ceph:master","ref":"master","sha":"0b84e0d45d951e3ce66ce2d6683e414e65adee29","user":{"login":"ceph","id":1015767,"avatar_url":"https://avatars.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"repo":{"id":2310495,"name":"ceph","full_name":"ceph/ceph","owner":{"login":"ceph","id":1015767,"avatar_url":"https://avatars.githubusercontent.com/u/1015767?v=3","gravatar_id":"","url":"https://api.github.com/users/ceph","html_url":"https://github.com/ceph","followers_url":"https://api.github.com/users/ceph/followers","following_url":"https://api.github.com/users/ceph/following{/other_user}","gists_url":"https://api.github.com/users/ceph/gists{/gist_id}","starred_url":"https://api.github.com/users/ceph/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ceph/subscriptions","organizations_url":"https://api.github.com/users/ceph/orgs","repos_url":"https://api.github.com/users/ceph/repos","events_url":"https://api.github.com/users/ceph/events{/privacy}","received_events_url":"https://api.github.com/users/ceph/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ceph/ceph","description":"Ceph is a distributed object, block, and file storage platform ","fork":false,"url":"https://api.github.com/repos/ceph/ceph","forks_url":"https://api.github.com/repos/ceph/ceph/forks","keys_url":"https://api.github.com/repos/ceph/ceph/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ceph/ceph/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ceph/ceph/teams","hooks_url":"https://api.github.com/repos/ceph/ceph/hooks","issue_events_url":"https://api.github.com/repos/ceph/ceph/issues/events{/number}","events_url":"https://api.github.com/repos/ceph/ceph/events","assignees_url":"https://api.github.com/repos/ceph/ceph/assignees{/user}","branches_url":"https://api.github.com/repos/ceph/ceph/branches{/branch}","tags_url":"https://api.github.com/repos/ceph/ceph/tags","blobs_url":"https://api.github.com/repos/ceph/ceph/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ceph/ceph/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ceph/ceph/git/refs{/sha}","trees_url":"https://api.github.com/repos/ceph/ceph/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ceph/ceph/statuses/{sha}","languages_url":"https://api.github.com/repos/ceph/ceph/languages","stargazers_url":"https://api.github.com/repos/ceph/ceph/stargazers","contributors_url":"https://api.github.com/repos/ceph/ceph/contributors","subscribers_url":"https://api.github.com/repos/ceph/ceph/subscribers","subscription_url":"https://api.github.com/repos/ceph/ceph/subscription","commits_url":"https://api.github.com/repos/ceph/ceph/commits{/sha}","git_commits_url":"https://api.github.com/repos/ceph/ceph/git/commits{/sha}","comments_url":"https://api.github.com/repos/ceph/ceph/comments{/number}","issue_comment_url":"https://api.github.com/repos/ceph/ceph/issues/comments{/number}","contents_url":"https://api.github.com/repos/ceph/ceph/contents/{+path}","compare_url":"https://api.github.com/repos/ceph/ceph/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ceph/ceph/merges","archive_url":"https://api.github.com/repos/ceph/ceph/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ceph/ceph/downloads","issues_url":"https://api.github.com/repos/ceph/ceph/issues{/number}","pulls_url":"https://api.github.com/repos/ceph/ceph/pulls{/number}","milestones_url":"https://api.github.com/repos/ceph/ceph/milestones{/number}","notifications_url":"https://api.github.com/repos/ceph/ceph/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ceph/ceph/labels{/name}","releases_url":"https://api.github.com/repos/ceph/ceph/releases{/id}","deployments_url":"https://api.github.com/repos/ceph/ceph/deployments","created_at":"2011-09-01T21:41:26Z","updated_at":"2016-08-16T13:28:29Z","pushed_at":"2016-08-16T13:35:11Z","git_url":"git://github.com/ceph/ceph.git","ssh_url":"git@github.com:ceph/ceph.git","clone_url":"https://github.com/ceph/ceph.git","svn_url":"https://github.com/ceph/ceph","homepage":"http://ceph.com","size":235189,"stargazers_count":2373,"watchers_count":2373,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1415,"mirror_url":null,"open_issues_count":448,"forks":1415,"open_issues":448,"watchers":2373,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ceph/ceph/pulls/9844"},"html":{"href":"https://github.com/ceph/ceph/pull/9844"},"issue":{"href":"https://api.github.com/repos/ceph/ceph/issues/9844"},"comments":{"href":"https://api.github.com/repos/ceph/ceph/issues/9844/comments"},"review_comments":{"href":"https://api.github.com/repos/ceph/ceph/pulls/9844/comments"},"review_comment":{"href":"https://api.github.com/repos/ceph/ceph/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ceph/ceph/pulls/9844/commits"},"statuses":{"href":"https://api.github.com/repos/ceph/ceph/statuses/b27f72e83a7d40030691d739d5591091086919e5"}}}}
{"actor":{"display_login":"yehudasa"}}