@@ -262,6 +262,7 @@ async def _validate_gateway_url(self, url: str, headers: dict, transport_type: s
262
262
validation_client = ResilientHttpClient (client_args = {"timeout" : settings .gateway_validation_timeout , "verify" : not settings .skip_ssl_verify })
263
263
try :
264
264
async with validation_client .client .stream ("GET" , url , headers = headers , timeout = timeout ) as response :
265
+ response .raise_for_status ()
265
266
response_headers = dict (response .headers )
266
267
location = response_headers .get ("location" )
267
268
content_type = response_headers .get ("content-type" )
@@ -286,8 +287,10 @@ async def _validate_gateway_url(self, url: str, headers: dict, transport_type: s
286
287
if content_type is not None and content_type != "" and "text/event-stream" in content_type :
287
288
return True
288
289
return False
290
+ except httpx .UnsupportedProtocol as e :
291
+ logger .debug (f"Gateway URL Unsupported Protocol for { url } : { str (e )} " , exc_info = True )
292
+ return False
289
293
except Exception as e :
290
- print (str (e ))
291
294
logger .debug (f"Gateway validation failed for { url } : { str (e )} " , exc_info = True )
292
295
return False
293
296
finally :
@@ -1148,11 +1151,11 @@ async def _initialize_gateway(self, url: str, authentication: Optional[Dict[str,
1148
1151
>>> import asyncio
1149
1152
>>> async def test_params():
1150
1153
... try:
1151
- ... await service._initialize_gateway("http://invalid://url ")
1154
+ ... await service._initialize_gateway("hello// ")
1152
1155
... except Exception as e:
1153
- ... return "True" if ("Failed" in str(e ) or "GatewayConnectionError " in str(type(e).__name__)) else "False"
1154
-
1155
- >>> print ( asyncio.run(test_params() ))
1156
+ ... return isinstance(e, GatewayConnectionError ) or "Failed " in str(e)
1157
+
1158
+ >>> asyncio.run(test_params())
1156
1159
True
1157
1160
1158
1161
>>> # Test default parameters
0 commit comments