mirror of
https://github.com/oven-sh/bun
synced 2026-02-09 10:28:47 +00:00
add test
This commit is contained in:
@@ -3,7 +3,7 @@ import { bunExe, bunEnv } from "harness";
|
||||
import path from "path";
|
||||
|
||||
describe("Server", () => {
|
||||
test("normlizes incoming request URLs", async () => {
|
||||
test("normalizes incoming request URLs", async () => {
|
||||
const server = Bun.serve({
|
||||
fetch(request) {
|
||||
return new Response(request.url, {
|
||||
@@ -408,4 +408,29 @@ describe("Server", () => {
|
||||
server.stop(true);
|
||||
}
|
||||
});
|
||||
|
||||
test("should accept more than 999 999 999 bytes in maxRequestSize", async () => {
|
||||
let server;
|
||||
const MAX_REQUEST_BODY_SIZE = 1000000000;
|
||||
try {
|
||||
server = Bun.serve({
|
||||
async fetch(request, server) {
|
||||
return new Response("Hi", { status: 200 });
|
||||
},
|
||||
port: 0,
|
||||
maxRequestBodySize: MAX_REQUEST_BODY_SIZE,
|
||||
});
|
||||
const url = `http://${server.hostname}:${server.port}`;
|
||||
|
||||
for (const length of [MAX_REQUEST_BODY_SIZE - 1, MAX_REQUEST_BODY_SIZE, MAX_REQUEST_BODY_SIZE + 1]) {
|
||||
const response = await fetch(url, {
|
||||
method: "POST",
|
||||
body: "A".repeat(length),
|
||||
});
|
||||
expect(response.status).toBe(length > MAX_REQUEST_BODY_SIZE ? 413 : 200);
|
||||
}
|
||||
} finally {
|
||||
server?.stop(true);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user