request / tunnel-agent

HTTP proxy tunneling agent. Formerly part of mikeal/request, now a standalone module.
Apache License 2.0
117 stars 105 forks source link

emit event on CONNECT response #50

Open florisvink opened 5 years ago

florisvink commented 5 years ago

Emit the tunnel CONNECT response to the parent request. This makes it possible to debug or gain insights in the tunneling process.

Example that logs a response header from the proxy service:

const onTunnelReponse = t => console.log(t.headers['x-proxy-header'])
const onRequest = r => r.once('tunnel_connect_response', onTunnelReponse)

request.get({
    url,
    proxy: `http://${puser}:${ppass}@${phost}`,
    tunnel: true
}).once('request', onRequest)

This also solves #49 (@hashexclude: I think you want the tunnel response per request)