Method: Sinatra::Response#finish

Defined in:
lib/vendor/sinatra-1.4.4/lib/sinatra/base.rb

#finishObject



136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# File 'lib/vendor/sinatra-1.4.4/lib/sinatra/base.rb', line 136

def finish
  result = body

  if 
    headers.delete "Content-Length"
    headers.delete "Content-Type"
  end

  if drop_body?
    close
    result = []
  end

  if calculate_content_length?
    # if some other code has already set Content-Length, don't muck with it
    # currently, this would be the static file-handler
    headers["Content-Length"] = body.inject(0) { |l, p| l + Rack::Utils.bytesize(p) }.to_s
  end

  [status.to_i, headers, result]
end