h3 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +4 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.mjs +4 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -155,6 +155,9 @@ function readRawBody(event, encoding = "utf-8") {
|
|
|
155
155
|
if ("body" in event.req) {
|
|
156
156
|
return Promise.resolve(event.req.body);
|
|
157
157
|
}
|
|
158
|
+
if (!parseInt(event.req.headers["content-length"] || "")) {
|
|
159
|
+
return Promise.resolve(void 0);
|
|
160
|
+
}
|
|
158
161
|
const promise = event.req[RawBodySymbol] = new Promise((resolve, reject) => {
|
|
159
162
|
const bodyData = [];
|
|
160
163
|
event.req.on("error", (err) => {
|
|
@@ -309,7 +312,7 @@ function writeEarlyHints(event, hints, cb = noop) {
|
|
|
309
312
|
let hint = "HTTP/1.1 103 Early Hints";
|
|
310
313
|
if (hints.link) {
|
|
311
314
|
hint += `\r
|
|
312
|
-
Link: ${hints.link.join("
|
|
315
|
+
Link: ${hints.link.join(", ")}`;
|
|
313
316
|
}
|
|
314
317
|
for (const [header, value] of headers) {
|
|
315
318
|
if (header === "link") {
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ declare type LazyEventHandler = () => EventHandler | Promise<EventHandler>;
|
|
|
16
16
|
|
|
17
17
|
declare type NodeListener = (req: IncomingMessage, res: ServerResponse) => void;
|
|
18
18
|
declare type NodePromisifiedHandler = (req: IncomingMessage, res: ServerResponse) => Promise<any>;
|
|
19
|
-
declare type NodeMiddleware = (req: IncomingMessage, res: ServerResponse, next
|
|
19
|
+
declare type NodeMiddleware = (req: IncomingMessage, res: ServerResponse, next: (err?: Error) => any) => any;
|
|
20
20
|
declare const defineNodeListener: (handler: NodeListener) => NodeListener;
|
|
21
21
|
declare const defineNodeMiddleware: (middleware: NodeMiddleware) => NodeMiddleware;
|
|
22
22
|
declare function fromNodeMiddleware(handler: NodeListener | NodeMiddleware): EventHandler;
|
|
@@ -159,7 +159,7 @@ declare function useBase(base: string, handler: EventHandler): EventHandler;
|
|
|
159
159
|
*
|
|
160
160
|
* @return {String|Buffer} Encoded raw string or raw Buffer of the body
|
|
161
161
|
*/
|
|
162
|
-
declare function readRawBody(event: H3Event, encoding?: Encoding): Encoding extends false ? Buffer : Promise<string | Buffer>;
|
|
162
|
+
declare function readRawBody(event: H3Event, encoding?: Encoding): Encoding extends false ? Buffer : Promise<string | Buffer | undefined>;
|
|
163
163
|
/** @deprecated Use `h3.readRawBody` */
|
|
164
164
|
declare const useRawBody: typeof readRawBody;
|
|
165
165
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -153,6 +153,9 @@ function readRawBody(event, encoding = "utf-8") {
|
|
|
153
153
|
if ("body" in event.req) {
|
|
154
154
|
return Promise.resolve(event.req.body);
|
|
155
155
|
}
|
|
156
|
+
if (!parseInt(event.req.headers["content-length"] || "")) {
|
|
157
|
+
return Promise.resolve(void 0);
|
|
158
|
+
}
|
|
156
159
|
const promise = event.req[RawBodySymbol] = new Promise((resolve, reject) => {
|
|
157
160
|
const bodyData = [];
|
|
158
161
|
event.req.on("error", (err) => {
|
|
@@ -307,7 +310,7 @@ function writeEarlyHints(event, hints, cb = noop) {
|
|
|
307
310
|
let hint = "HTTP/1.1 103 Early Hints";
|
|
308
311
|
if (hints.link) {
|
|
309
312
|
hint += `\r
|
|
310
|
-
Link: ${hints.link.join("
|
|
313
|
+
Link: ${hints.link.join(", ")}`;
|
|
311
314
|
}
|
|
312
315
|
for (const [header, value] of headers) {
|
|
313
316
|
if (header === "link") {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "h3",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.3",
|
|
4
4
|
"description": "Tiny JavaScript Server",
|
|
5
5
|
"repository": "unjs/h3",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"unbuild": "^0.9.4",
|
|
46
46
|
"vitest": "^0.24.3"
|
|
47
47
|
},
|
|
48
|
-
"packageManager": "pnpm@7.13.
|
|
48
|
+
"packageManager": "pnpm@7.13.5",
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "unbuild",
|
|
51
51
|
"dev": "vitest",
|