@whatwg-node/server 0.9.5 → 0.9.6
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/cjs/uwebsockets.js +18 -13
- package/esm/uwebsockets.js +18 -13
- package/package.json +1 -1
- package/typings/uwebsockets.d.cts +1 -1
- package/typings/uwebsockets.d.ts +1 -1
package/cjs/uwebsockets.js
CHANGED
|
@@ -70,12 +70,27 @@ function getRequestFromUWSRequest({ req, res, fetchAPI }) {
|
|
|
70
70
|
});
|
|
71
71
|
}
|
|
72
72
|
exports.getRequestFromUWSRequest = getRequestFromUWSRequest;
|
|
73
|
-
async function
|
|
73
|
+
async function forwardResponseBodyToUWSResponse({ res, response }) {
|
|
74
74
|
let resAborted = false;
|
|
75
75
|
res.onAborted(function () {
|
|
76
76
|
resAborted = true;
|
|
77
77
|
});
|
|
78
|
-
|
|
78
|
+
for await (const chunk of response.body) {
|
|
79
|
+
if (resAborted) {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
res.cork(() => {
|
|
83
|
+
res.write(chunk);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
res.cork(() => {
|
|
87
|
+
res.end();
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
function sendResponseToUwsOpts({ res, response }) {
|
|
91
|
+
const isStringOrBuffer = response.bodyType === 'Buffer' ||
|
|
92
|
+
response.bodyType === 'String' ||
|
|
93
|
+
response.bodyType === 'Uint8Array';
|
|
79
94
|
res.cork(() => {
|
|
80
95
|
res.writeStatus(`${response.status} ${response.statusText}`);
|
|
81
96
|
for (const [key, value] of response.headers) {
|
|
@@ -104,16 +119,6 @@ async function sendResponseToUwsOpts({ res, response }) {
|
|
|
104
119
|
res.end();
|
|
105
120
|
return;
|
|
106
121
|
}
|
|
107
|
-
|
|
108
|
-
if (resAborted) {
|
|
109
|
-
return;
|
|
110
|
-
}
|
|
111
|
-
res.cork(() => {
|
|
112
|
-
res.write(chunk);
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
res.cork(() => {
|
|
116
|
-
res.end();
|
|
117
|
-
});
|
|
122
|
+
return forwardResponseBodyToUWSResponse({ res, response });
|
|
118
123
|
}
|
|
119
124
|
exports.sendResponseToUwsOpts = sendResponseToUwsOpts;
|
package/esm/uwebsockets.js
CHANGED
|
@@ -65,12 +65,27 @@ export function getRequestFromUWSRequest({ req, res, fetchAPI }) {
|
|
|
65
65
|
signal: new UWSAbortSignal(res),
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
-
|
|
68
|
+
async function forwardResponseBodyToUWSResponse({ res, response }) {
|
|
69
69
|
let resAborted = false;
|
|
70
70
|
res.onAborted(function () {
|
|
71
71
|
resAborted = true;
|
|
72
72
|
});
|
|
73
|
-
|
|
73
|
+
for await (const chunk of response.body) {
|
|
74
|
+
if (resAborted) {
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
res.cork(() => {
|
|
78
|
+
res.write(chunk);
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
res.cork(() => {
|
|
82
|
+
res.end();
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
export function sendResponseToUwsOpts({ res, response }) {
|
|
86
|
+
const isStringOrBuffer = response.bodyType === 'Buffer' ||
|
|
87
|
+
response.bodyType === 'String' ||
|
|
88
|
+
response.bodyType === 'Uint8Array';
|
|
74
89
|
res.cork(() => {
|
|
75
90
|
res.writeStatus(`${response.status} ${response.statusText}`);
|
|
76
91
|
for (const [key, value] of response.headers) {
|
|
@@ -99,15 +114,5 @@ export async function sendResponseToUwsOpts({ res, response }) {
|
|
|
99
114
|
res.end();
|
|
100
115
|
return;
|
|
101
116
|
}
|
|
102
|
-
|
|
103
|
-
if (resAborted) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
res.cork(() => {
|
|
107
|
-
res.write(chunk);
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
res.cork(() => {
|
|
111
|
-
res.end();
|
|
112
|
-
});
|
|
117
|
+
return forwardResponseBodyToUWSResponse({ res, response });
|
|
113
118
|
}
|
package/package.json
CHANGED
|
@@ -28,5 +28,5 @@ interface SendResponseToUWSOpts {
|
|
|
28
28
|
res: UWSResponse;
|
|
29
29
|
response: Response;
|
|
30
30
|
}
|
|
31
|
-
export declare function sendResponseToUwsOpts({ res, response }: SendResponseToUWSOpts): Promise<void
|
|
31
|
+
export declare function sendResponseToUwsOpts({ res, response }: SendResponseToUWSOpts): Promise<void> | undefined;
|
|
32
32
|
export {};
|
package/typings/uwebsockets.d.ts
CHANGED
|
@@ -28,5 +28,5 @@ interface SendResponseToUWSOpts {
|
|
|
28
28
|
res: UWSResponse;
|
|
29
29
|
response: Response;
|
|
30
30
|
}
|
|
31
|
-
export declare function sendResponseToUwsOpts({ res, response }: SendResponseToUWSOpts): Promise<void
|
|
31
|
+
export declare function sendResponseToUwsOpts({ res, response }: SendResponseToUWSOpts): Promise<void> | undefined;
|
|
32
32
|
export {};
|