summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2008-05-18 12:28:57 +0000
committerJan Lehnardt <jan@apache.org>2008-05-18 12:28:57 +0000
commit1c7fc943c0aaf1fc41df8fa8dd431a95c302400a (patch)
treebf8bf72231a81d5f8fc4a73c321391300e36a974 /src
parenta684f95cbcee7f2568a2ce04e7dc2bbb605a27b3 (diff)
- more graceful handling of unknown private URIs including more user friendly messages
- add a proper comment to the descending=false handling git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@657552 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_httpd.erl20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 9ebb0b93..bdb23e78 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -96,6 +96,8 @@ handle_request0(Req, DocumentRoot, Method, Path) ->
{ok, Req:respond({301, [{"Location", "/_utils/"}], <<>>})};
"/_utils/" ++ PathInfo ->
{ok, Req:serve_file(PathInfo, DocumentRoot)};
+ "/_" ++ UnknownPrivatePath ->
+ handle_unkown_private_uri_request(Req, Method, UnknownPrivatePath);
_Else ->
handle_db_request(Req, Method, {Path})
end.
@@ -129,6 +131,19 @@ handle_replicate_request(Req, 'POST') ->
handle_replicate_request(_Req, _Method) ->
throw({method_not_allowed, "POST"}).
+handle_unkown_private_uri_request(Req, _Method, UnknownPrivatePath) ->
+ KnownPrivatePaths = ["_utils"],
+ Msg = {obj,
+ [
+ {error, "Sorry, we could not find the private path '_" ++
+ mochiweb_util:unquote(UnknownPrivatePath) ++
+ "' you are looking for. We only know about the following path(s): '" ++
+ lists:flatten(KnownPrivatePaths) ++ "'"}
+ ]
+ },
+ io:format("Debug: ~p~n", [Msg]),
+ send_error(Req, 404, Msg).
+
% Database request handlers
handle_db_request(Req, Method, {Path}) ->
@@ -631,7 +646,10 @@ parse_view_query(Req) ->
Args %already reversed
end;
{"descending", "false"} ->
- % ignore
+ % The descending=false behaviour is the default behaviour, so we
+ % simpply ignore it. This is only for convenience when playing with
+ % the HTTP API, so that a user doesn't get served an error when
+ % flipping true to false in the descending option.
Args;
{"skip", Value} ->
case (catch list_to_integer(Value)) of