Class: Fredo::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Fredo::Response
- Defined in:
- lib/fredo/response.rb
Instance Method Summary collapse
Instance Method Details
#finish ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/fredo/response.rb', line 3 def finish @body = block if block_given? if [204, 304].include?(status.to_i) header.delete "Content-Type" [status.to_i, header.to_hash, []] else body = @body || [] body = [body] if body.respond_to? :to_str if body.respond_to?(:to_ary) header["Content-Length"] = body.to_ary. inject(0) { |len, part| len + part.bytesize }.to_s end [status.to_i, header.to_hash, body] end end |