couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rnew...@apache.org
Subject [09/50] chttpd commit: updated refs/heads/master to 58020ab
Date Thu, 28 Aug 2014 11:59:32 GMT
Throw HTTP 413 is max_document_size is exceeded

BugzID: 19888

This is a backport of
Apache/CouchDB@bf1eb135f2b46861474b9276dee02d8edb05fe3b


Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/204ab913
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/204ab913
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/204ab913

Branch: refs/heads/master
Commit: 204ab913463792dd71d8be59468919d7a63b2091
Parents: 4816754
Author: Mike Wallace <mikewallace1979@googlemail.com>
Authored: Fri May 24 11:19:00 2013 +0100
Committer: Robert Newson <rnewson@apache.org>
Committed: Tue Jul 29 17:34:16 2014 +0100

----------------------------------------------------------------------
 src/chttpd.erl | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/204ab913/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index 75fcf6d..6878fa5 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -219,6 +219,8 @@ handle_request(MochiReq) ->
             exit(normal);
         exit:{uri_too_long, _} ->
             send_error(HttpReq, request_uri_too_long);
+        exit:{body_too_large, _} ->
+            send_error(HttpReq, request_entity_too_large);
         throw:Error ->
             send_error(HttpReq, Error);
         error:database_does_not_exist ->
@@ -479,16 +481,8 @@ recv_chunked(#httpd{mochi_req=MochiReq}, MaxChunkSize, ChunkFun, InitState)
->
     % called with Length == 0 on the last time.
     MochiReq:stream_body(MaxChunkSize, ChunkFun, InitState).
 
-body_length(Req) ->
-    case header_value(Req, "Transfer-Encoding") of
-        undefined ->
-            case header_value(Req, "Content-Length") of
-                undefined -> undefined;
-                Length -> list_to_integer(Length)
-            end;
-        "chunked" -> chunked;
-        Unknown -> {unknown_transfer_encoding, Unknown}
-    end.
+body_length(#httpd{mochi_req=MochiReq}) ->
+    MochiReq:get(body_length).
 
 body(#httpd{mochi_req=MochiReq, req_body=ReqBody}) ->
     case ReqBody of
@@ -723,6 +717,8 @@ error_info({error, illegal_database_name}) ->
         "allowed. Moreover, the database name must begin with a letter.">>};
 error_info({missing_stub, Reason}) ->
     {412, <<"missing_stub">>, Reason};
+error_info(request_entity_too_large) ->
+    {413, <<"too_large">>, <<"the request entity is too large">>};
 error_info(not_implemented) ->
     {501, <<"not_implemented">>, <<"this feature is not yet implemented">>};
 error_info({Error, null}) ->


Mime
View raw message