rack-devel archive mirror (unofficial) https://groups.google.com/group/rack-devel
 help / color / mirror / Atom feed
From: James Tucker <jftucker@gmail.com>
To: rack-devel@googlegroups.com
Subject: Re: Middleware for serving static files
Date: Tue, 20 Dec 2011 18:49:14 -0800	[thread overview]
Message-ID: <4CB63506-A761-47CD-97D4-902D534D9B21@gmail.com> (raw)
In-Reply-To: <CAJ367fdgAoFUC3upSHU1Kw=MG0K3VoHjVY7so3cAE-OgaAW3Lg@mail.gmail.com>

Magnus,

Does this do what you want?

def call(env)
  [ 200, {'Content-Type' => 'text/plain'}, [env['HTTP_HOST']] ]
end

use Rack::Static, :urls => 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

      reply	other threads:[~2011-12-21  2:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-20  8:32 Middleware for serving static files Magnus Holm
2011-12-20  8:41 ` Lee Hambley
2011-12-20  8:45   ` Magnus Holm
2011-12-20  8:52     ` Lee Hambley
2011-12-20  9:07       ` Magnus Holm
2011-12-21  2:49         ` James Tucker [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://groups.google.com/group/rack-devel

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4CB63506-A761-47CD-97D4-902D534D9B21@gmail.com \
    --to=rack-devel@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).