Unable to access the response. Inside inside the filter unit in Sinatra 1.0

I am struggling with a strange problem. According to http://github.com/sinatra/sinatra (secion Filters), a response object is available after filter blocks in Sinatra 1.0. However, response.status is correctly accessible, I cannot see a non-empty response.body from my routes inside the filter after.

I have this file:

config.ru

require 'app'
run TestApp

Then the Sinatra 1.0.b stone is installed using:

gem install --pre sinatra

And this is my little application with one route:

app.rb

require 'rubygems'
require 'sinatra/base'

class TestApp < Sinatra::Base

  set :root, File.dirname(__FILE__)

  get '/test' do
    'Some response'
  end

  after do
    halt 500 if response.empty? # used 500 just for illustation
  end

end

And now I would like to access the answer inside the after filter. When I run this application and access the URL / test , I got a 500 response , as if the answer is empty, but the answer is clearly "Some response".

/ /favicon.ico 404, . , 500 , .

, , after /favicon.ico - - " ", /test , , .

?

+5
1

.body Sinatra:: Base # invoke, Sinatra:: Base # dispatch!, , , . , #invoke ! , . , , , .

+6

All Articles