You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ch...@apache.org on 2014/05/29 00:45:08 UTC
[2/9] chttpd commit: updated
refs/heads/1843-feature-bigcouch-clustered-eventsource-changes-feed to
002a908
Allow optional max_uri_length server setting
Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/eaf1b56a
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/eaf1b56a
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/eaf1b56a
Branch: refs/heads/1843-feature-bigcouch-clustered-eventsource-changes-feed
Commit: eaf1b56ae63fa6f5708348246933de2aa1602130
Parents: 76d82fc
Author: Robert Newson <rn...@apache.org>
Authored: Thu May 22 11:52:02 2014 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Thu May 22 11:52:02 2014 +0100
----------------------------------------------------------------------
src/chttpd.erl | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/eaf1b56a/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index dd184c0..f9ed560 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -203,6 +203,7 @@ handle_request(MochiReq) ->
Result =
try
+ check_request_uri_length(RawUri),
case authenticate_request(HttpReq, AuthenticationFuns) of
#httpd{} = Req ->
HandlerFun = url_handler(HandlerKey),
@@ -220,6 +221,8 @@ handle_request(MochiReq) ->
exit:{mochiweb_recv_error, E} ->
couch_log:notice(LogForClosedSocket ++ " - ~p", [E]),
exit(normal);
+ exit:{uri_too_long, _} ->
+ send_error(HttpReq, request_uri_too_long);
throw:Error ->
send_error(HttpReq, Error);
error:database_does_not_exist ->
@@ -276,6 +279,19 @@ possibly_hack(#httpd{path_parts=[<<"_replicate">>]}=Req) ->
possibly_hack(Req) ->
Req.
+check_request_uri_length(Uri) ->
+ check_request_uri_length(Uri, config:get("httpd", "max_uri_length")).
+
+check_request_uri_length(_Uri, undefined) ->
+ ok;
+check_request_uri_length(Uri, MaxUriLen) when is_list(MaxUriLen) ->
+ case length(Uri) > list_to_integer(MaxUriLen) of
+ true ->
+ throw(request_uri_too_long);
+ false ->
+ ok
+ end.
+
fix_uri(Req, Props, Type) ->
case is_http(replication_uri(Type, Props)) of
true ->
@@ -694,6 +710,8 @@ error_info({r_quorum_not_met, Reason}) ->
{412, <<"read_quorum_not_met">>, Reason};
error_info({w_quorum_not_met, Reason}) ->
{500, <<"write_quorum_not_met">>, Reason};
+error_info(request_uri_too_long) ->
+ {414, <<"too_long">>, <<"the request uri is too long">>};
error_info({bad_ctype, Reason}) ->
{415, <<"bad_content_type">>, Reason};
error_info(requested_range_not_satisfiable) ->