Class: Sinatra::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Sinatra::Response
- Defined in:
- lib/sinatra/base.rb
Overview
The response object. See Rack::Response and Rack::Response::Helpers for more info: http://rubydoc.info/github/rack/rack/master/Rack/Response http://rubydoc.info/github/rack/rack/master/Rack/Response/Helpers
Constant Summary collapse
- DROP_BODY_RESPONSES =
[204, 304]
Instance Method Summary collapse
Instance Method Details
#body=(value) ⇒ Object
163 164 165 166 |
# File 'lib/sinatra/base.rb', line 163 def body=(value) value = value.body while Rack::Response === value @body = String === value ? [value.to_str] : value end |
#each ⇒ Object
168 169 170 |
# File 'lib/sinatra/base.rb', line 168 def each block_given? ? super : enum_for(:each) end |
#finish ⇒ Object
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'lib/sinatra/base.rb', line 172 def finish result = body if drop_content_info? 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.map(&:bytesize).reduce(0, :+).to_s end [status.to_i, headers, result] end |