ruby-changes:74205
From: nagachika <ko1@a...>
Date: Sat, 22 Oct 2022 17:09:35 +0900 (JST)
Subject: [ruby-changes:74205] 3f3aebc237 (ruby_3_1): merge revision(s) ac1bb6b51032ad8d34a1060f5f6b5b10b60dc183:
https://git.ruby-lang.org/ruby.git/commit/?id=3f3aebc237 From 3f3aebc23729f53c8c3564a33e7b83fc02072449 Mon Sep 17 00:00:00 2001 From: nagachika <nagachika@r...> Date: Sat, 22 Oct 2022 17:08:38 +0900 Subject: merge revision(s) ac1bb6b51032ad8d34a1060f5f6b5b10b60dc183: [ruby/net-http] Rename `D` to `debug` in `Net::HTTP` Renames `D` to `debug` in `Net::HTTP` and introduces an alias for backwards compatibility. This was done for readability reasons, in that `D` did not clearly reflect what the method was doing and can cause some confusion. https://github.com/ruby/net-http/commit/582d6e87d6 --- lib/net/http.rb | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) --- lib/net/http.rb | 33 ++++++++++++++++++--------------- version.h | 4 ++-- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/lib/net/http.rb b/lib/net/http.rb index 552f818e5d..f004bce836 100644 --- a/lib/net/http.rb +++ b/lib/net/http.rb @@ -993,7 +993,7 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L993 conn_port = port end - D "opening connection to #{conn_addr}:#{conn_port}..." + debug "opening connection to #{conn_addr}:#{conn_port}..." begin s = Socket.tcp conn_addr, conn_port, @local_host, @local_port, connect_timeout: @open_timeout rescue => e @@ -1002,7 +1002,7 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1002 "#{conn_addr}:#{conn_port} (#{e.message})" end s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) - D "opened" + debug "opened" if use_ssl? if proxy? plain_sock = BufferedIO.new(s, read_timeout: @read_timeout, @@ -1036,7 +1036,7 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1036 OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT | OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE @ssl_context.session_new_cb = proc {|sock, sess| @ssl_session = sess } - D "starting SSL for #{conn_addr}:#{conn_port}..." + debug "starting SSL for #{conn_addr}:#{conn_port}..." s = OpenSSL::SSL::SSLSocket.new(s, @ssl_context) s.sync_close = true # Server Name Indication (SNI) RFC 3546 @@ -1049,7 +1049,7 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1049 if (@ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE) && @ssl_context.verify_hostname s.post_connection_check(@address) end - D "SSL established, protocol: #{s.ssl_version}, cipher: #{s.cipher[0]}" + debug "SSL established, protocol: #{s.ssl_version}, cipher: #{s.cipher[0]}" end @socket = BufferedIO.new(s, read_timeout: @read_timeout, write_timeout: @write_timeout, @@ -1059,7 +1059,7 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1059 on_connect rescue => exception if s - D "Conn close because of connect error #{exception}" + debug "Conn close because of connect error #{exception}" s.close end raise @@ -1593,10 +1593,10 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1593 if count < max_retries && IDEMPOTENT_METHODS_.include?(req.method) count += 1 @socket.close if @socket - D "Conn close because of error #{exception}, and retry" + debug "Conn close because of error #{exception}, and retry" retry end - D "Conn close because of error #{exception}" + debug "Conn close because of error #{exception}" @socket.close if @socket raise end @@ -1604,7 +1604,7 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1604 end_transport req, res res rescue => exception - D "Conn close because of error #{exception}" + debug "Conn close because of error #{exception}" @socket.close if @socket raise exception end @@ -1614,11 +1614,11 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1614 connect elsif @last_communicated if @last_communicated + @keep_alive_timeout < Process.clock_gettime(Process::CLOCK_MONOTONIC) - D 'Conn close because of keep_alive_timeout' + debug 'Conn close because of keep_alive_timeout' @socket.close connect elsif @socket.io.to_io.wait_readable(0) && @socket.eof? - D "Conn close because of EOF" + debug "Conn close because of EOF" @socket.close connect end @@ -1636,15 +1636,15 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1636 @curr_http_version = res.http_version @last_communicated = nil if @socket.closed? - D 'Conn socket closed' + debug 'Conn socket closed' elsif not res.body and @close_on_empty_response - D 'Conn close' + debug 'Conn close' @socket.close elsif keep_alive?(req, res) - D 'Conn keep-alive' + debug 'Conn keep-alive' @last_communicated = Process.clock_gettime(Process::CLOCK_MONOTONIC) else - D 'Conn close' + debug 'Conn close' @socket.close end end @@ -1699,11 +1699,14 @@ module Net #:nodoc: https://github.com/ruby/ruby/blob/trunk/lib/net/http.rb#L1699 default_port == port ? addr : "#{addr}:#{port}" end - def D(msg) + # Adds a message to debugging output + def debug(msg) return unless @debug_output @debug_output << msg @debug_output << "\n" end + + alias_method :D, :debug end end diff --git a/version.h b/version.h index c8d9caaabf..4c2ba43f94 100644 --- a/version.h +++ b/version.h @@ -11,11 +11,11 @@ https://github.com/ruby/ruby/blob/trunk/version.h#L11 # define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR #define RUBY_VERSION_TEENY 3 #define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR -#define RUBY_PATCHLEVEL 165 +#define RUBY_PATCHLEVEL 166 #define RUBY_RELEASE_YEAR 2022 #define RUBY_RELEASE_MONTH 10 -#define RUBY_RELEASE_DAY 21 +#define RUBY_RELEASE_DAY 22 #include "ruby/version.h" -- cgit v1.2.3 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/