couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iil...@apache.org
Subject [1/2] chttpd commit: updated refs/heads/master to 53459ab
Date Wed, 05 Oct 2016 17:02:40 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/master 297493f29 -> 53459aba5


Handle disconnect when receiving body

When any error happen on an underlying socket mochiweb uses
exit(normal). Add catch for exit:normal and convert it to
exit({bad_request, <<"Incomplete">>}).

COUCHDB-3158


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

Branch: refs/heads/master
Commit: 3868099565dbf8eb7851c50a2e2940f078aea14e
Parents: 297493f
Author: ILYA Khlopotov <iilyak@apache.org>
Authored: Thu Sep 22 16:19:39 2016 -0700
Committer: ILYA Khlopotov <iilyak@apache.org>
Committed: Wed Oct 5 09:30:28 2016 -0700

----------------------------------------------------------------------
 src/chttpd_external.erl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/38680995/src/chttpd_external.erl
----------------------------------------------------------------------
diff --git a/src/chttpd_external.erl b/src/chttpd_external.erl
index ec3afaa..1dccf2a 100644
--- a/src/chttpd_external.erl
+++ b/src/chttpd_external.erl
@@ -94,7 +94,11 @@ json_req_obj_field(<<"headers">>, #httpd{mochi_req=Req}, _Db,
_DocId) ->
     to_json_terms(Hlist);
 json_req_obj_field(<<"body">>, #httpd{req_body=undefined, mochi_req=Req}, _Db,
_DocId) ->
     MaxSize = config:get_integer("couchdb", "max_document_size", 4294967296),
-    Req:recv_body(MaxSize);
+    try
+        Req:recv_body(MaxSize)
+    catch exit:normal ->
+        exit({bad_request, <<"Invalid request body">>})
+    end;
 json_req_obj_field(<<"body">>, #httpd{req_body=Body}, _Db, _DocId) ->
     Body;
 json_req_obj_field(<<"peer">>, #httpd{mochi_req=Req}, _Db, _DocId) ->


Mime
View raw message