![]() Implement HEAD by delegating to GET handlers (when no HEAD handler registered) and removing response body. This fixes a problem where Sinatra sent a 404 response to HEAD requests due to HEAD not having any registered handlers. While here, make Static handlers respond only to GET and HEAD requests instead of using GET semantics for PUT/POST/DELETE. Makes it possible for Events to register PUT/POST/DELETE handlers for static file URLs. For instance, assuming a file exists, `public/foo.xml`, and the following event: put '/foo.xml' do File.open('public/foo.xml', 'wb') do |io| io.write(request.body.read) end '' end get '/foo.xml' do "THIS NEVER HAPPENS ... as long as /foo.xml exists on disk." end The built-in Static handler hits on GET and the dynamic event hits on PUT. An important note here is that the Static handler is now registered at the head of the events[:get] array (see Application#load_default_events! and Application#lookup), where it was previously a special case in the lookup method. |
||
---|---|---|
images | ||
lib | ||
test | ||
.gitignore | ||
Rakefile |