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 166 def body=(value) 167 value = value.body while Rack::Response === value 168 @body = String === value ? [value.to_str] : value 169 end
each()
click to toggle source
Calls superclass method
# File lib/sinatra/base.rb 171 def each 172 block_given? ? super : enum_for(:each) 173 end
finish()
click to toggle source
# File lib/sinatra/base.rb 175 def finish 176 result = body 177 178 if drop_content_info? 179 headers.delete 'Content-Length' 180 headers.delete 'Content-Type' 181 end 182 183 if drop_body? 184 close 185 result = [] 186 end 187 188 if calculate_content_length? 189 # if some other code has already set Content-Length, don't muck with it 190 # currently, this would be the static file-handler 191 headers['Content-Length'] = body.map(&:bytesize).reduce(0, :+).to_s 192 end 193 194 [status, headers, result] 195 end
Private Instance Methods
calculate_content_length?()
click to toggle source
# File lib/sinatra/base.rb 199 def calculate_content_length? 200 headers['Content-Type'] && !headers['Content-Length'] && (Array === body) 201 end
drop_body?()
click to toggle source
# File lib/sinatra/base.rb 207 def drop_body? 208 DROP_BODY_RESPONSES.include?(status) 209 end
drop_content_info?()
click to toggle source
# File lib/sinatra/base.rb 203 def drop_content_info? 204 informational? || drop_body? 205 end