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 2013/12/15 10:00:57 UTC
git commit: updated refs/heads/154-feature-gzip-post to 899a919
Updated Branches:
refs/heads/154-feature-gzip-post [created] 899a91927
Allows clients to send gzipped JSON bodies
A request with a Content-Encoding other than "gzip" or "identity" will
receive a 415 Unsupported Media Type response.
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/899a9192
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/899a9192
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/899a9192
Branch: refs/heads/154-feature-gzip-post
Commit: 899a919275d16dfbb016945fb818e4791af969d6
Parents: cb90950
Author: Adam Kocoloski <ad...@cloudant.com>
Authored: Wed Oct 9 11:37:18 2013 -0400
Committer: Robert Newson <rn...@apache.org>
Committed: Sun Dec 15 10:00:13 2013 +0100
----------------------------------------------------------------------
src/couchdb/couch_httpd.erl | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/899a9192/src/couchdb/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 28932ba..a370bd2 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -559,7 +559,8 @@ body(#httpd{req_body=ReqBody}) ->
ReqBody.
json_body(Httpd) ->
- ?JSON_DECODE(body(Httpd)).
+ Body = body(Httpd),
+ ?JSON_DECODE(maybe_decompress(Httpd, Body)).
json_body_obj(Httpd) ->
case json_body(Httpd) of
@@ -569,6 +570,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})) ++ "\"".