This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+16 -1
View File
@@ -83,7 +83,7 @@ var HonoRequest = class {
return headerData;
}
async parseBody(options) {
return this.bodyCache.parsedBody ??= await parseBody(this, options);
return parseBody(this, options);
}
#cachedBody = (key) => {
const { bodyCache, raw } = this;
@@ -147,6 +147,21 @@ var HonoRequest = class {
arrayBuffer() {
return this.#cachedBody("arrayBuffer");
}
/**
* `.bytes()` parses the request body as a `Uint8Array`.
*
* @see {@link https://hono.dev/docs/api/request#bytes}
*
* @example
* ```ts
* app.post('/entry', async (c) => {
* const body = await c.req.bytes()
* })
* ```
*/
bytes() {
return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
}
/**
* Parses the request body as a `Blob`.
* @example