@@ -724,7 +724,7 @@ class HTTPHeaderSyntaxError < StandardError; end
724724 class HTTP < Protocol
725725
726726 # :stopdoc:
727- VERSION = "0.8 .0"
727+ VERSION = "0.7 .0"
728728 HTTPVersion = '1.1'
729729 begin
730730 require 'zlib'
@@ -1179,7 +1179,6 @@ def initialize(address, port = nil) # :nodoc:
11791179 @debug_output = options [ :debug_output ]
11801180 @response_body_encoding = options [ :response_body_encoding ]
11811181 @ignore_eof = options [ :ignore_eof ]
1182- @tcpsocket_supports_open_timeout = nil
11831182
11841183 @proxy_from_env = false
11851184 @proxy_uri = nil
@@ -1322,9 +1321,6 @@ def response_body_encoding=(value)
13221321 # Sets the proxy password;
13231322 # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
13241323 attr_writer :proxy_pass
1325-
1326- # Sets wheter the proxy uses SSL;
1327- # see {Proxy Server}[rdoc-ref:Gem::Net::HTTP@Proxy+Server].
13281324 attr_writer :proxy_use_ssl
13291325
13301326 # Returns the IP address for the connection.
@@ -1636,21 +1632,6 @@ def start # :yield: http
16361632 self
16371633 end
16381634
1639- # Finishes the \HTTP session:
1640- #
1641- # http = Gem::Net::HTTP.new(hostname)
1642- # http.start
1643- # http.started? # => true
1644- # http.finish # => nil
1645- # http.started? # => false
1646- #
1647- # Raises IOError if not in a session.
1648- def finish
1649- raise IOError , 'HTTP session not yet started' unless started?
1650- do_finish
1651- end
1652-
1653- # :stopdoc:
16541635 def do_start
16551636 connect
16561637 @started = true
@@ -1673,36 +1654,14 @@ def connect
16731654 end
16741655
16751656 debug "opening connection to #{ conn_addr } :#{ conn_port } ..."
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 Gem::Timeout.timeout if TCPSocket.open does not support open_timeout
1690- Gem ::Timeout . timeout ( @open_timeout , Gem ::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 Gem::Timeout.timeout to avoid performance penalty incured by rescue.
1697- Gem ::Timeout . timeout ( @open_timeout , Gem ::Net ::OpenTimeout ) {
1698- TCPSocket . open ( conn_addr , conn_port , @local_host , @local_port )
1699- }
1700- end
1701- rescue => e
1702- e = Gem ::Net ::OpenTimeout . new ( e ) if e . is_a? ( Errno ::ETIMEDOUT ) # for compatibility with previous versions
1703- raise e , "Failed to open TCP connection to " +
1704- "#{ conn_addr } :#{ conn_port } (#{ e . message } )"
1705- end
1657+ s = Gem ::Timeout . timeout ( @open_timeout , Gem ::Net ::OpenTimeout ) {
1658+ begin
1659+ TCPSocket . open ( conn_addr , conn_port , @local_host , @local_port )
1660+ rescue => e
1661+ raise e , "Failed to open TCP connection to " +
1662+ "#{ conn_addr } :#{ conn_port } (#{ e . message } )"
1663+ end
1664+ }
17061665 s . setsockopt ( Socket ::IPPROTO_TCP , Socket ::TCP_NODELAY , 1 )
17071666 debug "opened"
17081667 if use_ssl?
@@ -1799,6 +1758,20 @@ def on_connect
17991758 end
18001759 private :on_connect
18011760
1761+ # Finishes the \HTTP session:
1762+ #
1763+ # http = Gem::Net::HTTP.new(hostname)
1764+ # http.start
1765+ # http.started? # => true
1766+ # http.finish # => nil
1767+ # http.started? # => false
1768+ #
1769+ # Raises IOError if not in a session.
1770+ def finish
1771+ raise IOError , 'HTTP session not yet started' unless started?
1772+ do_finish
1773+ end
1774+
18021775 def do_finish
18031776 @started = false
18041777 @socket . close if @socket
@@ -1848,8 +1821,6 @@ def HTTP.Proxy(p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_use_ss
18481821 }
18491822 end
18501823
1851- # :startdoc:
1852-
18531824 class << HTTP
18541825 # Returns true if self is a class which was created by HTTP::Proxy.
18551826 def proxy_class?
@@ -1944,7 +1915,6 @@ def proxy_pass
19441915 alias proxyport proxy_port #:nodoc: obsolete
19451916
19461917 private
1947- # :stopdoc:
19481918
19491919 def unescape ( value )
19501920 require 'cgi/escape'
@@ -1973,7 +1943,6 @@ def edit_path(path)
19731943 path
19741944 end
19751945 end
1976- # :startdoc:
19771946
19781947 #
19791948 # HTTP operations
@@ -2428,8 +2397,6 @@ def send_entity(path, data, initheader, dest, type, &block)
24282397 res
24292398 end
24302399
2431- # :stopdoc:
2432-
24332400 IDEMPOTENT_METHODS_ = %w/ GET HEAD PUT DELETE OPTIONS TRACE / # :nodoc:
24342401
24352402 def transport_request ( req )
@@ -2587,7 +2554,7 @@ def debug(msg)
25872554 alias_method :D , :debug
25882555 end
25892556
2590- # for backward compatibility until Ruby 4.0
2557+ # for backward compatibility until Ruby 3.5
25912558 # https://bugs.ruby-lang.org/issues/20900
25922559 # https://github.com/bblimke/webmock/pull/1081
25932560 HTTPSession = HTTP
0 commit comments