You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by rn...@apache.org on 2015/07/12 16:01:48 UTC

couch commit: updated refs/heads/master to b3d1028

Repository: couchdb-couch
Updated Branches:
  refs/heads/master bcb7c1a36 -> b3d102807


Send 400 Bad Request if request body is missing


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

Branch: refs/heads/master
Commit: b3d10280743bb39a0656c3c88d5c3d7f8c2d999b
Parents: bcb7c1a
Author: Robert Newson <rn...@apache.org>
Authored: Sun Jul 12 14:20:25 2015 +0100
Committer: Robert Newson <rn...@apache.org>
Committed: Sun Jul 12 15:01:31 2015 +0100

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


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/b3d10280/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index 8e5555c..3260721 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -545,7 +545,12 @@ body(#httpd{req_body=ReqBody}) ->
     ReqBody.
 
 json_body(Httpd) ->
-    ?JSON_DECODE(maybe_decompress(Httpd, body(Httpd))).
+    case body(Httpd) of
+        undefined ->
+            throw({bad_request, "Missing request body"});
+        Body ->
+            ?JSON_DECODE(maybe_decompress(Httpd, Body))
+    end.
 
 json_body_obj(Httpd) ->
     case json_body(Httpd) of