@@ -401,6 +401,58 @@ def test(self, config: TestConfig) -> TestResult:
401401 )
402402
403403
404+ # =============================================================================
405+ # pycurl Test
406+ # =============================================================================
407+
408+ class PycurlTest (ModuleTest ):
409+ """Test for pycurl extension."""
410+
411+ name = "pycurl"
412+
413+ def test (self , config : TestConfig ) -> TestResult :
414+ try :
415+ from python_proxy_headers .pycurl_proxy import ProxyCurl
416+
417+ # Create ProxyCurl with optional proxy headers to send
418+ with ProxyCurl (proxy_headers = config .proxy_headers_to_send or None ) as curl :
419+ # Make request through proxy
420+ response = curl .get (config .test_url , proxy = config .proxy_url )
421+
422+ # Check for proxy header in response headers (merged) or proxy_headers
423+ header_value = self ._check_header (response .headers , config .proxy_header )
424+ if not header_value :
425+ header_value = self ._check_header (response .proxy_headers , config .proxy_header )
426+
427+ if header_value :
428+ return TestResult (
429+ module_name = self .name ,
430+ success = True ,
431+ header_value = header_value ,
432+ response_status = response .status_code
433+ )
434+ else :
435+ return TestResult (
436+ module_name = self .name ,
437+ success = False ,
438+ error = f"Header '{ config .proxy_header } ' not found in response" ,
439+ response_status = response .status_code
440+ )
441+
442+ except ImportError as e :
443+ return TestResult (
444+ module_name = self .name ,
445+ success = False ,
446+ error = f"Import error: { e } "
447+ )
448+ except Exception as e :
449+ return TestResult (
450+ module_name = self .name ,
451+ success = False ,
452+ error = f"{ type (e ).__name__ } : { e } "
453+ )
454+
455+
404456# =============================================================================
405457# Test Registry
406458# =============================================================================
@@ -411,6 +463,7 @@ def test(self, config: TestConfig) -> TestResult:
411463 'requests' : RequestsTest ,
412464 'aiohttp' : AiohttpTest ,
413465 'httpx' : HttpxTest ,
466+ 'pycurl' : PycurlTest ,
414467}
415468
416469
0 commit comments