From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.204.72.79 with SMTP id l15cs49827bkj; Fri, 12 Jun 2009 14:49:10 -0700 (PDT) Return-Path: Received-SPF: pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.220.98.5 as permitted sender) client-ip=10.220.98.5; Authentication-Results: mr.google.com; spf=pass (google.com: domain of grbounce-ceibQwUAAAB4YPBqaDIjI2bFOCxyyh3G=chneukirchen=gmail.com@googlegroups.com designates 10.220.98.5 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.220.98.5]) by 10.220.98.5 with SMTP id o5mr1830460vcn.19.1244843350072 (num_hops = 1); Fri, 12 Jun 2009 14:49:10 -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 :mime-version:received:date:x-ip:user-agent:x-http-useragent :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=0gJUOk2tY7kFngZIH/XaUEgCN5lgQzOaM1sUo9D5oXQ=; b=amZ79n03rKb/TxxEk3HMJM7t2aDf3JWrRXHk/kgQQiHjXts8KXjYcfrYmIsij9+RUH oHaY2ZH03UqW7Zx+jgFQarrpq97bMYaz09CUGfo4MtAuE/kjAILHGNFQjf6vmGf+qnMq oBZvEpfShUeGxiQOEhlZ4DHXyoxT5Bii5m/iw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-sender:x-apparently-to:mime-version:date:x-ip:user-agent :x-http-useragent: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=eBYOmJoJ0d6Qs2rsLgY4qKXIReuwdsQw5MiW5h9aTrgNDGilBfsemLJAmO/mg5Rn6V i+jv0hiZIvhOGndpD5za8mTBk7lFTu8w6jea9iChIZScxv/lnh4gSF+OuSIdteMWeCjI TzcqNmlh3UUG+uuI3fsSsa+ElVNKTaJNiqKp8= Received: by 10.220.98.5 with SMTP id o5mr252925vcn.19.1244843349863; Fri, 12 Jun 2009 14:49:09 -0700 (PDT) Received: by 10.230.35.30 with SMTP id n30gr1437vbd.0; Fri, 12 Jun 2009 14:49:02 -0700 (PDT) X-Sender: martin.aumont@gmail.com X-Apparently-To: rack-devel@googlegroups.com MIME-Version: 1.0 Received: by 10.100.132.4 with SMTP id f4mr229677and.13.1244843339383; Fri, 12 Jun 2009 14:48:59 -0700 (PDT) Date: Fri, 12 Jun 2009 14:48:59 -0700 (PDT) X-IP: 69.165.162.141 User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10) Gecko/2009042523 Ubuntu/9.04 (jaunty) Firefox/3.0.10,gzip(gfe),gzip(gfe) Message-ID: <39345448-fc33-4712-8159-6da93fe9a189@h18g2000yqj.googlegroups.com> Subject: [PATCH] Request#accept_media_types From: mynyml To: Rack Development 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 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