Class: Angus::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Angus::Response
- Defined in:
- lib/angus/response.rb
Instance Method Summary collapse
- #body=(value) ⇒ Object
- #each ⇒ Object
- #finish ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
3 4 5 6 |
# File 'lib/angus/response.rb', line 3 def initialize(*) super headers['Content-Type'] ||= 'application/json' end |
Instance Method Details
#body=(value) ⇒ Object
8 9 10 11 |
# File 'lib/angus/response.rb', line 8 def body=(value) value = value.body while Rack::Response === value @body = String === value ? [value.to_str] : value end |
#each ⇒ Object
13 14 15 |
# File 'lib/angus/response.rb', line 13 def each block_given? ? super : enum_for(:each) end |
#finish ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/angus/response.rb', line 17 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.inject(0) { |l, p| l + Rack::Utils.bytesize(p) }.to_s end [status.to_i, headers, result] end |