From 002607f634c197af7a47094563d47df3832fa4fa Mon Sep 17 00:00:00 2001 From: Lewis Crichton Date: Thu, 16 Feb 2023 20:56:29 +0000 Subject: [PATCH] 413 + bytelength --- src/index.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 505d4f2..307fd9b 100644 --- a/src/index.ts +++ b/src/index.ts @@ -100,11 +100,11 @@ fastify.get("/settings", async (request, response) => { fastify.put("/settings", async (request, response) => { if (request.headers["content-type"] !== "application/octet-stream") { - return response.status(400).send({ error: "Content type must be `application/octet-stream`" }); + return response.status(413).send({ error: "Content type must be `application/octet-stream`" }); } - if ((request.body as Buffer).length > SIZE_LIMIT) { - return response.status(400).send({ error: "Settings are too large" }); + if ((request.body as Buffer).byteLength > SIZE_LIMIT) { + return response.status(413).send({ error: "Settings are too large" }); } const now = Date.now();