summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_httpd_external.erl23
1 files changed, 16 insertions, 7 deletions
diff --git a/src/couchdb/couch_httpd_external.erl b/src/couchdb/couch_httpd_external.erl
index 7ed3d51a..84f1c444 100644
--- a/src/couchdb/couch_httpd_external.erl
+++ b/src/couchdb/couch_httpd_external.erl
@@ -12,7 +12,7 @@
-module(couch_httpd_external).
--export([handle_external_req/2]).
+-export([handle_external_req/2, handle_external_req/3]).
-import(couch_httpd,[send_error/4]).
@@ -25,10 +25,9 @@
headers = []
}).
-handle_external_req(#httpd{mochi_req=Req,
- method=Verb,
- path_parts=[_DbName, _External, UrlName | Path]
- }=HttpReq, Db) ->
+process_external_req(#httpd{mochi_req=Req,
+ method=Verb
+ }=HttpReq, Db, Name, Path) ->
ReqBody = Req:recv_body(),
ParsedForm = case Req:get_primary_header_value("content-type") of
"application/x-www-form-urlencoded" ++ _ ->
@@ -36,7 +35,7 @@ handle_external_req(#httpd{mochi_req=Req,
_ ->
[]
end,
- Response = couch_external_manager:execute(binary_to_list(UrlName),
+ Response = couch_external_manager:execute(binary_to_list(Name),
Db, Verb, Path, Req:parse_qs(), ReqBody, ParsedForm,
Req:parse_cookie()),
@@ -45,12 +44,22 @@ handle_external_req(#httpd{mochi_req=Req,
send_error(HttpReq, 404, <<"external_server_error">>, Msg);
_ ->
send_external_response(Req, Response)
- end;
+ end.
+
+handle_external_req(#httpd{
+ path_parts=[_DbName, _External, UrlName | Path]
+ }=HttpReq, Db) ->
+ process_external_req(HttpReq, Db, UrlName, Path);
handle_external_req(#httpd{path_parts=[_, _]}=Req, _Db) ->
send_error(Req, 404, <<"external_server_error">>, <<"No server name specified.">>);
handle_external_req(Req, _) ->
send_error(Req, 404, <<"external_server_error">>, <<"Broken assumption">>).
+handle_external_req(#httpd{
+ path_parts=[_DbName, _External | Path]
+ }=HttpReq, Db, Name) ->
+ process_external_req(HttpReq, Db, Name, Path).
+
send_external_response(Req, Response) ->
#extern_resp_args{
code = Code,