TryStatic #48

mrrooijen opened this Issue Feb 1, 2012 · 3 comments


None yet
3 participants

Hi there,

I'm trying to make use of TryStatic and it seems to work but on every request I get the following: - - [01/Feb/2012 01:44:30] "GET /index.html HTTP/1.1" 304 - 0.0006
ArgumentError: wrong number of arguments (1 for 0)
    /Users/Michael/Desktop/rwm/ `block (2 levels) in <main>'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-contrib-1.1.0/lib/rack/contrib/try_static.rb:33:in `call'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-contrib-1.1.0/lib/rack/contrib/try_static.rb:33:in `call'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/lint.rb:48:in `_call'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/lint.rb:36:in `call'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/showexceptions.rb:24:in `call'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/commonlogger.rb:20:in `call'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/chunked.rb:43:in `call'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/content_length.rb:14:in `call'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/thin-1.3.1/lib/thin/connection.rb:80:in `block in pre_process'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/thin-1.3.1/lib/thin/connection.rb:78:in `catch'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/thin-1.3.1/lib/thin/connection.rb:78:in `pre_process'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/thin-1.3.1/lib/thin/connection.rb:53:in `process'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/thin-1.3.1/lib/thin/connection.rb:38:in `receive_data'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/handler/thin.rb:13:in `run'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:265:in `start'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/lib/rack/server.rb:137:in `start'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/bin/rackup:19:in `load'
    /Users/Michael/.rvm/gems/ruby-1.9.3-p0/bin/rackup:19:in `<main>'

The contents of my are:

require "rack"
require "rack/contrib/try_static"

use Rack::TryStatic,
    :root => "public",
    :urls => ["/"],
    :try  => ['.html', 'index.html', '/index.html']

# otherwise 404 NotFound
run lambda { [404, {'Content-Type' => 'text/html'}, ['Page Not Found']] }

I'm using rack (1.4.1) and rack-contrib (1.1.0) and I run the app using:


On line 33 in the try_static.rb you see the following:

found or!('PATH_INFO' => orig_path))

I'm not sure what the underlying idea is behind this part:!('PATH_INFO' => orig_path))

But when I simply replace that with just this:

It properly returns Page Not Found when accessing a non-existant page, along with the proper 404 status code instead of a 500. Also, regular pages no longer return 302 but regular 200 (as one would expect?).

Also, by removing the env argument from, the raised exceptions/stack traces disappear.

Now, I'm not too familiar with Rack but what is the added-value of passing the args (which apparently it can't?) to <here> )? Perhaps some Rack internals changed and this Rack::Contrib middleware needs to be updated?

If so, I could send a pull request, although it's just one line.

Anyone with more in-depth Rack-knowledge, please advise. :)

@tkareine tkareine added a commit to tkareine/rack-contrib that referenced this issue Apr 4, 2012

@tkareine tkareine Add unused env parameter for lambdas (Ruby 1.9 compatibility)
Possibly related to GH-48

Close issue if #53 is closed.

@crofty crofty added a commit to crofty/rack-contrib that referenced this issue Oct 10, 2012

@tkareine @crofty tkareine + crofty Add unused env parameter for lambdas (Ruby 1.9 compatibility)
Possibly related to GH-48

Can close issue, since #53 is now closed.

rkh closed this Dec 10, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment