@@ -993,7 +993,7 @@ def connect
993
993
conn_port = port
994
994
end
995
995
996
- D "opening connection to #{ conn_addr } :#{ conn_port } ..."
996
+ debug "opening connection to #{ conn_addr } :#{ conn_port } ..."
997
997
begin
998
998
s = Socket . tcp conn_addr , conn_port , @local_host , @local_port , connect_timeout : @open_timeout
999
999
rescue => e
@@ -1002,7 +1002,7 @@ def connect
1002
1002
"#{ conn_addr } :#{ conn_port } (#{ e . message } )"
1003
1003
end
1004
1004
s . setsockopt ( Socket ::IPPROTO_TCP , Socket ::TCP_NODELAY , 1 )
1005
- D "opened"
1005
+ debug "opened"
1006
1006
if use_ssl?
1007
1007
if proxy?
1008
1008
plain_sock = BufferedIO . new ( s , read_timeout : @read_timeout ,
@@ -1036,7 +1036,7 @@ def connect
1036
1036
OpenSSL ::SSL ::SSLContext ::SESSION_CACHE_CLIENT |
1037
1037
OpenSSL ::SSL ::SSLContext ::SESSION_CACHE_NO_INTERNAL_STORE
1038
1038
@ssl_context . session_new_cb = proc { |sock , sess | @ssl_session = sess }
1039
- D "starting SSL for #{ conn_addr } :#{ conn_port } ..."
1039
+ debug "starting SSL for #{ conn_addr } :#{ conn_port } ..."
1040
1040
s = OpenSSL ::SSL ::SSLSocket . new ( s , @ssl_context )
1041
1041
s . sync_close = true
1042
1042
# Server Name Indication (SNI) RFC 3546
@@ -1049,7 +1049,7 @@ def connect
1049
1049
if ( @ssl_context . verify_mode != OpenSSL ::SSL ::VERIFY_NONE ) && @ssl_context . verify_hostname
1050
1050
s . post_connection_check ( @address )
1051
1051
end
1052
- D "SSL established, protocol: #{ s . ssl_version } , cipher: #{ s . cipher [ 0 ] } "
1052
+ debug "SSL established, protocol: #{ s . ssl_version } , cipher: #{ s . cipher [ 0 ] } "
1053
1053
end
1054
1054
@socket = BufferedIO . new ( s , read_timeout : @read_timeout ,
1055
1055
write_timeout : @write_timeout ,
@@ -1059,7 +1059,7 @@ def connect
1059
1059
on_connect
1060
1060
rescue => exception
1061
1061
if s
1062
- D "Conn close because of connect error #{ exception } "
1062
+ debug "Conn close because of connect error #{ exception } "
1063
1063
s . close
1064
1064
end
1065
1065
raise
@@ -1593,18 +1593,18 @@ def transport_request(req)
1593
1593
if count < max_retries && IDEMPOTENT_METHODS_ . include? ( req . method )
1594
1594
count += 1
1595
1595
@socket . close if @socket
1596
- D "Conn close because of error #{ exception } , and retry"
1596
+ debug "Conn close because of error #{ exception } , and retry"
1597
1597
retry
1598
1598
end
1599
- D "Conn close because of error #{ exception } "
1599
+ debug "Conn close because of error #{ exception } "
1600
1600
@socket . close if @socket
1601
1601
raise
1602
1602
end
1603
1603
1604
1604
end_transport req , res
1605
1605
res
1606
1606
rescue => exception
1607
- D "Conn close because of error #{ exception } "
1607
+ debug "Conn close because of error #{ exception } "
1608
1608
@socket . close if @socket
1609
1609
raise exception
1610
1610
end
@@ -1614,11 +1614,11 @@ def begin_transport(req)
1614
1614
connect
1615
1615
elsif @last_communicated
1616
1616
if @last_communicated + @keep_alive_timeout < Process . clock_gettime ( Process ::CLOCK_MONOTONIC )
1617
- D 'Conn close because of keep_alive_timeout'
1617
+ debug 'Conn close because of keep_alive_timeout'
1618
1618
@socket . close
1619
1619
connect
1620
1620
elsif @socket . io . to_io . wait_readable ( 0 ) && @socket . eof?
1621
- D "Conn close because of EOF"
1621
+ debug "Conn close because of EOF"
1622
1622
@socket . close
1623
1623
connect
1624
1624
end
@@ -1636,15 +1636,15 @@ def end_transport(req, res)
1636
1636
@curr_http_version = res . http_version
1637
1637
@last_communicated = nil
1638
1638
if @socket . closed?
1639
- D 'Conn socket closed'
1639
+ debug 'Conn socket closed'
1640
1640
elsif not res . body and @close_on_empty_response
1641
- D 'Conn close'
1641
+ debug 'Conn close'
1642
1642
@socket . close
1643
1643
elsif keep_alive? ( req , res )
1644
- D 'Conn keep-alive'
1644
+ debug 'Conn keep-alive'
1645
1645
@last_communicated = Process . clock_gettime ( Process ::CLOCK_MONOTONIC )
1646
1646
else
1647
- D 'Conn close'
1647
+ debug 'Conn close'
1648
1648
@socket . close
1649
1649
end
1650
1650
end
@@ -1699,11 +1699,14 @@ def addr_port
1699
1699
default_port == port ? addr : "#{ addr } :#{ port } "
1700
1700
end
1701
1701
1702
- def D ( msg )
1702
+ # Adds a message to debugging output
1703
+ def debug ( msg )
1703
1704
return unless @debug_output
1704
1705
@debug_output << msg
1705
1706
@debug_output << "\n "
1706
1707
end
1708
+
1709
+ alias_method :D , :debug
1707
1710
end
1708
1711
1709
1712
end
0 commit comments