MCPcopy Create free account
hub / github.com/dan-v/lambda-nat-proxy / testHTTPTraffic

Function testHTTPTraffic

test/e2e/basic_test.go:121–149  ·  view source on GitHub ↗

testHTTPTraffic tests that HTTP requests work through the proxy

()

Source from the content-addressed store, hash-verified

119
120// testHTTPTraffic tests that HTTP requests work through the proxy
121func testHTTPTraffic() error {
122 // Set up HTTP client with SOCKS5 proxy
123 proxyURL, _ := url.Parse("socks5://localhost:8080")
124 client := &http.Client{
125 Transport: &http.Transport{
126 Proxy: http.ProxyURL(proxyURL),
127 },
128 Timeout: 30 * time.Second,
129 }
130
131 // Test HTTP request
132 resp, err := client.Get("http://httpbin.org/ip")
133 if err != nil {
134 return err
135 }
136 defer resp.Body.Close()
137
138 // Read response to make sure it works
139 _, err = io.ReadAll(resp.Body)
140 if err != nil {
141 return err
142 }
143
144 if resp.StatusCode != 200 {
145 return http.ErrNotSupported
146 }
147
148 return nil
149}

Callers 1

TestBasicConnectivityFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected