diff --git a/lib/net/http.rb b/lib/net/http.rb index d44492ad..bd479e40 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -1626,23 +1626,20 @@ def peer_cert # def start # :yield: http raise IOError, 'HTTP session already opened' if @started + + @started = true + connect + if block_given? begin - do_start return yield(self) ensure - do_finish + finish end end - do_start - self - end - def do_start - connect - @started = true + self end - private :do_start def connect if use_ssl? @@ -1750,7 +1747,6 @@ def connect continue_timeout: @continue_timeout, debug_output: @debug_output) @last_communicated = nil - on_connect rescue => exception if s debug "Conn close because of connect error #{exception}" @@ -1760,10 +1756,6 @@ def connect end private :connect - def on_connect - end - private :on_connect - # Finishes the \HTTP session: # # http = Net::HTTP.new(hostname) @@ -1775,15 +1767,10 @@ def on_connect # Raises IOError if not in a session. def finish raise IOError, 'HTTP session not yet started' unless started? - do_finish - end - - def do_finish @started = false @socket.close if @socket @socket = nil end - private :do_finish # # proxy