diff options
author | Adam Kocoloski <kocolosk@apache.org> | 2010-04-15 16:34:25 +0000 |
---|---|---|
committer | Adam Kocoloski <kocolosk@apache.org> | 2010-04-15 16:34:25 +0000 |
commit | f3e688373082574d6f469acc282b873658a2321a (patch) | |
tree | 2fd8e4e84bb277d5deb5109d5fd498d337aad7df /src/couchdb/couch_httpd_db.erl | |
parent | fc8069eedf13c10b9b61f527964279fa2085009b (diff) |
refactor att compression to allow more encodings. thanks fdmanana. COUCHDB-710
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@934475 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_httpd_db.erl')
-rw-r--r-- | src/couchdb/couch_httpd_db.erl | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/couchdb/couch_httpd_db.erl b/src/couchdb/couch_httpd_db.erl index 463519a8..1e11e0d3 100644 --- a/src/couchdb/couch_httpd_db.erl +++ b/src/couchdb/couch_httpd_db.erl @@ -853,26 +853,26 @@ db_attachment_req(#httpd{method='GET'}=Req, Db, DocId, FileNameParts) -> case [A || A <- Atts, A#att.name == FileName] of [] -> throw({not_found, "Document is missing attachment"}); - [#att{type=Type, comp=Comp}=Att] -> + [#att{type=Type, encoding=Enc}=Att] -> Etag = couch_httpd:doc_etag(Doc), - ReqAcceptsGzip = lists:member( - "gzip", + ReqAcceptsAttEnc = lists:member( + atom_to_list(Enc), couch_httpd:accepted_encodings(Req) ), Headers = [ {"ETag", Etag}, {"Cache-Control", "must-revalidate"}, {"Content-Type", binary_to_list(Type)} - ] ++ case {Comp, ReqAcceptsGzip} of - {true, true} -> - [{"Content-Encoding", "gzip"}]; + ] ++ case ReqAcceptsAttEnc of + true -> + [{"Content-Encoding", atom_to_list(Enc)}]; _ -> [] end, - AttFun = case {Comp, ReqAcceptsGzip} of - {true, false} -> - fun couch_doc:att_foldl_unzip/3; - _ -> + AttFun = case ReqAcceptsAttEnc of + false -> + fun couch_doc:att_foldl_decode/3; + true -> fun couch_doc:att_foldl/3 end, couch_httpd:etag_respond( @@ -1045,8 +1045,8 @@ parse_doc_query(Req) -> Args#doc_query_args{update_type=replicated_changes}; {"new_edits", "true"} -> Args#doc_query_args{update_type=interactive_edit}; - {"att_gzip_length", "true"} -> - Options = [att_gzip_length | Args#doc_query_args.options], + {"att_encoding_info", "true"} -> + Options = [att_encoding_info | Args#doc_query_args.options], Args#doc_query_args{options=Options}; _Else -> % unknown key value pair, ignore. Args |