mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-12 22:19:10 +00:00
Basic connectivity test
This commit is contained in:
parent
4f92fefd31
commit
8b550a442d
1 changed files with 36 additions and 0 deletions
36
test/tool/net/fetch_proxy_test.lua
Normal file
36
test/tool/net/fetch_proxy_test.lua
Normal file
|
@ -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()
|
Loading…
Add table
Add a link
Reference in a new issue