From mboxrd@z Thu Jan 1 00:00:00 1970 Delivered-To: chneukirchen@gmail.com Received: by 10.229.248.130 with SMTP id mg2cs105967qcb; Tue, 20 Dec 2011 18:49:24 -0800 (PST) Return-Path: Received-SPF: pass (google.com: domain of rack-devel+bncCP_V2_zRBRCvksX3BBoEOjlDFw@googlegroups.com designates 10.50.40.165 as permitted sender) client-ip=10.50.40.165; Authentication-Results: mr.google.com; spf=pass (google.com: domain of rack-devel+bncCP_V2_zRBRCvksX3BBoEOjlDFw@googlegroups.com designates 10.50.40.165 as permitted sender) smtp.mail=rack-devel+bncCP_V2_zRBRCvksX3BBoEOjlDFw@googlegroups.com; dkim=pass header.i=rack-devel+bncCP_V2_zRBRCvksX3BBoEOjlDFw@googlegroups.com Received: from mr.google.com ([10.50.40.165]) by 10.50.40.165 with SMTP id y5mr843918igk.4.1324435762142 (num_hops = 1); Tue, 20 Dec 2011 18:49:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:mime-version:subject:from:in-reply-to:date :message-id:references:to:x-mailer:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:x-google-group-id:list-post:list-help:list-archive:sender :list-subscribe:list-unsubscribe:content-type :content-transfer-encoding; bh=82hpsIp0Mrd2qMzttiHAs8BSij77Huj7HFiA0oyFLlA=; b=Lq+mrnmVmETpxrE85URQUBfuIlKGgzXf9+/KVHxPRhDGQQ3a/mShC4SfcZywvcJTqo P6p0n/PvZ+hCv4BdFMo8a6VfJ/OXeJoTEdVCQsO5HRhbnyYIAX4rCSQYWtsLyXaI4bfp RdTwk3WiOV/dXi+1C47KKL7wk1boIRi0Z9Poo= Received: by 10.50.40.165 with SMTP id y5mr280795igk.4.1324435759709; Tue, 20 Dec 2011 18:49:19 -0800 (PST) X-BeenThere: rack-devel@googlegroups.com Received: by 10.231.37.200 with SMTP id y8ls3435418ibd.2.gmail; Tue, 20 Dec 2011 18:49:18 -0800 (PST) Received: by 10.50.183.133 with SMTP id em5mr501748igc.0.1324435758871; Tue, 20 Dec 2011 18:49:18 -0800 (PST) Received: by 10.50.183.133 with SMTP id em5mr501747igc.0.1324435758858; Tue, 20 Dec 2011 18:49:18 -0800 (PST) Received: from mail-iy0-f175.google.com (mail-iy0-f175.google.com [209.85.210.175]) by gmr-mx.google.com with ESMTPS id wm10si6974877igc.1.2011.12.20.18.49.18 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Dec 2011 18:49:18 -0800 (PST) Received-SPF: pass (google.com: domain of jftucker@gmail.com designates 209.85.210.175 as permitted sender) client-ip=209.85.210.175; Received: by iakh37 with SMTP id h37so9640240iak.34 for ; Tue, 20 Dec 2011 18:49:18 -0800 (PST) Received: by 10.42.147.72 with SMTP id m8mr4946804icv.56.1324435758755; Tue, 20 Dec 2011 18:49:18 -0800 (PST) Received: from [10.0.1.20] (c-67-180-21-214.hsd1.ca.comcast.net. [67.180.21.214]) by mx.google.com with ESMTPS id wn9sm26837408igc.6.2011.12.20.18.49.16 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 20 Dec 2011 18:49:17 -0800 (PST) Mime-Version: 1.0 (Apple Message framework v1251.1) Subject: Re: Middleware for serving static files From: James Tucker In-Reply-To: Date: Tue, 20 Dec 2011 18:49:14 -0800 Message-Id: <4CB63506-A761-47CD-97D4-902D534D9B21@gmail.com> References: To: rack-devel@googlegroups.com X-Mailer: Apple Mail (2.1251.1) X-Original-Sender: jftucker@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of jftucker@gmail.com designates 209.85.210.175 as permitted sender) smtp.mail=jftucker@gmail.com; dkim=pass (test mode) header.i=@gmail.com Reply-To: rack-devel@googlegroups.com Precedence: list Mailing-list: list rack-devel@googlegroups.com; contact rack-devel+owners@googlegroups.com List-ID: X-Google-Group-Id: 486215384060 List-Post: , List-Help: , List-Archive: Sender: rack-devel@googlegroups.com List-Subscribe: , List-Unsubscribe: , Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Magnus, Does this do what you want? def call(env) [ 200, {'Content-Type' =3D> 'text/plain'}, [env['HTTP_HOST']] ] end use Rack::Static, :urls =3D> Dir['*'].map { |f| "/#{f}" } run self This does cache the allowed list on boot. If not, a patch to support what you want is reasonably trivial, however, = one has to be careful to not open up the system to discovery attacks, = file traversals, and timing issues. It's not quite as simple as tacking = an || File.exists?(path) onto the end of the can_serve method. Cheers, James=