aboutsummaryrefslogtreecommitdiff
path: root/test/js/web/fetch/fetch.test.ts
diff options
context:
space:
mode:
Diffstat (limited to 'test/js/web/fetch/fetch.test.ts')
-rw-r--r--test/js/web/fetch/fetch.test.ts92
1 files changed, 92 insertions, 0 deletions
diff --git a/test/js/web/fetch/fetch.test.ts b/test/js/web/fetch/fetch.test.ts
index 4f7b20d3c..8c5e27f88 100644
--- a/test/js/web/fetch/fetch.test.ts
+++ b/test/js/web/fetch/fetch.test.ts
@@ -1702,3 +1702,95 @@ it("should throw RedirectURLTooLong when location is too long", async () => {
expect(err.code).toStrictEqual("RedirectURLTooLong");
server.stop(true);
});
+
+it("304 not modified with missing content-length does not cause a request timeout", async () => {
+ const server = await Bun.listen({
+ socket: {
+ open(socket) {
+ socket.write("HTTP/1.1 304 Not Modified\r\n\r\n");
+ socket.flush();
+ setTimeout(() => {
+ socket.end();
+ }, 9999).unref();
+ },
+ data() {},
+ close() {},
+ },
+ port: 0,
+ hostname: "localhost",
+ });
+
+ const response = await fetch(`http://${server.hostname}:${server.port}/`);
+ expect(response.status).toBe(304);
+ expect(await response.arrayBuffer()).toHaveLength(0);
+ server.stop(true);
+});
+
+it("304 not modified with missing content-length and connection close does not cause a request timeout", async () => {
+ const server = await Bun.listen({
+ socket: {
+ open(socket) {
+ socket.write("HTTP/1.1 304 Not Modified\r\nConnection: close\r\n\r\n");
+ socket.flush();
+ setTimeout(() => {
+ socket.end();
+ }, 9999).unref();
+ },
+ data() {},
+ close() {},
+ },
+ port: 0,
+ hostname: "localhost",
+ });
+
+ const response = await fetch(`http://${server.hostname}:${server.port}/`);
+ expect(response.status).toBe(304);
+ expect(await response.arrayBuffer()).toHaveLength(0);
+ server.stop(true);
+});
+
+it("304 not modified with content-length 0 and connection close does not cause a request timeout", async () => {
+ const server = await Bun.listen({
+ socket: {
+ open(socket) {
+ socket.write("HTTP/1.1 304 Not Modified\r\nConnection: close\r\nContent-Length: 0\r\n\r\n");
+ socket.flush();
+ setTimeout(() => {
+ socket.end();
+ }, 9999).unref();
+ },
+ data() {},
+ close() {},
+ },
+ port: 0,
+ hostname: "localhost",
+ });
+
+ const response = await fetch(`http://${server.hostname}:${server.port}/`);
+ expect(response.status).toBe(304);
+ expect(await response.arrayBuffer()).toHaveLength(0);
+ server.stop(true);
+});
+
+it("304 not modified with 0 content-length does not cause a request timeout", async () => {
+ const server = await Bun.listen({
+ socket: {
+ open(socket) {
+ socket.write("HTTP/1.1 304 Not Modified\r\nContent-Length: 0\r\n\r\n");
+ socket.flush();
+ setTimeout(() => {
+ socket.end();
+ }, 9999).unref();
+ },
+ data() {},
+ close() {},
+ },
+ port: 0,
+ hostname: "localhost",
+ });
+
+ const response = await fetch(`http://${server.hostname}:${server.port}/`);
+ expect(response.status).toBe(304);
+ expect(await response.arrayBuffer()).toHaveLength(0);
+ server.stop(true);
+});
span>/+75 2023-10-16Fix use before define bug in sqliteGravatar Ashcon Partovi 2-5/+5 2023-10-16fix(jest): fix toStrictEqual on same URLs (#6528)Gravatar João Alisson 2-13/+16 2023-10-16Fix `toHaveBeenCalled` having wrong error signatureGravatar Ashcon Partovi 1-2/+2 2023-10-16Fix formattingGravatar Ashcon Partovi 1-2/+1 2023-10-16Add `reusePort` to `Bun.serve` typesGravatar Ashcon Partovi 1-0/+9 2023-10-16Fix `request.url` having incorrect portGravatar Ashcon Partovi 4-1/+92 2023-10-16Remove uWebSockets header from Bun.serve responsesGravatar Ashcon Partovi 1-6/+6 2023-10-16Rename some testsGravatar Ashcon Partovi 3-0/+0 2023-10-16Fix #6467Gravatar Ashcon Partovi 2-3/+10 2023-10-16Update InternalModuleRegistryConstants.hGravatar Dylan Conway 1-3/+3 2023-10-16Development -> Contributing (#6538)Gravatar Colin McDonnell 2-1/+1 2023-10-14fix(net/tls) fix pg hang on end + hanging on query (#6487)Gravatar Ciro Spaciari 3-8/+36 2023-10-13fix installing dependencies that match workspace versions (#6494)Gravatar Dylan Conway 4-2/+64 2023-10-13fix lockfile struct padding (#6495)Gravatar Dylan Conway 3-3/+18