Return-Path: Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: (qmail 13855 invoked from network); 1 Jan 2011 21:10:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 1 Jan 2011 21:10:57 -0000 Received: (qmail 33216 invoked by uid 500); 1 Jan 2011 21:10:57 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 33174 invoked by uid 500); 1 Jan 2011 21:10:57 -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 33167 invoked by uid 99); 1 Jan 2011 21:10:57 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Jan 2011 21:10:57 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 01 Jan 2011 21:10:55 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 5C89D23889E9; Sat, 1 Jan 2011 21:10:34 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1054290 - in /couchdb/trunk/src/couchdb: couch_db.erl couch_util.erl Date: Sat, 01 Jan 2011 21:10:34 -0000 To: commits@couchdb.apache.org From: benoitc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110101211034.5C89D23889E9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: benoitc Date: Sat Jan 1 21:10:33 2011 New Revision: 1054290 URL: http://svn.apache.org/viewvc?rev=1054290&view=rev Log: remove cyclic dependancy. couch_config is using couch_util too. Modified: couchdb/trunk/src/couchdb/couch_db.erl couchdb/trunk/src/couchdb/couch_util.erl Modified: couchdb/trunk/src/couchdb/couch_db.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.erl?rev=1054290&r1=1054289&r2=1054290&view=diff ============================================================================== --- couchdb/trunk/src/couchdb/couch_db.erl (original) +++ couchdb/trunk/src/couchdb/couch_db.erl Sat Jan 1 21:10:33 2011 @@ -862,6 +862,24 @@ flush_att(Fd, #att{data=Fun,att_len=AttL write_streamed_attachment(OutputStream, Fun, AttLen) end). + +compressible_att_type(MimeType) when is_binary(MimeType) -> + compressible_att_type(?b2l(MimeType)); +compressible_att_type(MimeType) -> + TypeExpList = re:split( + couch_config:get("attachments", "compressible_types", ""), + ", ?", + [{return, list}] + ), + lists:any( + fun(TypeExp) -> + Regexp = ["^\\s*", re:replace(TypeExp, "\\*", ".*"), + "(?:\\s*;.*?)?\\s*", $$], + re:run(MimeType, Regexp, [caseless]) =/= nomatch + end, + [T || T <- TypeExpList, T /= []] + ). + % From RFC 2616 3.6.1 - Chunked Transfer Coding % % In other words, the origin server is willing to accept @@ -874,7 +892,7 @@ flush_att(Fd, #att{data=Fun,att_len=AttL % pretend that no Content-MD5 exists. with_stream(Fd, #att{md5=InMd5,type=Type,encoding=Enc}=Att, Fun) -> {ok, OutputStream} = case (Enc =:= identity) andalso - couch_util:compressible_att_type(Type) of + compressible_att_type(Type) of true -> CompLevel = list_to_integer( couch_config:get("attachments", "compression_level", "0") Modified: couchdb/trunk/src/couchdb/couch_util.erl URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_util.erl?rev=1054290&r1=1054289&r2=1054290&view=diff ============================================================================== --- couchdb/trunk/src/couchdb/couch_util.erl (original) +++ couchdb/trunk/src/couchdb/couch_util.erl Sat Jan 1 21:10:33 2011 @@ -23,7 +23,6 @@ -export([to_binary/1, to_integer/1, to_list/1, url_encode/1]). -export([json_encode/1, json_decode/1]). -export([verify/2,simple_call/2,shutdown_sync/1]). --export([compressible_att_type/1]). -export([get_value/2, get_value/3]). -export([md5/1, md5_init/0, md5_update/2, md5_final/1]). -export([reorder_results/2]). @@ -388,23 +387,6 @@ verify(X, Y) when is_list(X) and is_list end; verify(_X, _Y) -> false. -compressible_att_type(MimeType) when is_binary(MimeType) -> - compressible_att_type(?b2l(MimeType)); -compressible_att_type(MimeType) -> - TypeExpList = re:split( - couch_config:get("attachments", "compressible_types", ""), - ", ?", - [{return, list}] - ), - lists:any( - fun(TypeExp) -> - Regexp = ["^\\s*", re:replace(TypeExp, "\\*", ".*"), - "(?:\\s*;.*?)?\\s*", $$], - re:run(MimeType, Regexp, [caseless]) =/= nomatch - end, - [T || T <- TypeExpList, T /= []] - ). - -spec md5(Data::(iolist() | binary())) -> Digest::binary(). md5(Data) -> try crypto:md5(Data) catch error:_ -> erlang:md5(Data) end.