Class: Rack::HttpStreamingResponse
- Inherits:
-
Object
- Object
- Rack::HttpStreamingResponse
- Defined in:
- lib/rack/http_streaming_response.rb
Overview
Wraps the hacked net/http in a Rack way.
Instance Attribute Summary collapse
-
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
-
#verify_mode ⇒ Object
Returns the value of attribute verify_mode.
Instance Method Summary collapse
- #body ⇒ Object
- #code ⇒ Object (also: #status)
-
#each(&block) ⇒ Object
Can be called only once!.
- #headers ⇒ Object
-
#initialize(request, host, port = nil) ⇒ HttpStreamingResponse
constructor
A new instance of HttpStreamingResponse.
- #to_s ⇒ Object
Constructor Details
#initialize(request, host, port = nil) ⇒ HttpStreamingResponse
Returns a new instance of HttpStreamingResponse.
10 11 12 |
# File 'lib/rack/http_streaming_response.rb', line 10 def initialize(request, host, port = nil) @request, @host, @port = request, host, port end |
Instance Attribute Details
#use_ssl ⇒ Object
Returns the value of attribute use_ssl.
7 8 9 |
# File 'lib/rack/http_streaming_response.rb', line 7 def use_ssl @use_ssl end |
#verify_mode ⇒ Object
Returns the value of attribute verify_mode.
8 9 10 |
# File 'lib/rack/http_streaming_response.rb', line 8 def verify_mode @verify_mode end |
Instance Method Details
#body ⇒ Object
14 15 16 |
# File 'lib/rack/http_streaming_response.rb', line 14 def body self end |
#code ⇒ Object Also known as: status
18 19 20 |
# File 'lib/rack/http_streaming_response.rb', line 18 def code response.code.to_i end |
#each(&block) ⇒ Object
Can be called only once!
35 36 37 38 39 |
# File 'lib/rack/http_streaming_response.rb', line 35 def each(&block) response.read_body(&block) ensure session.end_request_hacked end |
#headers ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/rack/http_streaming_response.rb', line 24 def headers h = Utils::HeaderHash.new response.to_hash.each do |k, v| h[k] = v end h end |
#to_s ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/rack/http_streaming_response.rb', line 41 def to_s @body ||= begin lines = [] each do |line| lines << line end lines.join end end |