diff options
author | Robert Newson <rnewson@apache.org> | 2014-02-07 20:33:57 +0000 |
---|---|---|
committer | Robert Newson <rnewson@apache.org> | 2014-02-07 20:33:57 +0000 |
commit | 4d893387291ef4db1058a2f101bc0fd3c5064b17 (patch) | |
tree | cffdbbcf379761fdf2b6c7b5f9127f8a188d601e | |
parent | f7801e669e522ca3bd92cfc4fdf2a65879369be1 (diff) | |
download | couchdb-2054-feature-gzip-requests.tar.gz |
Accept gzipped JSON request bodies2054-feature-gzip-requests
COUCHDB-2054
-rw-r--r-- | src/couchdb/couch_httpd.erl | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl index acc20d736..f00fdd068 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})) ++ "\"". |