Classy web-development dressed in a DSL (official / canonical repo)
Go to file
Ryan Tomayko b47ffd392a HEAD support and Static as GET/HEAD only event.
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.
2008-03-12 17:00:49 -04:00
images * Default error messages 2007-11-29 18:35:06 -08:00
lib HEAD support and Static as GET/HEAD only event. 2008-03-12 17:00:49 -04:00
test HEAD support and Static as GET/HEAD only event. 2008-03-12 17:00:49 -04:00
.gitignore more ignores 2008-02-20 20:14:53 -08:00
Rakefile No more Error codes. Map them by Class name 2008-02-24 16:43:39 -08:00