Skip to content

Commit 563313d

Browse files
committed
refactor(event): rename event.body to event.rawBody
1 parent aa2e5d9 commit 563313d

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/event/event.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ export class H3Event<
9393
return this.node.res;
9494
}
9595

96-
get body() {
96+
/** @experimental */
97+
get rawBody() {
9798
if (!this._hasBody) {
9899
return undefined;
99100
}
@@ -123,7 +124,7 @@ export class H3Event<
123124
duplex: "half",
124125
method: this.method,
125126
headers: this.headers,
126-
body: this.body,
127+
body: this.rawBody,
127128
});
128129
}
129130
return this._request;

src/utils/proxy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function proxyRequest(
4040
let duplex: Duplex | undefined;
4141
if (PayloadMethods.has(event.method)) {
4242
if (opts.streamRequest) {
43-
body = event.body;
43+
body = event.rawBody;
4444
duplex = "half";
4545
} else {
4646
body = await readRawBody(event, false).catch(() => undefined);

test/event.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe("Event", () => {
5757
app.use(
5858
"/",
5959
eventHandler(async (event) => {
60-
const bodyStream = event.body as unknown as NodeJS.ReadableStream;
60+
const bodyStream = event.rawBody as unknown as NodeJS.ReadableStream;
6161
let bytes = 0;
6262
for await (const chunk of bodyStream) {
6363
bytes += chunk.length;

0 commit comments

Comments
 (0)