aboutsummaryrefslogtreecommitdiff
path: root/test/js/node/http/node-http.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/js/node/http/node-http.test.ts')
-rw-r--r--test/js/node/http/node-http.test.ts40
1 files changed, 40 insertions, 0 deletions
diff --git a/test/js/node/http/node-http.test.ts b/test/js/node/http/node-http.test.ts
index b8302c1d8..5e3e1fd8f 100644
--- a/test/js/node/http/node-http.test.ts
+++ b/test/js/node/http/node-http.test.ts
@@ -9,6 +9,7 @@ import {
validateHeaderName,
validateHeaderValue,
} from "node:http";
+import * as http from "node:http";
import { createTest } from "node-harness";
import url from "node:url";
import { tmpdir } from "node:os";
@@ -852,6 +853,18 @@ describe("node:http", () => {
});
});
+ test("should not decompress gzip, issue#4397", async () => {
+ const { promise, resolve } = Promise.withResolvers();
+ request("https://bun.sh/", { headers: { "accept-encoding": "gzip" } }, res => {
+ res.on("data", function cb(chunk) {
+ resolve(chunk);
+ res.off("data", cb);
+ });
+ }).end();
+ const chunk = await promise;
+ expect(chunk.toString()).not.toContain("<html");
+ });
+
test("test unix socket server", done => {
const socketPath = `${tmpdir()}/bun-server-${Math.random().toString(32)}.sock`;
const server = createServer((req, res) => {
@@ -908,4 +921,31 @@ describe("node:http", () => {
}
});
});
+
+ test("IncomingMessage.statusMessage is overridable", done => {
+ const server = createServer((req, res) => {
+ // From `got` library
+ const statusCode = res.statusCode;
+ res.statusMessage = http.STATUS_CODES[statusCode];
+ res.url = "any";
+ res.requestUrl = "any";
+ res.redirectUrls = "any";
+ res.request = "any";
+ res.isFromCache = "any";
+ res.ip = "any";
+ res.retryCount = "any";
+ res.ok = true;
+ res.end("success");
+ });
+ server.listen({ port: 0 }, async (_err, host, port) => {
+ try {
+ await fetch(`http://${host}:${port}`).then(res => {
+ expect(res.status).toBe(200);
+ done();
+ });
+ } catch (err) {
+ done(err);
+ }
+ });
+ });
});