Class: Async::HTTP::Proxy
- Inherits:
-
Object
- Object
- Async::HTTP::Proxy
- Defined in:
- lib/async/http/proxy.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #connect(&block) ⇒ Object
- #endpoint(url, **options) ⇒ Object
-
#initialize(client, address, headers = []) ⇒ Proxy
constructor
A new instance of Proxy.
Constructor Details
#initialize(client, address, headers = []) ⇒ Proxy
Returns a new instance of Proxy.
33 34 35 36 37 |
# File 'lib/async/http/proxy.rb', line 33 def initialize(client, address, headers = []) @client = client @address = address @headers = headers end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
39 40 41 |
# File 'lib/async/http/proxy.rb', line 39 def client @client end |
Class Method Details
.tcp(client, host, port, headers = []) ⇒ Object
29 30 31 |
# File 'lib/async/http/proxy.rb', line 29 def self.tcp(client, host, port, headers = []) self.new(client, "#{host}:#{port}", headers) end |
Instance Method Details
#close ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/async/http/proxy.rb', line 41 def close while @client.pool.busy? @client.pool.wait end @client.close end |
#connect(&block) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/async/http/proxy.rb', line 49 def connect(&block) input = Body::Writable.new response = @client.connect(@address.to_s, @headers, input) pipe = Body::Pipe.new(response.body, input) return pipe.to_io unless block_given? begin yield pipe.to_io ensure pipe.close end end |
#endpoint(url, **options) ⇒ Object
65 66 67 |
# File 'lib/async/http/proxy.rb', line 65 def endpoint(url, **) Endpoint.parse(url, self, **) end |