mirror of
https://github.com/ruby/ruby.git
synced 2025-09-20 19:14:00 +02:00
merge revision(s) ac1bb6b510
:
[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.
582d6e87d6
---
lib/net/http.rb | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
This commit is contained in:
parent
45d92966be
commit
3f3aebc237
2 changed files with 20 additions and 17 deletions
|
@ -993,7 +993,7 @@ module Net #:nodoc:
|
||||||
conn_port = port
|
conn_port = port
|
||||||
end
|
end
|
||||||
|
|
||||||
D "opening connection to #{conn_addr}:#{conn_port}..."
|
debug "opening connection to #{conn_addr}:#{conn_port}..."
|
||||||
begin
|
begin
|
||||||
s = Socket.tcp conn_addr, conn_port, @local_host, @local_port, connect_timeout: @open_timeout
|
s = Socket.tcp conn_addr, conn_port, @local_host, @local_port, connect_timeout: @open_timeout
|
||||||
rescue => e
|
rescue => e
|
||||||
|
@ -1002,7 +1002,7 @@ module Net #:nodoc:
|
||||||
"#{conn_addr}:#{conn_port} (#{e.message})"
|
"#{conn_addr}:#{conn_port} (#{e.message})"
|
||||||
end
|
end
|
||||||
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)
|
||||||
D "opened"
|
debug "opened"
|
||||||
if use_ssl?
|
if use_ssl?
|
||||||
if proxy?
|
if proxy?
|
||||||
plain_sock = BufferedIO.new(s, read_timeout: @read_timeout,
|
plain_sock = BufferedIO.new(s, read_timeout: @read_timeout,
|
||||||
|
@ -1036,7 +1036,7 @@ module Net #:nodoc:
|
||||||
OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT |
|
OpenSSL::SSL::SSLContext::SESSION_CACHE_CLIENT |
|
||||||
OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE
|
OpenSSL::SSL::SSLContext::SESSION_CACHE_NO_INTERNAL_STORE
|
||||||
@ssl_context.session_new_cb = proc {|sock, sess| @ssl_session = sess }
|
@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 = OpenSSL::SSL::SSLSocket.new(s, @ssl_context)
|
||||||
s.sync_close = true
|
s.sync_close = true
|
||||||
# Server Name Indication (SNI) RFC 3546
|
# Server Name Indication (SNI) RFC 3546
|
||||||
|
@ -1049,7 +1049,7 @@ module Net #:nodoc:
|
||||||
if (@ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE) && @ssl_context.verify_hostname
|
if (@ssl_context.verify_mode != OpenSSL::SSL::VERIFY_NONE) && @ssl_context.verify_hostname
|
||||||
s.post_connection_check(@address)
|
s.post_connection_check(@address)
|
||||||
end
|
end
|
||||||
D "SSL established, protocol: #{s.ssl_version}, cipher: #{s.cipher[0]}"
|
debug "SSL established, protocol: #{s.ssl_version}, cipher: #{s.cipher[0]}"
|
||||||
end
|
end
|
||||||
@socket = BufferedIO.new(s, read_timeout: @read_timeout,
|
@socket = BufferedIO.new(s, read_timeout: @read_timeout,
|
||||||
write_timeout: @write_timeout,
|
write_timeout: @write_timeout,
|
||||||
|
@ -1059,7 +1059,7 @@ module Net #:nodoc:
|
||||||
on_connect
|
on_connect
|
||||||
rescue => exception
|
rescue => exception
|
||||||
if s
|
if s
|
||||||
D "Conn close because of connect error #{exception}"
|
debug "Conn close because of connect error #{exception}"
|
||||||
s.close
|
s.close
|
||||||
end
|
end
|
||||||
raise
|
raise
|
||||||
|
@ -1593,10 +1593,10 @@ module Net #:nodoc:
|
||||||
if count < max_retries && IDEMPOTENT_METHODS_.include?(req.method)
|
if count < max_retries && IDEMPOTENT_METHODS_.include?(req.method)
|
||||||
count += 1
|
count += 1
|
||||||
@socket.close if @socket
|
@socket.close if @socket
|
||||||
D "Conn close because of error #{exception}, and retry"
|
debug "Conn close because of error #{exception}, and retry"
|
||||||
retry
|
retry
|
||||||
end
|
end
|
||||||
D "Conn close because of error #{exception}"
|
debug "Conn close because of error #{exception}"
|
||||||
@socket.close if @socket
|
@socket.close if @socket
|
||||||
raise
|
raise
|
||||||
end
|
end
|
||||||
|
@ -1604,7 +1604,7 @@ module Net #:nodoc:
|
||||||
end_transport req, res
|
end_transport req, res
|
||||||
res
|
res
|
||||||
rescue => exception
|
rescue => exception
|
||||||
D "Conn close because of error #{exception}"
|
debug "Conn close because of error #{exception}"
|
||||||
@socket.close if @socket
|
@socket.close if @socket
|
||||||
raise exception
|
raise exception
|
||||||
end
|
end
|
||||||
|
@ -1614,11 +1614,11 @@ module Net #:nodoc:
|
||||||
connect
|
connect
|
||||||
elsif @last_communicated
|
elsif @last_communicated
|
||||||
if @last_communicated + @keep_alive_timeout < Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
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
|
@socket.close
|
||||||
connect
|
connect
|
||||||
elsif @socket.io.to_io.wait_readable(0) && @socket.eof?
|
elsif @socket.io.to_io.wait_readable(0) && @socket.eof?
|
||||||
D "Conn close because of EOF"
|
debug "Conn close because of EOF"
|
||||||
@socket.close
|
@socket.close
|
||||||
connect
|
connect
|
||||||
end
|
end
|
||||||
|
@ -1636,15 +1636,15 @@ module Net #:nodoc:
|
||||||
@curr_http_version = res.http_version
|
@curr_http_version = res.http_version
|
||||||
@last_communicated = nil
|
@last_communicated = nil
|
||||||
if @socket.closed?
|
if @socket.closed?
|
||||||
D 'Conn socket closed'
|
debug 'Conn socket closed'
|
||||||
elsif not res.body and @close_on_empty_response
|
elsif not res.body and @close_on_empty_response
|
||||||
D 'Conn close'
|
debug 'Conn close'
|
||||||
@socket.close
|
@socket.close
|
||||||
elsif keep_alive?(req, res)
|
elsif keep_alive?(req, res)
|
||||||
D 'Conn keep-alive'
|
debug 'Conn keep-alive'
|
||||||
@last_communicated = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
@last_communicated = Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
||||||
else
|
else
|
||||||
D 'Conn close'
|
debug 'Conn close'
|
||||||
@socket.close
|
@socket.close
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1699,11 +1699,14 @@ module Net #:nodoc:
|
||||||
default_port == port ? addr : "#{addr}:#{port}"
|
default_port == port ? addr : "#{addr}:#{port}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def D(msg)
|
# Adds a message to debugging output
|
||||||
|
def debug(msg)
|
||||||
return unless @debug_output
|
return unless @debug_output
|
||||||
@debug_output << msg
|
@debug_output << msg
|
||||||
@debug_output << "\n"
|
@debug_output << "\n"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
alias_method :D, :debug
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -11,11 +11,11 @@
|
||||||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||||
#define RUBY_VERSION_TEENY 3
|
#define RUBY_VERSION_TEENY 3
|
||||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
#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_YEAR 2022
|
||||||
#define RUBY_RELEASE_MONTH 10
|
#define RUBY_RELEASE_MONTH 10
|
||||||
#define RUBY_RELEASE_DAY 21
|
#define RUBY_RELEASE_DAY 22
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue