lib/persistent_http.rb in persistent_http-1.0.1 vs lib/persistent_http.rb in persistent_http-1.0.2

- old
+ new

@@ -256,11 +256,11 @@ # +req+ must be a Net::HTTPRequest subclass (see Net::HTTP for a list). # # If there is an error and the request is idempontent according to RFC 2616 # it will be retried automatically. - def request req = nil, &block + def request(req = nil, options = {}, &block) retried = false bad_response = false req = Net::HTTP::Get.new @default_path unless req @@ -271,16 +271,19 @@ req.add_field 'Connection', 'keep-alive' req.add_field 'Keep-Alive', @keep_alive @pool.with_connection do |connection| begin + options.each do |key, value| + connection.send("#{key}=", value) + end response = connection.request req, &block @http_version ||= response.http_version @count_hash[connection.object_id] += 1 return response - rescue Timeout::Error => e + rescue Timeout::Error => e due_to = "(due to #{e.message} - #{e.class})" message = error_message connection @logger.info "#{name}: Removing connection #{due_to} #{message}" if @logger remove connection raise @@ -296,10 +299,10 @@ @logger.info "#{name}: Renewing connection because of bad response #{message}" if @logger connection = renew connection retry end - rescue IOError, EOFError, Errno::ECONNABORTED, Errno::ECONNRESET, Errno::EPIPE => e + rescue IOError, EOFError, Errno::ECONNABORTED, Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::EPIPE => e due_to = "(due to #{e.message} - #{e.class})" message = error_message connection if retried or not (idempotent? req or @force_retry) @logger.info "#{name}: Removing connection #{due_to} #{message}" if @logger remove connection