From 8b550a442d5221512fa74c56ec3b9a997eb5498e Mon Sep 17 00:00:00 2001 From: Miguel Terron Date: Fri, 6 Jun 2025 22:39:19 +1200 Subject: [PATCH] Basic connectivity test --- test/tool/net/fetch_proxy_test.lua | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 test/tool/net/fetch_proxy_test.lua diff --git a/test/tool/net/fetch_proxy_test.lua b/test/tool/net/fetch_proxy_test.lua new file mode 100644 index 000000000..157194791 --- /dev/null +++ b/test/tool/net/fetch_proxy_test.lua @@ -0,0 +1,36 @@ +-- Test HTTPS connections through a proxy +-- Requires a proxy to be set in the environment variables + +local function test_proxy_fetch() + if os.getenv('http_proxy') or os.getenv('https_proxy') then + local url = "http://www.google.com" + print("Testing HTTP fetch through proxy: " .. url) + + local status, headers, _ = Fetch(url) + + if status == 200 then + print("SUCCESS: Proxy connection worked") + print("Status code: " .. status) + else + print("FAILED: Proxy connection failed") + print("Reason: " .. headers) + end + + url = "https://www.google.com" + print("Testing HTTPS fetch through proxy: " .. url) + + local status2, headers2, _ = Fetch(url) + + if status2 == 200 then + print("SUCCESS: Proxy connection worked") + print("Status code: " .. status2) + else + print("FAILED: Proxy connection failed") + print("Reason: " .. headers2) + end + else + print("Skipping test: No proxy environment variables set (http_proxy or https_proxy)") + end +end + +test_proxy_fetch()