Class: Poncho::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Poncho::Response
- Defined in:
- lib/poncho/response.rb
Instance Method Summary collapse
Instance Method Details
#body=(value) ⇒ Object
3 4 5 6 |
# File 'lib/poncho/response.rb', line 3 def body=(value) value = value.body while Rack::Response === value @body = String === value ? [value.to_str] : value end |
#each ⇒ Object
8 9 10 |
# File 'lib/poncho/response.rb', line 8 def each block_given? ? super : enum_for(:each) end |
#finish ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/poncho/response.rb', line 12 def finish if status.to_i / 100 == 1 headers.delete 'Content-Length' headers.delete 'Content-Type' elsif Array === body and not [204, 304].include?(status.to_i) # 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 # Rack::Response#finish sometimes returns self as response body. We don't want that. status, headers, result = super result = body if result == self [status, headers, result] end |