aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar iidebyo <8409882+iidebyo@users.noreply.github.com> 2023-09-13 05:02:25 -0400
committerGravatar GitHub <noreply@github.com> 2023-09-13 02:02:25 -0700
commit9101774593288e32c7d9f0c77ab6f133628ebd10 (patch)
treeb1412c04f86c17c488f2fb1b9a9854abb6d44a03
parent9a0ea0070523c02133c634a1576c9516bde19888 (diff)
downloadbun-9101774593288e32c7d9f0c77ab6f133628ebd10.tar.gz
bun-9101774593288e32c7d9f0c77ab6f133628ebd10.tar.zst
bun-9101774593288e32c7d9f0c77ab6f133628ebd10.zip
avoid inserting extraneous"accept-encoding" header (#5057)
* add no extraneous accept-encoding header test * ensure fetch honors no decompress opt * fix format on test/js/node/http/node-http.test.ts
-rw-r--r--src/http_client_async.zig2
-rw-r--r--test/js/node/http/node-http.test.ts21
2 files changed, 22 insertions, 1 deletions
diff --git a/src/http_client_async.zig b/src/http_client_async.zig
index f06474219..79fe74899 100644
--- a/src/http_client_async.zig
+++ b/src/http_client_async.zig
@@ -2122,7 +2122,7 @@ pub fn buildRequest(this: *HTTPClient, body_len: usize) picohttp.Request {
header_count += 1;
}
- if (!override_accept_encoding) {
+ if (!override_accept_encoding and !this.disable_decompression) {
request_headers_buf[header_count] = accept_encoding_header;
header_count += 1;
}
diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts
index f80a6c631..b8302c1d8 100644
--- a/test/js/node/http/node-http.test.ts
+++ b/test/js/node/http/node-http.test.ts
@@ -241,6 +241,27 @@ describe("node:http", () => {
// });
// });
+ it("should not insert extraneous accept-encoding header", async done => {
+ try {
+ let headers;
+ var server = createServer((req, res) => {
+ headers = req.headers;
+ req.on("data", () => {});
+ req.on("end", () => {
+ res.end();
+ });
+ });
+ const url = await listen(server);
+ await fetch(url, { decompress: false });
+ expect(headers["accept-encoding"]).toBeFalsy();
+ done();
+ } catch (e) {
+ done(e);
+ } finally {
+ server.close();
+ }
+ });
+
it("should make a standard GET request when passed string as first arg", done => {
runTest(done, (server, port, done) => {
const req = request(`http://localhost:${port}`, res => {