@@ -69,19 +69,18 @@ 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-
7572 default_port = self .default_port
76- 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
73+
74+ # proxies go through set_tunnel
75+ tunnel_host = getattr ( self , "_tunnel_host" , None )
76+ if tunnel_host :
77+ host = tunnel_host
78+ port = getattr ( self , "_tunnel_port" , None )
8279 else :
80+ host = self .host
8381 port = self .port
8482
83+
8584 client = sentry_sdk .get_client ()
8685 if client .get_integration (StdlibIntegration ) is None or is_sentry_url (
8786 client , host
@@ -113,10 +112,10 @@ def putrequest(
113112 span .set_data (SPANDATA .HTTP_QUERY , parsed_url .query )
114113 span .set_data (SPANDATA .HTTP_FRAGMENT , parsed_url .fragment )
115114
116- # Set network peer address and port (the actual connection endpoint)
117115 # 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 )
116+ if tunnel_host :
117+ span .set_data (SPANDATA .NETWORK_PEER_ADDRESS , self .host )
118+ span .set_data (SPANDATA .NETWORK_PEER_PORT , self .port )
120119
121120 rv = real_putrequest (self , method , url , * args , ** kwargs )
122121
0 commit comments