net-http 0.8.0 → 0.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.document +1 -0
- data/lib/net/http.rb +29 -29
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ad9408074d86908c8284d26a13f9ba35d86948726c5e42ce453d40639be9d255
|
|
4
|
+
data.tar.gz: b23103da88f3b5cf36274fb39b07e6889c86fbe6e9abf4cb86ed6bc2c9ce9448
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5448ae667eff55826562b25f79a8f2e2991a79e1a763d1695429286b59e7e1ef25ffe2c22d9320dcf112daca3571112c7baae4a34c1b43caed6b0a944974c089
|
|
7
|
+
data.tar.gz: 7679a6cf608155d9dabb09a9ed969deddb315662d220087fb80ba2b4e6f9d8519c714c501048b5c55a48625bb013313435461813197c63f0de6aed4dbabd68dc
|
data/lib/net/http.rb
CHANGED
|
@@ -724,7 +724,7 @@ module Net #:nodoc:
|
|
|
724
724
|
class HTTP < Protocol
|
|
725
725
|
|
|
726
726
|
# :stopdoc:
|
|
727
|
-
VERSION = "0.
|
|
727
|
+
VERSION = "0.9.1"
|
|
728
728
|
HTTPVersion = '1.1'
|
|
729
729
|
begin
|
|
730
730
|
require 'zlib'
|
|
@@ -1323,7 +1323,7 @@ module Net #:nodoc:
|
|
|
1323
1323
|
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
|
1324
1324
|
attr_writer :proxy_pass
|
|
1325
1325
|
|
|
1326
|
-
# Sets
|
|
1326
|
+
# Sets whether the proxy uses SSL;
|
|
1327
1327
|
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
|
1328
1328
|
attr_writer :proxy_use_ssl
|
|
1329
1329
|
|
|
@@ -1531,7 +1531,7 @@ module Net #:nodoc:
|
|
|
1531
1531
|
:verify_depth,
|
|
1532
1532
|
:verify_mode,
|
|
1533
1533
|
:verify_hostname,
|
|
1534
|
-
] # :nodoc:
|
|
1534
|
+
].freeze # :nodoc:
|
|
1535
1535
|
|
|
1536
1536
|
SSL_IVNAMES = SSL_ATTRIBUTES.map { |a| "@#{a}".to_sym }.freeze # :nodoc:
|
|
1537
1537
|
|
|
@@ -1674,32 +1674,11 @@ module Net #:nodoc:
|
|
|
1674
1674
|
|
|
1675
1675
|
debug "opening connection to #{conn_addr}:#{conn_port}..."
|
|
1676
1676
|
begin
|
|
1677
|
-
s =
|
|
1678
|
-
case @tcpsocket_supports_open_timeout
|
|
1679
|
-
when nil, true
|
|
1680
|
-
begin
|
|
1681
|
-
# Use built-in timeout in TCPSocket.open if available
|
|
1682
|
-
sock = TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
|
|
1683
|
-
@tcpsocket_supports_open_timeout = true
|
|
1684
|
-
sock
|
|
1685
|
-
rescue ArgumentError => e
|
|
1686
|
-
raise if !(e.message.include?('unknown keyword: :open_timeout') || e.message.include?('wrong number of arguments (given 5, expected 2..4)'))
|
|
1687
|
-
@tcpsocket_supports_open_timeout = false
|
|
1688
|
-
|
|
1689
|
-
# Fallback to Timeout.timeout if TCPSocket.open does not support open_timeout
|
|
1690
|
-
Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
|
1691
|
-
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
|
|
1692
|
-
}
|
|
1693
|
-
end
|
|
1694
|
-
when false
|
|
1695
|
-
# The current Ruby is known to not support TCPSocket(open_timeout:).
|
|
1696
|
-
# Directly fall back to Timeout.timeout to avoid performance penalty incured by rescue.
|
|
1697
|
-
Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
|
1698
|
-
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
|
|
1699
|
-
}
|
|
1700
|
-
end
|
|
1677
|
+
s = timeouted_connect(conn_addr, conn_port)
|
|
1701
1678
|
rescue => e
|
|
1702
|
-
|
|
1679
|
+
if (defined?(IO::TimeoutError) && e.is_a?(IO::TimeoutError)) || e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
|
|
1680
|
+
e = Net::OpenTimeout.new(e)
|
|
1681
|
+
end
|
|
1703
1682
|
raise e, "Failed to open TCP connection to " +
|
|
1704
1683
|
"#{conn_addr}:#{conn_port} (#{e.message})"
|
|
1705
1684
|
end
|
|
@@ -1795,6 +1774,27 @@ module Net #:nodoc:
|
|
|
1795
1774
|
end
|
|
1796
1775
|
private :connect
|
|
1797
1776
|
|
|
1777
|
+
tcp_socket_parameters = TCPSocket.instance_method(:initialize).parameters
|
|
1778
|
+
TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT = if tcp_socket_parameters != [[:rest]]
|
|
1779
|
+
tcp_socket_parameters.include?([:key, :open_timeout])
|
|
1780
|
+
else
|
|
1781
|
+
# Use Socket.tcp to find out since there is no parameters information for TCPSocket#initialize
|
|
1782
|
+
# See discussion in https://github.com/ruby/net-http/pull/224
|
|
1783
|
+
Socket.method(:tcp).parameters.include?([:key, :open_timeout])
|
|
1784
|
+
end
|
|
1785
|
+
private_constant :TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
|
|
1786
|
+
|
|
1787
|
+
def timeouted_connect(conn_addr, conn_port)
|
|
1788
|
+
if TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
|
|
1789
|
+
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
|
|
1790
|
+
else
|
|
1791
|
+
Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
|
1792
|
+
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
|
|
1793
|
+
}
|
|
1794
|
+
end
|
|
1795
|
+
end
|
|
1796
|
+
private :timeouted_connect
|
|
1797
|
+
|
|
1798
1798
|
def on_connect
|
|
1799
1799
|
end
|
|
1800
1800
|
private :on_connect
|
|
@@ -2430,7 +2430,7 @@ module Net #:nodoc:
|
|
|
2430
2430
|
|
|
2431
2431
|
# :stopdoc:
|
|
2432
2432
|
|
|
2433
|
-
IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE
|
|
2433
|
+
IDEMPOTENT_METHODS_ = %w/GET HEAD PUT DELETE OPTIONS TRACE/.freeze # :nodoc:
|
|
2434
2434
|
|
|
2435
2435
|
def transport_request(req)
|
|
2436
2436
|
count = 0
|