@@ -293,6 +293,40 @@ func TestProxyServerCONNECT(t *testing.T) {
293
293
require .Equal (t , expectedResponse , string (body ))
294
294
})
295
295
296
+ // Test HTTP request through proxy transport
297
+ t .Run ("HTTPRequestThroughProxyTransport" , func (t * testing.T ) {
298
+ // Create proxy URL
299
+ proxyURL , err := url .Parse ("http://localhost:8080" )
300
+ require .NoError (t , err )
301
+
302
+ // Create HTTP client with proxy transport
303
+ client := & http.Client {
304
+ Transport : & http.Transport {
305
+ Proxy : http .ProxyURL (proxyURL ),
306
+ },
307
+ Timeout : 10 * time .Second ,
308
+ }
309
+
310
+ // For HTTP requests, Go will send the request directly to the proxy
311
+ // The proxy will forward it to the target server
312
+ resp , err := client .Get ("http://jsonplaceholder.typicode.com/todos/1" )
313
+ require .NoError (t , err )
314
+ defer resp .Body .Close ()
315
+
316
+ // Read response
317
+ body , err := io .ReadAll (resp .Body )
318
+ require .NoError (t , err )
319
+
320
+ // Verify response contains expected content
321
+ expectedResponse := `{
322
+ "userId": 1,
323
+ "id": 1,
324
+ "title": "delectus aut autem",
325
+ "completed": false
326
+ }`
327
+ require .Equal (t , expectedResponse , string (body ))
328
+ })
329
+
296
330
err = server .Stop ()
297
331
require .NoError (t , err )
298
332
}
0 commit comments