lib/persistent_http.rb in persistent_http-2.0.0 vs lib/persistent_http.rb in persistent_http-2.0.1
- old
+ new
@@ -66,10 +66,22 @@
# The threshold in seconds for checking out a connection at which a warning
# will be logged via the logger
attr_reader :warn_timeout
##
+ # Host for the Net:HTTP connection
+ attr_reader :host
+
+ ##
+ # Port for the Net:HTTP connection
+ attr_reader :port
+
+ ##
+ # Default path for the request
+ attr_accessor :default_path
+
+ ##
# Creates a new PersistentHTTP.
#
# Set +name+ to keep your connections apart from everybody else's. Not
# required currently, but highly recommended. Your library name should be
# good enough. This parameter will be required in a future version.
@@ -89,9 +101,19 @@
@idle_timeout = options[:idle_timeout] || 10
@logger = options[:logger]
@pool_timeout = options[:pool_timeout]
@pool_size = options[:pool_size] || 1
@warn_timeout = options[:warn_timeout] || 0.5
+ @default_path = options[:default_path]
+ @host = options[:host]
+ @port = options[:port]
+ url = options[:url]
+ if url
+ url = URI.parse(url) if url.kind_of? String
+ @default_path ||= url.request_uri
+ @host ||= url.host
+ @port ||= url.port
+ end
@pool = GenePool.new(:name => name,
:pool_size => @pool_size,
:timeout => @pool_timeout,
:warn_timeout => @warn_timeout,