diff options
author | ILYA Khlopotov <iilyak@apache.org> | 2020-11-16 04:01:21 -0800 |
---|---|---|
committer | ILYA Khlopotov <iilyak@apache.org> | 2020-11-19 03:28:49 -0800 |
commit | 76898af320103b7acf2dd8d4aa398879ab154cac (patch) | |
tree | 3965109a3a99211e899f8ca0806484c154bb03aa | |
parent | 87a6b1ab7b6c29ff2b5c278c2171d2d894e4060e (diff) | |
download | couchdb-76898af320103b7acf2dd8d4aa398879ab154cac.tar.gz |
Use `req_body` field if present
When we call `couch_httpd:json_body/1` we can have `req_body` already set.
In this case we should return the field as is without any attempt to
decompress or decode it. This PR brings the approach we use in `chttpd`
into `couch_httpd`.
-rw-r--r-- | src/couch/src/couch_httpd.erl | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/couch/src/couch_httpd.erl b/src/couch/src/couch_httpd.erl index 8f7fedd5e..53d14d793 100644 --- a/src/couch/src/couch_httpd.erl +++ b/src/couch/src/couch_httpd.erl @@ -599,13 +599,16 @@ body(#httpd{mochi_req=MochiReq, req_body=undefined}) -> body(#httpd{req_body=ReqBody}) -> ReqBody. -json_body(Httpd) -> +json_body(#httpd{req_body=undefined} = Httpd) -> case body(Httpd) of undefined -> throw({bad_request, "Missing request body"}); Body -> ?JSON_DECODE(maybe_decompress(Httpd, Body)) - end. + end; + +json_body(#httpd{req_body=ReqBody}) -> + ReqBody. json_body_obj(Httpd) -> case json_body(Httpd) of |