Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

avoid inserting extraneous"accept-encoding" header #5057

Merged
merged 7 commits into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/http_client_async.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
21 changes: 21 additions & 0 deletions test/js/node/http/node-http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down