summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenoit Chesneau <benoitc@apache.org>2010-02-02 12:12:46 +0000
committerBenoit Chesneau <benoitc@apache.org>2010-02-02 12:12:46 +0000
commit2fcfa641f6572368f60a260bfd6c8bf11a5d5b20 (patch)
tree2165f652161cf5530ed9c6d77aa0606dfe617d88 /src
parent1ba1a72eba6b02e4b499d903991423a76f52ad0d (diff)
would have been strange to be abble ../../_changes and not
../../../_uuids in rewriting. Instead using couch_httpd_db:handle_request we now use couch_httpd:handle_request. Add one more unitest to test it. git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@905599 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_httpd.erl2
-rw-r--r--src/couchdb/couch_httpd_rewrite.erl25
2 files changed, 16 insertions, 11 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 856ab2a4..6d0230f9 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -17,7 +17,7 @@
-export([header_value/2,header_value/3,qs_value/2,qs_value/3,qs/1,path/1,absolute_uri/2,body_length/1]).
-export([verify_is_server_admin/1,unquote/1,quote/1,recv/2,recv_chunked/4,error_info/1]).
--export([make_fun_spec_strs/1]).
+-export([make_fun_spec_strs/1, make_arity_1_fun/1]).
-export([parse_form/1,json_body/1,json_body_obj/1,body/1,doc_etag/1, make_etag/1, etag_respond/3]).
-export([primary_header_value/2,partition/1,serve_file/3,serve_file/4, server_header/0]).
-export([start_chunked_response/3,send_chunk/2,log_request/2]).
diff --git a/src/couchdb/couch_httpd_rewrite.erl b/src/couchdb/couch_httpd_rewrite.erl
index 364e6c4d..eabe98df 100644
--- a/src/couchdb/couch_httpd_rewrite.erl
+++ b/src/couchdb/couch_httpd_rewrite.erl
@@ -159,11 +159,6 @@ handle_rewrite_req(#httpd{
% normalize final path (fix levels "." and "..")
RawPath1 = ?b2l(iolist_to_binary(normalize_path(RawPath))),
-
- %% get path parts, needed for CouchDB dispatching
- {"/" ++ NewPath2, _, _} = mochiweb_util:urlsplit_path(RawPath1),
- NewPathParts1 = [?l2b(couch_httpd:unquote(Part))
- || Part <- string:tokens(NewPath2, "/")],
?LOG_DEBUG("rewrite to ~p ~n", [RawPath1]),
@@ -176,11 +171,21 @@ handle_rewrite_req(#httpd{
% cleanup, It force mochiweb to reparse raw uri.
MochiReq1:cleanup(),
-
- % send to couchdb the rewritten request
- couch_httpd_db:handle_request(Req#httpd{
- path_parts=NewPathParts1,
- mochi_req=MochiReq1})
+
+ DefaultSpec = "{couch_httpd_db, handle_request}",
+ DefaultFun = couch_httpd:make_arity_1_fun(
+ couch_config:get("httpd", "default_handler", DefaultSpec)
+ ),
+
+ UrlHandlersList = lists:map(
+ fun({UrlKey, SpecStr}) ->
+ {?l2b(UrlKey), couch_httpd:make_arity_1_fun(SpecStr)}
+ end, couch_config:get("httpd_global_handlers")),
+ UrlHandlers = dict:from_list(UrlHandlersList),
+
+ couch_httpd:handle_request(MochiReq1, DefaultFun,
+ UrlHandlers, Req#httpd.db_url_handlers,
+ Req#httpd.design_url_handlers)
end.