From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.204.72.79 with SMTP id l15cs104535bkj; Sun, 14 Jun 2009 06:50:38 -0700 (PDT) Received-SPF: pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.142.240.9 as permitted sender) client-ip=10.142.240.9; Authentication-Results: mr.google.com; spf=pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.142.240.9 as permitted sender) smtp.mail=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com; dkim=pass header.i=grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com Received: from mr.google.com ([10.142.240.9]) by 10.142.240.9 with SMTP id n9mr7613917wfh.1.1244987437322 (num_hops = 1); Sun, 14 Jun 2009 06:50:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:received:x-sender:x-apparently-to :received:received:received-spf:authentication-results:received :dkim-signature:domainkey-signature:mime-version:received :in-reply-to:references:date:message-id:subject:from:to:content-type :content-transfer-encoding:reply-to:sender:precedence:x-google-loop :mailing-list:list-id:list-post:list-help:list-unsubscribe :x-beenthere-env:x-beenthere; bh=C5J+aICLTooO4Dyuk1CbZcFfTu/+t9UEuXyA+yQqGcM=; b=Aj65UvwUmXfOJHFpKTKjcBky/8Cvf5EF6nsj5pJ7b5oyoteRPVDnWTVYpVZOpGwN9T aeoApVm6Mdbdpbtz1xnr7FMoMdHoFuKhZnNHtR1ftNFcz7lgu200TZFAEzLbsAvrEwhD 6xxUBUVVoVyzR6EZS6vSLcn6muSH66I2W4IuA= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:received-spf:authentication-results :dkim-signature:domainkey-signature:mime-version:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding:reply-to:sender:precedence:x-google-loop :mailing-list:list-id:list-post:list-help:list-unsubscribe :x-beenthere-env:x-beenthere; b=h8+m+D/7UzW7l0muG3KLfYm8RGRfApJzkbjDd0y3yB/8cwa/9pFX5AT9YiftJ/ziO/ 2Uj0J+ef5tICvy0AHYgmV5nRM1YGnnVrAilPJ9LQ4HOg9X9oz8WNFmJrJsA6ke0SRw2j OGb6UGx9p3XeNHDoiX54KRwTkDVkvU+05Jl0g= Received: by 10.142.240.9 with SMTP id n9mr1026707wfh.1.1244987437139; Sun, 14 Jun 2009 06:50:37 -0700 (PDT) Received: by 10.106.201.4 with SMTP id y4gr1439prf.0; Sun, 14 Jun 2009 06:50:32 -0700 (PDT) X-Sender: joshbuddy@gmail.com X-Apparently-To: rack-devel@googlegroups.com Received: by 10.114.159.6 with SMTP id h6mr382792wae.9.1244987432262; Sun, 14 Jun 2009 06:50:32 -0700 (PDT) Return-Path: Received: from wa-out-1112.google.com ([172.21.186.37]) by gmr-mx.google.com with ESMTP id m37si896937waf.0.2009.06.14.06.50.31; Sun, 14 Jun 2009 06:50:31 -0700 (PDT) Received-SPF: neutral (google.com: 172.21.186.37 is neither permitted nor denied by domain of joshbuddy@gmail.com) client-ip=172.21.186.37; Authentication-Results: gmr-mx.google.com; spf=neutral (google.com: 172.21.186.37 is neither permitted nor denied by domain of joshbuddy@gmail.com) smtp.mail=joshbuddy@gmail.com; dkim=pass (test mode) header.i=@gmail.com Received: by wa-out-1112.google.com with SMTP id j37so712388waf.9 for ; Sun, 14 Jun 2009 06:50:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=wG+jzjFTObvDjX4/LIh4tU4U6NDKmrMLS/IXPzSoFrw=; b=cWUBoOAmZTcNKFLt+KNKstGEKJ4X8GRr4IWPg3Hubtp0D5DPD4eBcYWSMbNXZlCqNr vi6BsMpvbm0TeAW3x6zrrbcoOPAnHAIAOe1zCTaATmWL5kWSq30NZ/XnLtw08OLyiUtZ UjAj7oEcyH73YAgJb1BokgKAyRjNOD0AUI38A= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=AlAigbz2vj+RxnU4E9dJfkBy4QcoOxnDxLFFe5XDFyQ/Ai+hvNvNFkWa4h9v1fwQ+w SmQER3KO2bbFcL0TGrNesFnz+VJ3NmPHlM1F/WmhVkMOt3khzI3a9zDENLaFx3wQOlkQ GFhagfFR2OMH6r0YcgsaXAN1zMXUSk0wX9Ttw= MIME-Version: 1.0 Received: by 10.114.52.16 with SMTP id z16mr9791905waz.220.1244987431041; Sun, 14 Jun 2009 06:50:31 -0700 (PDT) In-Reply-To: <39345448-fc33-4712-8159-6da93fe9a189@h18g2000yqj.googlegroups.com> References: <39345448-fc33-4712-8159-6da93fe9a189@h18g2000yqj.googlegroups.com> Date: Sun, 14 Jun 2009 09:50:31 -0400 Message-ID: <299c839d0906140650n1849c528of36a6fee066a4a35@mail.gmail.com> Subject: Re: [PATCH] Request#accept_media_types From: Joshua Hull To: rack-devel@googlegroups.com Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Reply-To: rack-devel@googlegroups.com Sender: rack-devel@googlegroups.com Precedence: bulk X-Google-Loop: groups Mailing-List: list rack-devel@googlegroups.com; contact rack-devel+owner@googlegroups.com List-Id: List-Post: List-Help: List-Unsubscribe: , X-BeenThere-Env: rack-devel@googlegroups.com X-BeenThere: rack-devel@googlegroups.com Just a couple of comments on this: types = types.select {|type| media_type_quality(type).between?(0.1, 1) } this should probably check that its greater than 0 and less than or equal to 1 instead types = types.select {|type| quality = media_type_quality(type); quality > 0 && quality <= 1 } so that values of 0.01 still get through. As well, the default value of all types is 1.0, but we probably want to do something similar to what apache does, and assign */* a value of 0.01 and type/* a value of 0.02. Cheers Joshua On Fri, Jun 12, 2009 at 5:48 PM, mynyml wrote: > > Patch is at: http://github.com/mynyml/rack/commit/c9953dbc3f834fdcbcd1ebc8b71b64eaf24d9e2b > ----- > Patch to add parsing of the HTTP_ACCEPT header's media types. Orders > types by "quality" (preference level) (following HTTP 1.1 specs). > > The main advantage of being able to parse the Accept header is to > centralize the lookup for the request's "desired" type(s). Usually, a > client asks for a specific media type to be sent back by appending an > extension to the URL; not only does this require parsing by every > middleware/app that needs to know about this media type, but it also > ignores the Accept hierarchy, which can be usefull for cascading down > possible handlings of the resquest (think of a respond_to mechanism, > for instance). > > I've encountered many use cases already: > > o http://github.com/rack/rack-contrib/blob/3f42d3afe7323d322567d77cd404fb5bd8d9f1eb/lib/rack/contrib/accept_format.rb > o http://github.com/mynyml/rack-abstract-format > o http://github.com/mynyml/rack-supported-media-types > o http://github.com/mynyml/rack-js4xhr > o http://github.com/mynyml/rack-respond_to > > which led me to write the Accept header parsing code: > > o http://github.com/mynyml/rack-accept-media-types > > In my rack clone, the request_accept branch is a straight port of the > rack-accept-media-types gem, and the request_accept-compact branch > minimizes the code into two methods (instead of two classes). The > latter reflects the rest of the Request class much better so it's > probably a more appropriate patch. > > Feedback/questions/suggestions ? > > Thanks