@@ -107,10 +107,10 @@ def span_attr(span, attr, atype):
107107 return getattr (value , atype )
108108
109109
110- def collect_headers (headers , conf ):
111- if conf not in _headers :
112- _headers [conf ] = []
113- _headers [conf ].append (headers )
110+ def collect_headers (headers , http_ver , otel_mode ):
111+ if f" { http_ver } { otel_mode } " not in _headers :
112+ _headers [f" { http_ver } { otel_mode } " ] = []
113+ _headers [f" { http_ver } { otel_mode } " ].append (headers )
114114
115115
116116def simple_client (url , logger ):
@@ -122,20 +122,20 @@ def do_get(sock, path):
122122 logger .debug (f"{ http_recv = } " )
123123 return http_recv .decode ("utf-8" )
124124
125- parsed = urlparse (url )
126- port = 8443 if parsed .scheme == "https" else 8080
127- port = parsed .port if parsed .port is not None else port
128- with socket .create_connection ((parsed .hostname , port )) as sock :
129- if parsed .scheme == "https" :
125+ p_url = urlparse (url )
126+ port = 8443 if p_url .scheme == "https" else 8080
127+ port = p_url .port if p_url .port is not None else port
128+ with socket .create_connection ((p_url .hostname , port )) as sock :
129+ if p_url .scheme == "https" :
130130 ctx = ssl .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
131131 ctx .check_hostname = False
132132 ctx .verify_mode = ssl .CERT_NONE
133133 with ctx .wrap_socket (
134- sock , server_hostname = parsed .hostname
134+ sock , server_hostname = p_url .hostname
135135 ) as ssock :
136- recv = do_get (ssock , parsed .path )
136+ recv = do_get (ssock , p_url .path )
137137 else :
138- recv = do_get (sock , parsed .path )
138+ recv = do_get (sock , p_url .path )
139139 return recv
140140
141141
@@ -211,12 +211,12 @@ def response(logger, http_ver, otel_mode, url, headers):
211211 urllib3 .disable_warnings (urllib3 .exceptions .InsecureRequestWarning )
212212 with niquests .Session (multiplexed = True ) as s :
213213 if http_ver == 3 :
214- parsed = urlparse (url )
215- assert parsed .scheme == "https" , "Only https:// URLs are supported."
216- port = parsed .port if parsed .port is not None else 8443
217- s .quic_cache_layer .add_domain (parsed .hostname , port )
214+ p_url = urlparse (url )
215+ assert p_url .scheme == "https" , "Only https:// URLs are supported."
216+ port = p_url .port if p_url .port is not None else 8443
217+ s .quic_cache_layer .add_domain (p_url .hostname , port )
218218 resp = s .get (url , headers = headers , verify = False )
219- collect_headers (resp .headers , f" { http_ver } { otel_mode } " )
219+ collect_headers (resp .headers , http_ver , otel_mode )
220220 return resp .text
221221
222222
0 commit comments