Skip to content

Commit

Permalink
[https-proxy-agent] Emit "proxyConnect" event on Agent (#156)
Browse files Browse the repository at this point in the history
Closes #153.
  • Loading branch information
TooTallNate committed May 5, 2023
1 parent 7674748 commit c573dbe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/perfect-terms-tie.md
@@ -0,0 +1,5 @@
---
'https-proxy-agent': minor
---

Emit "proxyConnect" event on Agent instance
1 change: 1 addition & 0 deletions packages/https-proxy-agent/src/index.ts
Expand Up @@ -132,6 +132,7 @@ export class HttpsProxyAgent<Uri extends string> extends Agent {

const { connect, buffered } = await proxyResponsePromise;
req.emit('proxyConnect', connect);
this.emit('proxyConnect', connect, req);

if (connect.statusCode === 200) {
req.once('socket', resume);
Expand Down
6 changes: 5 additions & 1 deletion packages/https-proxy-agent/test/test.ts
Expand Up @@ -126,7 +126,11 @@ describe('HttpsProxyAgent', () => {
rejectUnauthorized: false,
});

const res = await req(serverUrl, { agent });
const r = req(serverUrl, { agent });
const [connect] = await once(agent, 'proxyConnect');
expect(connect.statusCode).toEqual(200);
expect(connect.statusText).toEqual('Connection established');
const res = await r;
const body = await json(res);
assert.equal(serverUrl.host, body.host);
});
Expand Down

1 comment on commit c573dbe

@vercel
Copy link

@vercel vercel bot commented on c573dbe May 5, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

proxy-agents – ./

proxy-agents-tootallnate.vercel.app
proxy-agents-git-main-tootallnate.vercel.app
proxy-agents.vercel.app

Please sign in to comment.