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 15:26:10 UTC

couch commit: updated refs/heads/handle-missing-body to b65c918

Repository: couchdb-couch
Updated Branches:
  refs/heads/handle-missing-body cfd0b4f42 -> b65c9180c (forced update)


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/b65c9180
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/b65c9180
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/b65c9180

Branch: refs/heads/handle-missing-body
Commit: b65c9180c10f67ba84c9ab92a0f5f43ed0c1a8a4
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 14:25:57 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/b65c9180/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