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 Method Summary collapse
- #body ⇒ Object
-
#each(&block) ⇒ Object
Can be called only once!.
- #headers ⇒ Object
-
#initialize(request, host, port = nil) ⇒ HttpStreamingResponse
constructor
A new instance of HttpStreamingResponse.
- #status ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(request, host, port = nil) ⇒ HttpStreamingResponse
Returns a new instance of HttpStreamingResponse.
7 8 9 |
# File 'lib/rack/http_streaming_response.rb', line 7 def initialize(request, host, port = nil) @request, @host, @port = request, host, port end |
Instance Method Details
#body ⇒ Object
25 26 27 |
# File 'lib/rack/http_streaming_response.rb', line 25 def body self end |
#each(&block) ⇒ Object
Can be called only once!
30 31 32 33 34 |
# File 'lib/rack/http_streaming_response.rb', line 30 def each(&block) response.read_body(&block) ensure session.end_request_hacked end |
#headers ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/rack/http_streaming_response.rb', line 15 def headers h = Utils::HeaderHash.new response.each_header do |k, v| h[k] = v end h end |
#status ⇒ Object
11 12 13 |
# File 'lib/rack/http_streaming_response.rb', line 11 def status response.code.to_i end |
#to_s ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rack/http_streaming_response.rb', line 36 def to_s @body ||= begin lines = [] each do |line| lines << line end lines.join end end |