Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B9C0A10896 for ; Fri, 7 Feb 2014 20:34:33 +0000 (UTC) Received: (qmail 31072 invoked by uid 500); 7 Feb 2014 20:34:32 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 31029 invoked by uid 500); 7 Feb 2014 20:34:32 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 31018 invoked by uid 99); 7 Feb 2014 20:34:32 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Feb 2014 20:34:32 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 6992191F97E; Fri, 7 Feb 2014 20:34:32 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: rnewson@apache.org To: commits@couchdb.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: couchdb commit: updated refs/heads/2054-feature-gzip-requests to 4d89338 Date: Fri, 7 Feb 2014 20:34:32 +0000 (UTC) Updated Branches: refs/heads/2054-feature-gzip-requests [created] 4d8933872 Accept gzipped JSON request bodies COUCHDB-2054 Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/4d893387 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/4d893387 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/4d893387 Branch: refs/heads/2054-feature-gzip-requests Commit: 4d893387291ef4db1058a2f101bc0fd3c5064b17 Parents: f7801e6 Author: Robert Newson Authored: Fri Feb 7 20:33:57 2014 +0000 Committer: Robert Newson Committed: Fri Feb 7 20:33:57 2014 +0000 ---------------------------------------------------------------------- src/couchdb/couch_httpd.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/4d893387/src/couchdb/couch_httpd.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index acc20d7..f00fdd0 100644 --- a/src/couchdb/couch_httpd.erl +++ b/src/couchdb/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})) ++ "\"".