Class: Jets::Controller::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Jets::Controller::Response
- Defined in:
- lib/jets/controller/response.rb
Overview
The response object. See Rack::Response and Rack::Response::Helpers for more info: rubydoc.info/github/rack/rack/master/Rack/Response rubydoc.info/github/rack/rack/master/Rack/Response/Helpers
Constant Summary collapse
- DROP_BODY_RESPONSES =
[204, 304]
Instance Method Summary collapse
-
#body=(value) ⇒ Object
TODO: unsure if we should even have these methods.
- #each ⇒ Object
- #finish ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize ⇒ Response
Returns a new instance of Response.
10 11 12 13 |
# File 'lib/jets/controller/response.rb', line 10 def initialize(*) super # headers['Content-Type'] ||= 'text/html' end |
Instance Method Details
#body=(value) ⇒ Object
TODO: unsure if we should even have these methods. We dont really use them.
16 17 18 19 |
# File 'lib/jets/controller/response.rb', line 16 def body=(value) value = value.body while Rack::Response === value @body = String === value ? [value.to_str] : value end |
#each ⇒ Object
21 22 23 |
# File 'lib/jets/controller/response.rb', line 21 def each block_given? ? super : enum_for(:each) end |
#finish ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/jets/controller/response.rb', line 25 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 + p.bytesize }.to_s end [status.to_i, headers, result] end |