Skip to content

Commit 4450ae3

Browse files
authored
Merge pull request #99 from vroldanbet/add-write-timeout
adds ruby 2.6 write_timeout support
2 parents 6b60d37 + 01b9932 commit 4450ae3

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
/TAGS
44
/doc
55
/pkg
6+
.idea

lib/net/http/persistent.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,11 @@ def self.detect_idle_timeout uri, max = 10
406406

407407
attr_accessor :read_timeout
408408

409+
##
410+
# Seconds to wait until writing one block. See Net::HTTP#write_timeout
411+
412+
attr_accessor :write_timeout
413+
409414
##
410415
# By default SSL sessions are reused to avoid extra SSL handshakes. Set
411416
# 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
530535
@keep_alive = 30
531536
@open_timeout = nil
532537
@read_timeout = nil
538+
@write_timeout = nil
533539
@idle_timeout = 5
534540
@max_requests = nil
535541
@socket_options = []
@@ -643,6 +649,7 @@ def connection_for uri
643649
end
644650

645651
http.read_timeout = @read_timeout if @read_timeout
652+
http.write_timeout = @write_timeout if @write_timeout && http.respond_to?(:write_timeout=)
646653
http.keep_alive_timeout = @idle_timeout if @idle_timeout
647654

648655
return yield connection

0 commit comments

Comments
 (0)