Class: Rack::StreamingProxy::Response
- Inherits:
-
Object
- Object
- Rack::StreamingProxy::Response
- Includes:
- Utils
- Defined in:
- lib/rack/streaming_proxy/response.rb
Instance Attribute Summary collapse
-
#client_http_version ⇒ Object
Returns the value of attribute client_http_version.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#each ⇒ Object
This method is called by Rack itself, to iterate over the proxied contents.
-
#initialize(piper) ⇒ Response
constructor
A new instance of Response.
Constructor Details
#initialize(piper) ⇒ Response
Returns a new instance of Response.
9 10 11 12 13 |
# File 'lib/rack/streaming_proxy/response.rb', line 9 def initialize(piper) @piper = piper @client_http_version = '1.1' receive end |
Instance Attribute Details
#client_http_version ⇒ Object
Returns the value of attribute client_http_version.
7 8 9 |
# File 'lib/rack/streaming_proxy/response.rb', line 7 def client_http_version @client_http_version end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/rack/streaming_proxy/response.rb', line 6 def headers @headers end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/rack/streaming_proxy/response.rb', line 6 def status @status end |
Instance Method Details
#each ⇒ Object
This method is called by Rack itself, to iterate over the proxied contents.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rack/streaming_proxy/response.rb', line 16 def each if @body_permitted term = "\r\n" while chunk = read_from_destination break if chunk == :done if @chunked size = chunk.bytesize next if size == 0 if @client_http_version >= '1.1' yield [size.to_s(16), term, chunk, term].join else yield chunk end else yield chunk end end finish if @chunked && @client_http_version >= '1.1' yield ['0', term, '', term].join end end end |