Class: Ocular::Inputs::HTTP::Input::Response
- Inherits:
-
Rack::Response
- Object
- Rack::Response
- Ocular::Inputs::HTTP::Input::Response
- Defined in:
- lib/ocular/inputs/http_input.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, 205, 304]
Instance Method Summary collapse
- #body=(value) ⇒ Object
- #each ⇒ Object
- #finish ⇒ Object
-
#initialize ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize ⇒ Response
186 187 188 189 |
# File 'lib/ocular/inputs/http_input.rb', line 186 def initialize(*) super headers['Content-Type'] ||= 'text/html' end |
Instance Method Details
#body=(value) ⇒ Object
191 192 193 194 |
# File 'lib/ocular/inputs/http_input.rb', line 191 def body=(value) value = value.body while Rack::Response === value @body = String === value ? [value.to_str] : value end |
#each ⇒ Object
196 197 198 |
# File 'lib/ocular/inputs/http_input.rb', line 196 def each block_given? ? super : enum_for(:each) end |
#finish ⇒ Object
200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/ocular/inputs/http_input.rb', line 200 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 |