class Sinatra::Response
The response object. See Rack::Response and Rack::Response::Helpers for more info: rubydoc.info/github/rack/rack/master/Rack/Response rubydoc.info/github/rack/rack/master/Rack/Response/Helpers
Constants
- DROP_BODY_RESPONSES
Public Instance Methods
body=(value)
click to toggle source
# File lib/sinatra/base.rb 163 def body=(value) 164 value = value.body while Rack::Response === value 165 @body = String === value ? [value.to_str] : value 166 end
each()
click to toggle source
Calls superclass method
# File lib/sinatra/base.rb 168 def each 169 block_given? ? super : enum_for(:each) 170 end
finish()
click to toggle source
# File lib/sinatra/base.rb 172 def finish 173 result = body 174 175 if drop_content_info? 176 headers.delete "Content-Length" 177 headers.delete "Content-Type" 178 end 179 180 if drop_body? 181 close 182 result = [] 183 end 184 185 if calculate_content_length? 186 # if some other code has already set Content-Length, don't muck with it 187 # currently, this would be the static file-handler 188 headers["Content-Length"] = body.map(&:bytesize).reduce(0, :+).to_s 189 end 190 191 [status.to_i, headers, result] 192 end
Private Instance Methods
calculate_content_length?()
click to toggle source
# File lib/sinatra/base.rb 196 def calculate_content_length? 197 headers["Content-Type"] and not headers["Content-Length"] and Array === body 198 end
drop_body?()
click to toggle source
# File lib/sinatra/base.rb 204 def drop_body? 205 DROP_BODY_RESPONSES.include?(status.to_i) 206 end
drop_content_info?()
click to toggle source
# File lib/sinatra/base.rb 200 def drop_content_info? 201 status.to_i / 100 == 1 or drop_body? 202 end