class Sinatra::Base
def call!(env) # :nodoc:
def call!(env) # :nodoc: @env = env @request = Request.new(env) @response = Response.new @params = indifferent_params(@request.params) template_cache.clear if settings.reload_templates force_encoding(@request.route) force_encoding(@params) @response['Content-Type'] = nil invoke { dispatch! } invoke { error_block!(response.status) } unless @response['Content-Type'] if body.respond_to?(:to_ary) and body.first.respond_to? :content_type content_type body.first.content_type else content_type :html end end status, header, body = @response.finish # Never produce a body on HEAD requests. Do retain the Content-Length # unless it's "0", in which case we assume it was calculated erroneously # for a manual HEAD response and remove it entirely. if @env['REQUEST_METHOD'] == 'HEAD' body = [] header.delete('Content-Length') if header['Content-Length'] == '0' end [status, header, body] end