net-http 0.8.0 → 0.9.0
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 +24 -26
- 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: 4b248ee1b72f192c00aeaa7667d98f0e1b7c8589ca0715e074c7134ecaf79b20
|
|
4
|
+
data.tar.gz: e275a50ec3e743c3c32a89321a31589833c943a243a24196d4a9494e299badca
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d845907907e467c35bedf95eb9854fa15344f717a9a499495cdd403efdb71be40f33eaaeca01c3f949b491bd57abd03beaf1d8a75a4dd241509927596dd9d59b
|
|
7
|
+
data.tar.gz: b28a46915ac4e105b83d7de85a13707b9ed938771d41dccf7bb16019a3718b141f15974d4d413f7664fdf64c0b033566ba6666755843efe43bee1a6dfa9a581a
|
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.0"
|
|
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
|
|
|
@@ -1674,30 +1674,7 @@ 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
|
e = Net::OpenTimeout.new(e) if e.is_a?(Errno::ETIMEDOUT) # for compatibility with previous versions
|
|
1703
1680
|
raise e, "Failed to open TCP connection to " +
|
|
@@ -1795,6 +1772,27 @@ module Net #:nodoc:
|
|
|
1795
1772
|
end
|
|
1796
1773
|
private :connect
|
|
1797
1774
|
|
|
1775
|
+
tcp_socket_parameters = TCPSocket.instance_method(:initialize).parameters
|
|
1776
|
+
TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT = if tcp_socket_parameters != [[:rest]]
|
|
1777
|
+
tcp_socket_parameters.include?([:key, :open_timeout])
|
|
1778
|
+
else
|
|
1779
|
+
# Use Socket.tcp to find out since there is no parameters information for TCPSocket#initialize
|
|
1780
|
+
# See discussion in https://github.com/ruby/net-http/pull/224
|
|
1781
|
+
Socket.method(:tcp).parameters.include?([:key, :open_timeout])
|
|
1782
|
+
end
|
|
1783
|
+
private_constant :TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
|
|
1784
|
+
|
|
1785
|
+
def timeouted_connect(conn_addr, conn_port)
|
|
1786
|
+
if TCP_SOCKET_NEW_HAS_OPEN_TIMEOUT
|
|
1787
|
+
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port, open_timeout: @open_timeout)
|
|
1788
|
+
else
|
|
1789
|
+
Timeout.timeout(@open_timeout, Net::OpenTimeout) {
|
|
1790
|
+
TCPSocket.open(conn_addr, conn_port, @local_host, @local_port)
|
|
1791
|
+
}
|
|
1792
|
+
end
|
|
1793
|
+
end
|
|
1794
|
+
private :timeouted_connect
|
|
1795
|
+
|
|
1798
1796
|
def on_connect
|
|
1799
1797
|
end
|
|
1800
1798
|
private :on_connect
|