| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dafee05 commit 0821b44
23 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -622,11 +622,11 @@ and `undici.Agent`) which will enable the family autoselection algorithm when es | |||
| 622 | 622 | ||
| 623 | 623 | Undici aligns with the Node.js LTS schedule. The following table shows the supported versions: | |
| 624 | 624 | ||
| 625 | - | Version | Node.js | End of Life | | ||
| 626 | - |---------|-------------|-------------| | ||
| 627 | - | 5.x | v18.x | 2024-04-30 | | ||
| 628 | - | 6.x | v20.x v22.x | 2026-04-30 | | ||
| 629 | - | 7.x | v24.x | 2027-04-30 | | ||
| 625 | + | Undici Version | Bundled in Node.js | Node.js Versions Supported | End of Life | | ||
| 626 | + |----------------|-------------------|----------------------------|-------------| | ||
| 627 | + | 5.x | 18.x | ≥14.0 (tested: 14, 16, 18) | 2024-04-30 | | ||
| 628 | + | 6.x | 20.x, 22.x | ≥18.17 (tested: 18, 20, 21, 22) | 2026-04-30 | | ||
| 629 | + | 7.x | 24.x | ≥20.18.1 (tested: 20, 22, 24) | 2027-04-30 | | ||
| 630 | 630 | ||
| 631 | 631 | ## License | |
| 632 | 632 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -169,14 +169,38 @@ This message is published after the client has successfully connected to a serve | |||
| 169 | 169 | ```js | |
| 170 | 170 | import diagnosticsChannel from 'diagnostics_channel' | |
| 171 | 171 | ||
| 172 | - diagnosticsChannel.channel('undici:websocket:open').subscribe(({ address, protocol, extensions, websocket }) => { | ||
| 172 | + diagnosticsChannel.channel('undici:websocket:open').subscribe(({ | ||
| 173 | + address, // { address: string, family: string, port: number } | ||
| 174 | + protocol, // string - negotiated subprotocol | ||
| 175 | + extensions, // string - negotiated extensions | ||
| 176 | + websocket, // WebSocket - the WebSocket instance | ||
| 177 | + handshakeResponse // object - HTTP response that upgraded the connection | ||
| 178 | + }) => { | ||
| 173 | 179 | console.log(address) // address, family, and port | |
| 174 | 180 | console.log(protocol) // negotiated subprotocols | |
| 175 | 181 | console.log(extensions) // negotiated extensions | |
| 176 | 182 | console.log(websocket) // the WebSocket instance | |
| 183 | + | ||
| 184 | + // Handshake response details | ||
| 185 | + console.log(handshakeResponse.status) // 101 for successful WebSocket upgrade | ||
| 186 | + console.log(handshakeResponse.statusText) // 'Switching Protocols' | ||
| 187 | + console.log(handshakeResponse.headers) // Object containing response headers | ||
| 177 | 188 | }) | |
| 178 | 189 | ``` | |
| 179 | 190 | ||
| 191 | + ### Handshake Response Object | ||
| 192 | + | ||
| 193 | + The `handshakeResponse` object contains the HTTP response that upgraded the connection to WebSocket: | ||
| 194 | + | ||
| 195 | + - `status` (number): The HTTP status code (101 for successful WebSocket upgrade) | ||
| 196 | + - `statusText` (string): The HTTP status message ('Switching Protocols' for successful upgrade) | ||
| 197 | + - `headers` (object): The HTTP response headers from the server, including: | ||
| 198 | + - `upgrade: 'websocket'` | ||
| 199 | + - `connection: 'upgrade'` | ||
| 200 | + - `sec-websocket-accept` and other WebSocket-related headers | ||
| 201 | + | ||
| 202 | + This information is particularly useful for debugging and monitoring WebSocket connections, as it provides access to the initial HTTP handshake response that established the WebSocket connection. | ||
| 203 | + | ||
| 180 | 204 | ## `undici:websocket:close` | |
| 181 | 205 | ||
| 182 | 206 | This message is published after the connection has closed. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,6 @@ | |||
| 1 | 1 | 'use strict' | |
| 2 | 2 | ||
| 3 | 3 | const { kProxy, kClose, kDestroy, kDispatch } = require('../core/symbols') | |
| 4 | - const { URL } = require('node:url') | ||
| 5 | 4 | const Agent = require('./agent') | |
| 6 | 5 | const Pool = require('./pool') | |
| 7 | 6 | const DispatcherBase = require('./dispatcher-base') | |
@@ -208,7 +207,7 @@ class ProxyAgent extends DispatcherBase { | |||
| 208 | 207 | } | |
| 209 | 208 | ||
| 210 | 209 | /** | |
| 211 | - * @param {import('../types/proxy-agent').ProxyAgent.Options | string | URL} opts | ||
| 210 | + * @param {import('../../types/proxy-agent').ProxyAgent.Options | string | URL} opts | ||
| 212 | 211 | * @returns {URL} | |
| 213 | 212 | */ | |
| 214 | 213 | #getUrl (opts) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -15,6 +15,15 @@ const HEURISTICALLY_CACHEABLE_STATUS_CODES = [ | |||
| 15 | 15 | 200, 203, 204, 206, 300, 301, 308, 404, 405, 410, 414, 501 | |
| 16 | 16 | ] | |
| 17 | 17 | ||
| 18 | + // Status codes which semantic is not handled by the cache | ||
| 19 | + // https://datatracker.ietf.org/doc/html/rfc9111#section-3 | ||
| 20 | + // This list should not grow beyond 206 and 304 unless the RFC is updated | ||
| 21 | + // by a newer one including more. Please introduce another list if | ||
| 22 | + // implementing caching of responses with the 'must-understand' directive. | ||
| 23 | + const NOT_UNDERSTOOD_STATUS_CODES = [ | ||
| 24 | + 206, 304 | ||
| 25 | + ] | ||
| 26 | + | ||
| 18 | 27 | const MAX_RESPONSE_AGE = 2147483647000 | |
| 19 | 28 | ||
| 20 | 29 | /** | |
@@ -241,10 +250,19 @@ class CacheHandler { | |||
| 241 | 250 | * @param {import('../../types/cache-interceptor.d.ts').default.CacheControlDirectives} cacheControlDirectives | |
| 242 | 251 | */ | |
| 243 | 252 | function canCacheResponse (cacheType, statusCode, resHeaders, cacheControlDirectives) { | |
| 244 | - // Allow caching for status codes 200 and 307 (original behavior) | ||
| 245 | - // Also allow caching for other status codes that are heuristically cacheable | ||
| 246 | - // when they have explicit cache directives | ||
| 247 | - if (statusCode !== 200 && statusCode !== 307 && !HEURISTICALLY_CACHEABLE_STATUS_CODES.includes(statusCode)) { | ||
| 253 | + // Status code must be final and understood. | ||
| 254 | + if (statusCode < 200 || NOT_UNDERSTOOD_STATUS_CODES.includes(statusCode)) { | ||
| 255 | + return false | ||
| 256 | + } | ||
| 257 | + // Responses with neither status codes that are heuristically cacheable, nor "explicit enough" caching | ||
| 258 | + // directives, are not cacheable. "Explicit enough": see https://www.rfc-editor.org/rfc/rfc9111.html#section-3 | ||
| 259 | + if (!HEURISTICALLY_CACHEABLE_STATUS_CODES.includes(statusCode) && !resHeaders['expires'] && | ||
| 260 | + !cacheControlDirectives.public && | ||
| 261 | + cacheControlDirectives['max-age'] === undefined && | ||
| 262 | + // RFC 9111: a private response directive, if the cache is not shared | ||
| 263 | + !(cacheControlDirectives.private && cacheType === 'private') && | ||
| 264 | + !(cacheControlDirectives['s-maxage'] !== undefined && cacheType === 'shared') | ||
| 265 | + ) { | ||
| 248 | 266 | return false | |
| 249 | 267 | } | |
| 250 | 268 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,7 +6,7 @@ const util = require('../core/util') | |||
| 6 | 6 | const CacheHandler = require('../handler/cache-handler') | |
| 7 | 7 | const MemoryCacheStore = require('../cache/memory-cache-store') | |
| 8 | 8 | const CacheRevalidationHandler = require('../handler/cache-revalidation-handler') | |
| 9 | - const { assertCacheStore, assertCacheMethods, makeCacheKey, normaliseHeaders, parseCacheControlHeader } = require('../util/cache.js') | ||
| 9 | + const { assertCacheStore, assertCacheMethods, makeCacheKey, normalizeHeaders, parseCacheControlHeader } = require('../util/cache.js') | ||
| 10 | 10 | const { AbortError } = require('../core/errors.js') | |
| 11 | 11 | ||
| 12 | 12 | /** | |
@@ -326,7 +326,7 @@ module.exports = (opts = {}) => { | |||
| 326 | 326 | ||
| 327 | 327 | opts = { | |
| 328 | 328 | ...opts, | |
| 329 | - headers: normaliseHeaders(opts) | ||
| 329 | + headers: normalizeHeaders(opts) | ||
| 330 | 330 | } | |
| 331 | 331 | ||
| 332 | 332 | const reqCacheControl = opts.headers?.['cache-control'] | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,5 +1,5 @@ | |||
| 1 | 1 | ||
| 2 | - > undici@7.13.0 build:wasm | ||
| 2 | + > undici@7.14.0 build:wasm | ||
| 3 | 3 | > node build/wasm.js --docker | |
| 4 | 4 | ||
| 5 | 5 | > docker run --rm --platform=linux/x86_64 --user 1001:118 --mount type=bind,source=/home/runner/work/node/node/deps/undici/src/lib/llhttp,target=/home/node/build/lib/llhttp --mount type=bind,source=/home/runner/work/node/node/deps/undici/src/build,target=/home/node/build/build --mount type=bind,source=/home/runner/work/node/node/deps/undici/src/deps,target=/home/node/build/deps -t ghcr.io/nodejs/wasm-builder@sha256:975f391d907e42a75b8c72eb77c782181e941608687d4d8694c3e9df415a0970 node build/wasm.js | |
| Back | FazBrowse Home | New Git URL |
0 commit comments