Skip to content

Commit 050356b

Browse files
authored
Revert "fix: Remove content-encoding header from already decompressed respons…" (#61)
This reverts commit 822a3c3.
1 parent 822a3c3 commit 050356b

File tree

3 files changed

+2
-14
lines changed

3 files changed

+2
-14
lines changed

.changeset/dirty-moles-exercise.md

-5
This file was deleted.

packages/fetch/src/fetch.js

-3
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,6 @@ async function fetch(url, options_ = {}) {
277277

278278
// For gzip
279279
if (codings === 'gzip' || codings === 'x-gzip') {
280-
responseOptions.headers.delete("Content-Encoding");
281280
body = pump(body, zlib.createGunzip(zlibOptions), reject);
282281
response = new Response(fromAsyncIterable(body), responseOptions);
283282
resolve(response);
@@ -286,7 +285,6 @@ async function fetch(url, options_ = {}) {
286285

287286
// For deflate
288287
if (codings === 'deflate' || codings === 'x-deflate') {
289-
responseOptions.headers.delete("Content-Encoding");
290288
// Handle the infamous raw deflate response from old servers
291289
// a hack for old IIS and Apache servers
292290
const raw = pump(response_, new PassThrough(), reject);
@@ -306,7 +304,6 @@ async function fetch(url, options_ = {}) {
306304

307305
// For br
308306
if (codings === 'br') {
309-
responseOptions.headers.delete("Content-Encoding");
310307
body = pump(body, zlib.createBrotliDecompress(), reject);
311308
response = new Response(fromAsyncIterable(body), responseOptions);
312309
resolve(response);

packages/fetch/test/main.js

+2-6
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,6 @@ describe("node-fetch", () => {
818818
const url = `${base}gzip`;
819819
return fetch(url).then((res) => {
820820
expect(res.headers.get("content-type")).to.equal("text/plain");
821-
expect(res.headers.get("content-encoding")).to.be.null;
822821
return res.text().then((result) => {
823822
expect(result).to.be.a("string");
824823
expect(result).to.equal("hello world");
@@ -837,9 +836,10 @@ describe("node-fetch", () => {
837836
});
838837
});
839838

840-
it("should decompress capitalised Content-Encoding", () => {
839+
it("should make capitalised Content-Encoding lowercase", () => {
841840
const url = `${base}gzip-capital`;
842841
return fetch(url).then((res) => {
842+
expect(res.headers.get("content-encoding")).to.equal("gzip");
843843
return res.text().then((result) => {
844844
expect(result).to.be.a("string");
845845
expect(result).to.equal("hello world");
@@ -851,7 +851,6 @@ describe("node-fetch", () => {
851851
const url = `${base}deflate`;
852852
return fetch(url).then((res) => {
853853
expect(res.headers.get("content-type")).to.equal("text/plain");
854-
expect(res.headers.get("content-encoding")).to.be.null;
855854
return res.text().then((result) => {
856855
expect(result).to.be.a("string");
857856
expect(result).to.equal("hello world");
@@ -878,7 +877,6 @@ describe("node-fetch", () => {
878877
const url = `${base}brotli`;
879878
return fetch(url).then((res) => {
880879
expect(res.headers.get("content-type")).to.equal("text/plain");
881-
expect(res.headers.get("content-encoding")).to.be.null;
882880
return res.text().then((result) => {
883881
expect(result).to.be.a("string");
884882
expect(result).to.equal("hello world");
@@ -908,7 +906,6 @@ describe("node-fetch", () => {
908906
const url = `${base}sdch`;
909907
return fetch(url).then((res) => {
910908
expect(res.headers.get("content-type")).to.equal("text/plain");
911-
expect(res.headers.get("content-encoding")).to.equal("sdch");
912909
return res.text().then((result) => {
913910
expect(result).to.be.a("string");
914911
expect(result).to.equal("fake sdch string");
@@ -960,7 +957,6 @@ describe("node-fetch", () => {
960957
};
961958
return fetch(url, options).then((res) => {
962959
expect(res.headers.get("content-type")).to.equal("text/plain");
963-
expect(res.headers.get("content-encoding")).to.equal("gzip");
964960
return res.text().then((result) => {
965961
expect(result).to.be.a("string");
966962
expect(result).to.not.equal("hello world");

0 commit comments

Comments
 (0)