mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
fix proxy status return (#2860)
This commit is contained in:
@@ -2717,13 +2717,13 @@ pub fn handleResponseMetadata(
|
||||
}
|
||||
|
||||
if (this.proxy_tunneling and this.proxy_tunnel == null) {
|
||||
//proxy denied connection
|
||||
if (this.state.pending_response.status_code != 200) {
|
||||
return error.ConnectionRefused;
|
||||
if (this.state.pending_response.status_code == 200) {
|
||||
//signal to continue the proxing
|
||||
return true;
|
||||
}
|
||||
|
||||
//signal to continue the proxing
|
||||
return true;
|
||||
//proxy denied connection so return proxy result (407, 403 etc)
|
||||
this.proxy_tunneling = false;
|
||||
}
|
||||
|
||||
const is_redirect = this.state.pending_response.status_code >= 300 and this.state.pending_response.status_code <= 399;
|
||||
|
||||
@@ -116,9 +116,9 @@ it("proxy non-TLS auth can fail", async () => {
|
||||
{
|
||||
try {
|
||||
const response = await fetch(url, { verbose: true, proxy: `http://localhost:${auth_proxy.port}` });
|
||||
expect(response.statusText).toBe("Proxy Authentication Required");
|
||||
expect(response.status).toBe(407);
|
||||
} catch (err) {
|
||||
expect(err).toBe("Proxy Authentication Required");
|
||||
expect(true).toBeFalsy();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,9 +128,9 @@ it("proxy non-TLS auth can fail", async () => {
|
||||
verbose: true,
|
||||
proxy: `http://squid_user:asdf123@localhost:${auth_proxy.port}`,
|
||||
});
|
||||
expect(response.statusText).toBe("Forbidden");
|
||||
expect(response.status).toBe(403);
|
||||
} catch (err) {
|
||||
expect(err).toBe("Forbidden");
|
||||
expect(true).toBeFalsy();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user