diff options
author | 2023-05-12 08:06:17 -0300 | |
---|---|---|
committer | 2023-05-12 08:06:17 -0300 | |
commit | 6070e135e93cd705ff3eaf8a6b0ff0b4ec504818 (patch) | |
tree | 84936cd315ea384cab822945e4783b1fb2a6a784 | |
parent | f8c840aec70061d5cc7d2ed211a176004d3fa2d2 (diff) | |
download | bun-6070e135e93cd705ff3eaf8a6b0ff0b4ec504818.tar.gz bun-6070e135e93cd705ff3eaf8a6b0ff0b4ec504818.tar.zst bun-6070e135e93cd705ff3eaf8a6b0ff0b4ec504818.zip |
fix proxy status return (#2860)
-rw-r--r-- | src/http_client_async.zig | 10 | ||||
-rw-r--r-- | test/js/bun/http/proxy.test.js | 8 |
2 files changed, 9 insertions, 9 deletions
diff --git a/src/http_client_async.zig b/src/http_client_async.zig index 87d59778e..276186fe5 100644 --- a/src/http_client_async.zig +++ b/src/http_client_async.zig @@ -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; diff --git a/test/js/bun/http/proxy.test.js b/test/js/bun/http/proxy.test.js index 203cbc294..85bb7ecf3 100644 --- a/test/js/bun/http/proxy.test.js +++ b/test/js/bun/http/proxy.test.js @@ -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(); } } }); |