@nifrajs/core 5.12.0 → 5.12.1
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/CHANGELOG.md +6 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/server/core-copies.js +1 -1
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js +8 -4
- package/dist/server/request-context.js.map +1 -1
- package/dist/server/respond.d.ts.map +1 -1
- package/dist/server/respond.js +10 -0
- package/dist/server/respond.js.map +1 -1
- package/dist/server/server.js +1 -1
- package/dist/server/server.js.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +1 -1
- package/src/server/core-copies.ts +1 -1
- package/src/server/request-context.ts +12 -8
- package/src/server/respond.ts +11 -0
- package/src/server/server.ts +1 -1
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* read its own package.json at runtime. `scripts/version.ts` rewrites it on every release bump and
|
|
17
17
|
* `check:publish` asserts it equals `@nifrajs/core`'s package version.
|
|
18
18
|
*/
|
|
19
|
-
export const VERSION = "5.12.
|
|
19
|
+
export const VERSION = "5.12.1" as const
|
|
20
20
|
|
|
21
21
|
export type Version = typeof VERSION
|
|
22
22
|
|
|
@@ -26,7 +26,7 @@ if (!copies.includes(here) && copies.push(here) > 1) {
|
|
|
26
26
|
|
|
27
27
|
/** This copy's version: a literal like the package root's `VERSION` (no fs on the edge), which
|
|
28
28
|
* `scripts/version.ts` rewrites on every release and `check:publish` asserts. */
|
|
29
|
-
const COPY_VERSION = "5.12.
|
|
29
|
+
const COPY_VERSION = "5.12.1"
|
|
30
30
|
|
|
31
31
|
/** Record this copy's version beside its URL. Called by each `server()` behind the development guard,
|
|
32
32
|
* so a production bundle drops it with the version; a copy that built a server has recorded one. */
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* sits below the server module in the graph.
|
|
6
6
|
*/
|
|
7
7
|
import type { RequestBudget } from "../budget.ts"
|
|
8
|
-
import { markResidentBody } from "../mount.ts"
|
|
8
|
+
import { markResidentBody, residentBodiesRecorded } from "../mount.ts"
|
|
9
9
|
import { applyTransportCap, readBoundedBytes } from "./body.ts"
|
|
10
10
|
import { readBoundedJsonSource } from "./body-lane.ts"
|
|
11
11
|
import type { Platform } from "./context.ts"
|
|
@@ -165,6 +165,8 @@ function responseTextContentType(): string {
|
|
|
165
165
|
/** `c.text`'s own default, unchanged: the explicit one nifra has always declared when the caller
|
|
166
166
|
* passes no headers of their own. */
|
|
167
167
|
const TEXT_CONTENT_TYPE = "text/plain; charset=utf-8"
|
|
168
|
+
const TEXT_RESPONSE_HEADERS = { "content-type": TEXT_CONTENT_TYPE }
|
|
169
|
+
const TEXT_RESPONSE_INIT: ResponseInit = { headers: TEXT_RESPONSE_HEADERS }
|
|
168
170
|
|
|
169
171
|
/** Where a serving adapter that shares one platform across requests leaves its socket-peer lookup.
|
|
170
172
|
* `c.clientIp` calls it with the request when a handler reads the address, so a request whose
|
|
@@ -439,13 +441,15 @@ export class RequestContext implements RawContext {
|
|
|
439
441
|
}
|
|
440
442
|
}
|
|
441
443
|
// Default to text/plain; if the caller passes their own headers, they own the content-type.
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
new Response(
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
444
|
+
const response =
|
|
445
|
+
i?.headers !== undefined
|
|
446
|
+
? new Response(body, i)
|
|
447
|
+
: new Response(
|
|
448
|
+
body,
|
|
449
|
+
i === undefined ? TEXT_RESPONSE_INIT : { ...i, headers: TEXT_RESPONSE_HEADERS },
|
|
450
|
+
)
|
|
451
|
+
const resident = residentText(response, body)
|
|
452
|
+
return residentBodiesRecorded ? markResidentBody(resident) : resident
|
|
449
453
|
}
|
|
450
454
|
|
|
451
455
|
get query(): unknown {
|
package/src/server/respond.ts
CHANGED
|
@@ -613,6 +613,17 @@ export function fusedRespond(
|
|
|
613
613
|
unstamped = false,
|
|
614
614
|
): Response {
|
|
615
615
|
const set = ctx[CONTEXT_SET]()
|
|
616
|
+
if (
|
|
617
|
+
set === undefined &&
|
|
618
|
+
statics === undefined &&
|
|
619
|
+
!tagResponseBody &&
|
|
620
|
+
result instanceof Response &&
|
|
621
|
+
!isResponseResult(result) &&
|
|
622
|
+
!responseBodyUsed(result)
|
|
623
|
+
) {
|
|
624
|
+
if (!isBodylessStatus(result.status)) return result
|
|
625
|
+
return normalizeBodylessResponse(result, unstamped ? undefined : ctx[CONTEXT_REQUEST])
|
|
626
|
+
}
|
|
616
627
|
const request = unstamped ? undefined : ctx[CONTEXT_REQUEST]
|
|
617
628
|
if (set === undefined)
|
|
618
629
|
return fusedRespondNoSet(result, tagResponseBody, statics, unstamped, request)
|
package/src/server/server.ts
CHANGED
|
@@ -7599,7 +7599,7 @@ export class Server<R extends Registry = EmptyRegistry, Ctx = EmptyContext, Hook
|
|
|
7599
7599
|
if (
|
|
7600
7600
|
mayUseStaticResponse &&
|
|
7601
7601
|
staticResponse !== undefined &&
|
|
7602
|
-
(method === "GET" || method === "HEAD") &&
|
|
7602
|
+
(method === "GET" || method === "HEAD" || method === "POST") &&
|
|
7603
7603
|
// Bun 1.3 can misframe null-body status codes in its native static table.
|
|
7604
7604
|
staticResponse.status !== 204 &&
|
|
7605
7605
|
staticResponse.status !== 205 &&
|