lib/httpx/client.rb in httpx-0.0.2 vs lib/httpx/client.rb in httpx-0.0.3

- old
+ new

@@ -3,14 +3,18 @@ module HTTPX class Client include Loggable include Chainable - def initialize(options = {}) + def initialize(options = {}, &blk) @options = self.class.default_options.merge(options) @connection = Connection.new(@options) @responses = {} + wrap(&blk) if block_given? + end + + def wrap return unless block_given? begin @keep_open = true yield self ensure @@ -105,10 +109,10 @@ responses << response requests.shift break if requests.empty? rescue TimeoutError => e - responses << ErrorResponse.new(e.message, 0) while requests.shift + responses << ErrorResponse.new(e, 0, @options) while requests.shift @connection.reset break end end responses