Z User
phase7: MCP stdio smoke test (handshake + tools/list + get_roots 6:74) — 4/4 tests PASS
54a6341 Download node_modules/@hono/node-server/dist/early-hints.mjs from bravesigma/quran-md-plugin: direct link, hf CLI and curl.
- Browser
- Download file 1.12 kB
-
https://huggingface.co/datasets/bravesigma/quran-md-plugin/resolve/main/node_modules/%40hono/node-server/dist/early-hints.mjs
- Command line
-
hf download hf://datasets/bravesigma/quran-md-plugin/node_modules/@hono/node-server/dist/early-hints.mjs
-
curl -L -o early-hints.mjs https://huggingface.co/datasets/bravesigma/quran-md-plugin/resolve/main/node_modules/%40hono/node-server/dist/early-hints.mjs
1.12 kB
| //#region src/early-hints.ts | |
| /** | |
| * Early Hints middleware for Node.js | |
| * Automatically sends a 103 Early Hints informational response with the specified Link header(s). | |
| * | |
| * @param options EarlyHintsOptions | |
| * @returns MiddlewareHandler | |
| */ | |
| const earlyHints = (options) => { | |
| let warned = false; | |
| return async (c, next) => { | |
| const mode = c.req.header("Sec-Fetch-Mode"); | |
| const dest = c.req.header("Sec-Fetch-Dest"); | |
| if (mode && mode !== "navigate" || dest && dest !== "document") return next(); | |
| const env = c.env || {}; | |
| const outgoing = ("server" in env ? env.server : env)?.outgoing; | |
| if (typeof outgoing?.writeEarlyHints !== "function") { | |
| if (!warned) { | |
| console.warn("Early Hints Middleware is not supported because writeEarlyHints is not defined."); | |
| warned = true; | |
| } | |
| return await next(); | |
| } | |
| if (!outgoing.headersSent) { | |
| const link = typeof options.link === "function" ? options.link(c) : options.link; | |
| if (link !== void 0 && (Array.isArray(link) ? link.length > 0 : Boolean(link))) outgoing.writeEarlyHints({ link }); | |
| } | |
| await next(); | |
| }; | |
| }; | |
| //#endregion | |
| export { earlyHints }; |