summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_httpd.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/couchdb/couch_httpd.erl')
-rw-r--r--src/couchdb/couch_httpd.erl11
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})) ++ "\"".