413 + bytelength

This commit is contained in:
Lewis Crichton
2023-02-16 20:56:29 +00:00
parent 1700198cb2
commit 002607f634
+3 -3
View File
@@ -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();