Getting lots of strange errors about weird http verbs being used, this rack middleware will help 🙂
Setup
config.middleware.use 'HttpVerbResponder',
'PROPFIND' => [404, {}, 'Not supported'],
'PURGE' => [404, {}, 'Not supported'], # e.g. varnish
'OPTIONS' => [200, {"Access-Control-Allow-Origin" => "*", "Access-Control-Max-Age" => '1000'},'OK"] # CORS
Code
class HttpVerbResponder
def initialize(app, options={})
@app = app
@options = options
end
def call(env, options={})
if response = @options[env['REQUEST_METHOD']]
response
else
@app.call(env)
end
end
end
Test
curl -X PURGE your-url.com
What do you think about filtering weird http requests in nginx ?
if ($request_method = PROPFIND) { return 404; }
Even better/faster, but Nginx-specific