You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by da...@apache.org on 2014/01/17 22:37:20 UTC
[26/50] git commit: Check that a request body was sent before decoding
Check that a request body was sent before decoding
BugzID: 14114
Project: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/commit/9f80885f
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/tree/9f80885f
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/diff/9f80885f
Branch: refs/heads/import
Commit: 9f80885fb38c61cc97f154a146218885a81c0ec9
Parents: 67e6a2b
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Fri Nov 16 10:25:42 2012 -0500
Committer: Robert Newson <ro...@cloudant.com>
Committed: Wed Mar 6 12:22:37 2013 -0600
----------------------------------------------------------------------
src/chttpd.erl | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/9f80885f/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index 54947a3..45bb043 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -493,7 +493,12 @@ body(#httpd{mochi_req=MochiReq, req_body=ReqBody}) ->
end.
json_body(Httpd) ->
- ?JSON_DECODE(body(Httpd)).
+ case body(Httpd) of
+ undefined ->
+ throw({bad_request, "Missing request body"});
+ Body ->
+ ?JSON_DECODE(Body)
+ end.
json_body_obj(Httpd) ->
case json_body(Httpd) of