diff --git a/.gitignore b/.gitignore index 71678ae..ac60f41 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /TAGS /doc /pkg +.idea diff --git a/lib/net/http/persistent.rb b/lib/net/http/persistent.rb index 18e5729..2f5ebc8 100644 --- a/lib/net/http/persistent.rb +++ b/lib/net/http/persistent.rb @@ -406,6 +406,11 @@ def self.detect_idle_timeout uri, max = 10 attr_accessor :read_timeout + ## + # Seconds to wait until writing one block. See Net::HTTP#write_timeout + + attr_accessor :write_timeout + ## # By default SSL sessions are reused to avoid extra SSL handshakes. Set # this to false if you have problems communicating with an HTTPS server @@ -530,6 +535,7 @@ def initialize name: nil, proxy: nil, pool_size: DEFAULT_POOL_SIZE @keep_alive = 30 @open_timeout = nil @read_timeout = nil + @write_timeout = nil @idle_timeout = 5 @max_requests = nil @socket_options = [] @@ -643,6 +649,7 @@ def connection_for uri end http.read_timeout = @read_timeout if @read_timeout + http.write_timeout = @write_timeout if @write_timeout && http.respond_to?(:write_timeout=) http.keep_alive_timeout = @idle_timeout if @idle_timeout return yield connection