Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TryStatic returns 405 "Method Not Allowed" Error if it can't find the static file #85

Closed
bachue opened this issue Jan 26, 2014 · 1 comment · Fixed by #86
Closed

TryStatic returns 405 "Method Not Allowed" Error if it can't find the static file #85

bachue opened this issue Jan 26, 2014 · 1 comment · Fixed by #86

Comments

@bachue
Copy link
Contributor

bachue commented Jan 26, 2014

Hi,

I found a bug that when I send a POST/PUT/DELETE request, and TryStatic can't find the static file which matches that path, it will return 405 error instead of going to next middleware.

This is the example how I use it:

  use Rack::TryStatic,
                root: File.expand_path(File.dirname(__FILE__) + '/public'),
                urls: %w[/], try: ['.html', 'index.html', '/index.html']

My gem version:
rack: v1.5.2
rack-contrib: v1.1.0

I've found the root cause is Rack::Static doesn't return 404 error if the request method is not GET or HEAD or OPTION, it returns 405(403 for old version), but in TryStatic, it just judge whether the status code is 404. So bug happens.

@alexmamonchik
Copy link

I spent many hours for research this problem. This solution is working! I wait when you apply this request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants