lib/async/http/client.rb in async-http-0.9.0 vs lib/async/http/client.rb in async-http-0.10.0
- old
+ new
@@ -23,18 +23,23 @@
require_relative 'protocol'
module Async
module HTTP
class Client
- def initialize(endpoint, protocol = Protocol::HTTPS, **options)
+ def initialize(endpoint, protocol = nil, authority = nil, **options)
@endpoint = endpoint
- @protocol = protocol
+ @protocol = protocol || endpoint.protocol
+ @authority = authority || endpoint.hostname
@connections = connect(**options)
end
+ attr :endpoint
+ attr :protocol
+ attr :authority
+
def self.open(*args, &block)
client = self.new(*args)
return client unless block_given?
@@ -57,10 +62,10 @@
end
end
def request(*args)
@connections.acquire do |connection|
- connection.send_request(*args)
+ connection.send_request(@authority, *args)
end
end
protected