class Sinatra::Response
The response object. See Rack::Response and Rack::Response::Helpers for more info: rubydoc.info/github/rack/rack/main/Rack/Response rubydoc.info/github/rack/rack/main/Rack/Response/Helpers
Constants
- DROP_BODY_RESPONSES
Public Instance Methods
Source
# File lib/sinatra/base.rb 174 def body=(value) 175 value = value.body while Rack::Response === value 176 @body = String === value ? [value.to_str] : value 177 end
Source
# File lib/sinatra/base.rb 179 def each 180 block_given? ? super : enum_for(:each) 181 end
Calls superclass method
Source
# File lib/sinatra/base.rb 183 def finish 184 result = body 185 186 if drop_content_info? 187 headers.delete 'content-length' 188 headers.delete 'content-type' 189 end 190 191 if drop_body? 192 close 193 result = [] 194 end 195 196 if calculate_content_length? 197 # if some other code has already set content-length, don't muck with it 198 # currently, this would be the static file-handler 199 headers['content-length'] = body.map(&:bytesize).reduce(0, :+).to_s 200 end 201 202 [status, headers, result] 203 end
Private Instance Methods
Source
# File lib/sinatra/base.rb 207 def calculate_content_length? 208 headers['content-type'] && !headers['content-length'] && (Array === body) 209 end
Source
# File lib/sinatra/base.rb 215 def drop_body? 216 DROP_BODY_RESPONSES.include?(status) 217 end
Source
# File lib/sinatra/base.rb 211 def drop_content_info? 212 informational? || drop_body? 213 end