Skip to content

Commit ae01511

Browse files
authored
chore(package.json): bump to httpxy 0.5.0 (#1183)
1 parent 5b97a94 commit ae01511

4 files changed

Lines changed: 20 additions & 19 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
},
9898
"dependencies": {
9999
"debug": "^4.3.6",
100-
"httpxy": "^0.2.2",
100+
"httpxy": "^0.5.0",
101101
"is-glob": "^4.0.3",
102102
"is-plain-object": "^5.0.0",
103103
"micromatch": "^4.0.8"

src/http-proxy-middleware.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,9 @@ export class HttpProxyMiddleware<
137137
private handleUpgrade = async (req: http.IncomingMessage, socket: net.Socket, head: Buffer) => {
138138
try {
139139
if (this.shouldProxy(this.proxyOptions.pathFilter, req)) {
140-
const activeProxyOptions = await this.prepareProxyRequest(req);
141-
await this.proxy.ws(req, socket, activeProxyOptions, head);
140+
const proxiedReq = req as TReq;
141+
const activeProxyOptions = await this.prepareProxyRequest(proxiedReq);
142+
await this.proxy.ws(proxiedReq, socket, activeProxyOptions, head);
142143
debug('server upgrade event received. Proxying WebSocket');
143144
}
144145
} catch (err) {

test/e2e/router.spec.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ describe('E2E router', () => {
3434

3535
await targetServerA
3636
.forAnyRequest()
37-
.thenCallback(({ protocol }) => ({ body: protocol === 'https' ? 'A' : 'NOT HTTPS A' }));
37+
.thenCallback(({ protocol }) => ({ body: protocol === 'https' ? 'HTTPS A' : 'HTTP A' }));
3838
await targetServerB
3939
.forAnyRequest()
40-
.thenCallback(({ protocol }) => ({ body: protocol === 'https' ? 'B' : 'NOT HTTPS B' }));
40+
.thenCallback(({ protocol }) => ({ body: protocol === 'https' ? 'HTTPS B' : 'HTTP B' }));
4141
await targetServerC
4242
.forAnyRequest()
43-
.thenCallback(({ protocol }) => ({ body: protocol === 'https' ? 'C' : 'NOT HTTPS C' }));
43+
.thenCallback(({ protocol }) => ({ body: protocol === 'https' ? 'HTTPS C' : 'HTTP C' }));
4444

4545
await targetServerA.start(targetPortA);
4646
await targetServerB.start(targetPortB);
@@ -68,7 +68,7 @@ describe('E2E router', () => {
6868

6969
const agent = request(app);
7070
const response = await agent.get('/api').expect(200);
71-
expect(response.text).toBe('C');
71+
expect(response.text).toBe('HTTPS C');
7272
});
7373

7474
it('should work with an object', async () => {
@@ -84,7 +84,7 @@ describe('E2E router', () => {
8484
);
8585
const agent = request(app);
8686
const response = await agent.get('/api').expect(200);
87-
expect(response.text).toBe('C');
87+
expect(response.text).toBe('HTTPS C');
8888
});
8989

9090
it('should work with an async callback', async () => {
@@ -103,7 +103,7 @@ describe('E2E router', () => {
103103

104104
const agent = request(app);
105105
const response = await agent.get('/api').expect(200);
106-
expect(response.text).toBe('C');
106+
expect(response.text).toBe('HTTPS C');
107107
});
108108

109109
it('should handle promise rejection in router', async () => {
@@ -127,7 +127,7 @@ describe('E2E router', () => {
127127
expect(response.text).toBe('An error thrown in the router');
128128
});
129129

130-
it('missing a : will cause it to use http', async () => {
130+
it('missing a ":" in protocol will cause it to use https', async () => {
131131
const app = createApp(
132132
createProxyMiddleware({
133133
target: `https://localhost:${targetPortA}`,
@@ -143,7 +143,7 @@ describe('E2E router', () => {
143143

144144
const agent = request(app);
145145
const response = await agent.get('/api').expect(200);
146-
expect(response.text).toBe('NOT HTTPS C');
146+
expect(response.text).toBe('HTTPS C');
147147
});
148148
});
149149

@@ -171,25 +171,25 @@ describe('E2E router', () => {
171171
it('should proxy to option.target', async () => {
172172
const response = await agent.get('/api').expect(200);
173173

174-
expect(response.text).toBe('A');
174+
expect(response.text).toBe('HTTPS A');
175175
});
176176

177177
it('should proxy when host is "alpha.localhost"', async () => {
178178
const response = await agent.get('/api').set('host', 'alpha.localhost:6000').expect(200);
179179

180-
expect(response.text).toBe('A');
180+
expect(response.text).toBe('HTTPS A');
181181
});
182182

183183
it('should proxy when host is "beta.localhost"', async () => {
184184
const response = await agent.get('/api').set('host', 'beta.localhost:6000').expect(200);
185185

186-
expect(response.text).toBe('B');
186+
expect(response.text).toBe('HTTPS B');
187187
});
188188

189189
it('should proxy with host & path config: "localhost:6000/api"', async () => {
190190
const response = await agent.get('/api').set('host', 'localhost:6000').expect(200);
191191

192-
expect(response.text).toBe('C');
192+
expect(response.text).toBe('HTTPS C');
193193
});
194194
});
195195
});

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2566,10 +2566,10 @@ https-proxy-agent@^7.0.6:
25662566
agent-base "^7.1.2"
25672567
debug "4"
25682568

2569-
httpxy@^0.2.2:
2570-
version "0.2.2"
2571-
resolved "https://registry.yarnpkg.com/httpxy/-/httpxy-0.2.2.tgz#1603165cfd12087f2039c4a8532ce61eab5d84e5"
2572-
integrity sha512-QnS6mAOqvdmfctFaD/Kp5cwRMcaUhEmIyw2rjVYnhJb8EuAyd/79biT/50HUTKvq/PwoXYTP6J3d9TUxzHFZwA==
2569+
httpxy@^0.5.0:
2570+
version "0.5.0"
2571+
resolved "https://registry.yarnpkg.com/httpxy/-/httpxy-0.5.0.tgz#a9c53543760dee498611827a464e56e14639c0d0"
2572+
integrity sha512-qwX7QX/rK2visT10/b7bSeZWQOMlSm3svTD0pZpU+vJjNUP0YHtNv4c3z+MO+MSnGuRFWJFdCZiV+7F7dXIOzg==
25732573

25742574
husky@9.1.7:
25752575
version "9.1.7"

0 commit comments

Comments
 (0)