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/02/12 07:15:50 UTC
[7/7] couch commit: updated refs/heads/import-master to bc467c3
Accept gzipped JSON request bodies
COUCHDB-2054
Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch/commit/bc467c32
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch/tree/bc467c32
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch/diff/bc467c32
Branch: refs/heads/import-master
Commit: bc467c323f8a09d0bf563739cd57a0596006968a
Parents: 1ebec99
Author: Robert Newson <rn...@apache.org>
Authored: Fri Feb 7 20:33:57 2014 +0000
Committer: Robert Newson <rn...@apache.org>
Committed: Fri Feb 7 20:33:57 2014 +0000
----------------------------------------------------------------------
couch_httpd.erl | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/bc467c32/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/couch_httpd.erl b/couch_httpd.erl
index acc20d7..f00fdd0 100644
--- a/couch_httpd.erl
+++ b/couch_httpd.erl
@@ -544,7 +544,7 @@ body(#httpd{req_body=ReqBody}) ->
ReqBody.
json_body(Httpd) ->
- ?JSON_DECODE(body(Httpd)).
+ ?JSON_DECODE(maybe_decompress(Httpd, body(Httpd))).
json_body_obj(Httpd) ->
case json_body(Httpd) of
@@ -554,6 +554,15 @@ json_body_obj(Httpd) ->
end.
+maybe_decompress(Httpd, Body) ->
+ case header_value(Httpd, "Content-Encoding", "identity") of
+ "gzip" ->
+ zlib:gunzip(Body);
+ "identity" ->
+ Body;
+ Else ->
+ throw({bad_ctype, [Else, " is not a supported content encoding."]})
+ end.
doc_etag(#doc{revs={Start, [DiskRev|_]}}) ->
"\"" ++ ?b2l(couch_doc:rev_to_str({Start, DiskRev})) ++ "\"".