Repository: couchdb-chttpd Updated Branches: refs/heads/master 33a242edd -> f087a016e
Restore HTTP 301 response for /db/_design%2fddoc/* resources This also fixes bug that existed in 1.x when escape sequence represented in uppercase: then we send wrong Location header back to user causing HTTP 404 result. COUCHDB-2674 Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/f087a016 Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/f087a016 Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/f087a016 Branch: refs/heads/master Commit: f087a016e9a75c9f2518a29dec37a6c8dd27871e Parents: 33a242e Author: Alexander Shorin <[email protected]> Authored: Thu Oct 29 01:07:26 2015 +0300 Committer: Alexander Shorin <[email protected]> Committed: Thu Oct 29 17:26:03 2015 +0300 ---------------------------------------------------------------------- src/chttpd_db.erl | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/f087a016/src/chttpd_db.erl ---------------------------------------------------------------------- diff --git a/src/chttpd_db.erl b/src/chttpd_db.erl index bce04e1..ad2017e 100644 --- a/src/chttpd_db.erl +++ b/src/chttpd_db.erl @@ -576,12 +576,12 @@ db_req(#httpd{method='GET',path_parts=[_,<<"_revs_limit">>]}=Req, Db) -> db_req(#httpd{path_parts=[_,<<"_revs_limit">>]}=Req, _Db) -> send_method_not_allowed(Req, "PUT,GET"); -% vanilla CouchDB sends a 301 here, but we just handle the request -db_req(#httpd{path_parts=[DbName,<<"_design/",Name/binary>>|Rest]}=Req, Db) -> - db_req(Req#httpd{path_parts=[DbName, <<"_design">>, Name | Rest]}, Db); - % Special case to enable using an unencoded slash in the URL of design docs, % as slashes in document IDs must otherwise be URL encoded. +db_req(#httpd{method='GET', mochi_req=MochiReq, path_parts=[DbName, <<"_design/", _/binary>> | _]}=Req, _Db) -> + [Head | Tail] = re:split(MochiReq:get(raw_path), "_design%2F", [{return, list}, caseless]), + chttpd:send_redirect(Req, Head ++ "_design/" ++ Tail); + db_req(#httpd{path_parts=[_DbName,<<"_design">>,Name]}=Req, Db) -> db_doc_req(Req, Db, <<"_design/",Name/binary>>);
