@@ -69,18 +69,11 @@ def _install_httplib() -> None:
6969 def putrequest (
7070 self : "HTTPConnection" , method : str , url : str , * args : "Any" , ** kwargs : "Any"
7171 ) -> "Any" :
72- # proxy info is in _tunnel_host/_tunnel_port
73- host = getattr (self , "_tunnel_host" , None ) or self .host
74-
75- default_port = self .default_port
72+ tunnel_host = getattr (self , "_tunnel_host" , None )
73+ host = tunnel_host or self .host
7674 tunnel_port = getattr (self , "_tunnel_port" , None )
77- if tunnel_port :
78- port = tunnel_port
79- # need to override default_port for correct url recording
80- if tunnel_port == 443 :
81- default_port = 443
82- else :
83- port = self .port
75+ port = tunnel_port or self .port
76+ default_port = self .default_port
8477
8578 client = sentry_sdk .get_client ()
8679 if client .get_integration (StdlibIntegration ) is None or is_sentry_url (
@@ -113,10 +106,11 @@ def putrequest(
113106 span .set_data (SPANDATA .HTTP_QUERY , parsed_url .query )
114107 span .set_data (SPANDATA .HTTP_FRAGMENT , parsed_url .fragment )
115108
116- # Set network peer address and port (the actual connection endpoint)
117109 # for proxies, these point to the proxy host/port
118- span .set_data (SPANDATA .NETWORK_PEER_ADDRESS , self .host )
119- span .set_data (SPANDATA .NETWORK_PEER_PORT , self .port )
110+ if tunnel_host :
111+ span .set_data (SPANDATA .NETWORK_PEER_ADDRESS , self .host )
112+ if tunnel_port :
113+ span .set_data (SPANDATA .NETWORK_PEER_PORT , self .port )
120114
121115 rv = real_putrequest (self , method , url , * args , ** kwargs )
122116
0 commit comments