Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

TryStatic #48

Closed
meskyanichi opened this Issue · 3 comments

3 participants

@meskyanichi

Hi there,

I'm trying to make use of TryStatic and it seems to work but on every request I get the following:

127.0.0.1 - - [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/config.ru:16:in `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 config.ru 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:

rackup
@meskyanichi

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

found or @app.call(env.merge!('PATH_INFO' => orig_path))

I'm not sure what the underlying idea is behind this part:

@app.call(env.merge!('PATH_INFO' => orig_path))

But when I simply replace that with just this:

@app.call

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 @app.call, 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 @app.call( <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. :)
Thanks!

@tkareine tkareine referenced this issue from a commit in tkareine/rack-contrib
@tkareine tkareine Add unused env parameter for lambdas (Ruby 1.9 compatibility)
Possibly related to GH-48
rack#48
04ced70
@jpmckinney

Close issue if #53 is closed.

@crofty crofty referenced this issue from a commit in crofty/rack-contrib
@tkareine tkareine Add unused env parameter for lambdas (Ruby 1.9 compatibility)
Possibly related to GH-48
rack#48
ed75269
@jpmckinney

Can close issue, since #53 is now closed.

@rkh rkh closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.