fulmine.js 5.20.0 → 5.21.0
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/package.json +1 -1
- package/src/cli.js +5 -4
- package/src/declarative.js +6 -0
- package/src/optimizer.js +3 -2
- package/src/testing.js +5 -2
- package/src/utils.js +5 -0
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -107,10 +107,11 @@ const DIFFERENCES = [
|
|
|
107
107
|
[
|
|
108
108
|
"a compiled route keeps its connection header",
|
|
109
109
|
"A handler simple enough to be read at registration time is answered natively, and a client\n" +
|
|
110
|
-
"that sent Connection: close is still told keep-alive, though the socket does close. A
|
|
111
|
-
"
|
|
112
|
-
|
|
113
|
-
'
|
|
110
|
+
"that sent Connection: close is still told keep-alive, though the socket does close. A\n" +
|
|
111
|
+
"response that would carry a validator is never compiled, so conditional requests behave as\n" +
|
|
112
|
+
'on Express. app.set("declarative responses", false) turns it off. A body with a piece of\n' +
|
|
113
|
+
'the query or a route parameter in it is compiled only under app.set("declarative request\n' +
|
|
114
|
+
'values", true), which takes the value as uWS reads it: undecoded, the first one, or none.'
|
|
114
115
|
],
|
|
115
116
|
[
|
|
116
117
|
"headers are capped at 4096 bytes by default",
|
package/src/declarative.js
CHANGED
|
@@ -818,6 +818,12 @@ module.exports = function compileDeclarative(cb, app) {
|
|
|
818
818
|
}
|
|
819
819
|
const { sendUsed, bodyFromSend } = read;
|
|
820
820
|
|
|
821
|
+
// a part copied out of the request is written by uWS with its own reading of it, so the
|
|
822
|
+
// route is compiled only where the application asked for that
|
|
823
|
+
if (!app.get("declarative request values") && body.some((part) => part.type !== "text")) {
|
|
824
|
+
return false;
|
|
825
|
+
}
|
|
826
|
+
|
|
821
827
|
// a handler that never sends is not a response: Express leaves the request waiting, so this
|
|
822
828
|
// has to fall back instead of answering a bare 200
|
|
823
829
|
if (!sendUsed && !sendStatusUsed) {
|
package/src/optimizer.js
CHANGED
|
@@ -558,8 +558,9 @@ function registerUwsRoute(router, route, optimizedPath) {
|
|
|
558
558
|
route.paramCallbacks.size === 0 && // a param callback has to run, and this answers without running anything
|
|
559
559
|
// a captured value is decoded when the route runs, and one that cannot be decoded is a
|
|
560
560
|
// 400 in express and on the ordinary path here. Nothing runs to raise it on a
|
|
561
|
-
// declarative response, so GET /a-b%5Ec@d%e came back 200 from app.get("/:p12")
|
|
562
|
-
|
|
561
|
+
// declarative response, so GET /a-b%5Ec@d%e came back 200 from app.get("/:p12").
|
|
562
|
+
// "declarative request values" is the application accepting that
|
|
563
|
+
(route.optimizedParams === undefined || router.get("declarative request values")) &&
|
|
563
564
|
// a declarative response is answered by µWS itself, so no javascript runs and the case
|
|
564
565
|
// guard could not: a route that needs one has to stay an ordinary handler
|
|
565
566
|
caseGuards === null &&
|
package/src/testing.js
CHANGED
|
@@ -187,8 +187,11 @@ function whyNotCompiled(app, entry) {
|
|
|
187
187
|
if (!app.get("declarative responses")) {
|
|
188
188
|
return "answered by µWS, but declarative responses are turned off";
|
|
189
189
|
}
|
|
190
|
-
if (entry.path.includes(":")) {
|
|
191
|
-
return
|
|
190
|
+
if (entry.path.includes(":") && !app.get("declarative request values")) {
|
|
191
|
+
return (
|
|
192
|
+
"answered by µWS, but the route captures, and nothing runs to decode the value: " +
|
|
193
|
+
'app.set("declarative request values", true) is what puts a route here'
|
|
194
|
+
);
|
|
192
195
|
}
|
|
193
196
|
if (app.get("etag")) {
|
|
194
197
|
return (
|
package/src/utils.js
CHANGED
|
@@ -1028,6 +1028,11 @@ const defaultSettings = {
|
|
|
1028
1028
|
// The native µWS router matches bytes, so the compiler in _compileOptimizedRoutes only hands
|
|
1029
1029
|
// it routes whose earlier siblings it can prove agree under either case rule.
|
|
1030
1030
|
"declarative responses": true,
|
|
1031
|
+
// off: a compiled body copies nothing out of the request. On, res.send(req.query.q) and
|
|
1032
|
+
// res.send(req.params.id) compile too, written by uWS as it reads them and not as Express
|
|
1033
|
+
// does: a query key repeated or missing gives the first value or nothing, a route parameter
|
|
1034
|
+
// goes out undecoded, and one that Express refuses with a 400 is answered
|
|
1035
|
+
"declarative request values": false,
|
|
1031
1036
|
// on. Off hands every request to the ordinary chain instead of letting uWS match what it can,
|
|
1032
1037
|
// which is slower and answers the same. Not a tuning knob: it exists so one application can be
|
|
1033
1038
|
// served both ways and the answers compared, see `npm run fuzz -- --self`. A compiled response
|