MCPcopy Create free account
hub / github.com/nodejs/undici / httpsWithSocks5Example

Function httpsWithSocks5Example

docs/examples/socks5-proxy.js:78–96  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

76
77// Example with HTTPS
78async function httpsWithSocks5Example () {
79 console.log('\n=== HTTPS with SOCKS5 Proxy Example ===')
80
81 try {
82 const socks5Proxy = new Socks5Agent('socks5://localhost:1080')
83
84 const response = await request('https://httpbin.org/ip', {
85 dispatcher: socks5Proxy
86 })
87
88 console.log('Status:', response.statusCode)
89 const body = await response.body.json()
90 console.log('HTTPS Response:', body)
91
92 await socks5Proxy.close()
93 } catch (error) {
94 console.error('Error:', error.message)
95 }
96}
97
98// Example with connection pooling
99async function connectionPoolingExample () {

Callers 1

runExamplesFunction · 0.85

Calls 4

jsonMethod · 0.65
closeMethod · 0.65
requestFunction · 0.50
errorMethod · 0.45

Tested by

no test coverage detected