velocious 1.0.654 → 1.0.656

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.
@@ -22,9 +22,9 @@ const COMPRESSIBLE_EXACT_MEDIA_TYPES = new Set([
22
22
 
23
23
  /**
24
24
  * RFC 9110 §12.4.2 qvalue grammar: `0` or `1` with at most three fractional
25
- * digits, and only zeros after `1`.
25
+ * digits (the boundary forms `0.` and `1.` are valid), and only zeros after `1`.
26
26
  * @type {RegExp} */
27
- const QVALUE_PATTERN = /^(?:0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/u
27
+ const QVALUE_PATTERN = /^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/u
28
28
 
29
29
  /**
30
30
  * Runs parse accept encoding.
@@ -118,7 +118,9 @@ export function isCompressibleContentType(contentType) {
118
118
  /**
119
119
  * Merges Accept-Encoding into the response Vary header case-insensitively and
120
120
  * without duplicates. An existing `Vary: *` already covers every request header
121
- * and is preserved as-is.
121
+ * and is preserved as-is. Called by the response sender for every
122
+ * framework-selected representation so the header is identical for every
123
+ * request on the same connection.
122
124
  * @param {import("./response.js").default} response - Response instance.
123
125
  * @returns {void} - No return value.
124
126
  */
@@ -160,7 +162,7 @@ export function addAcceptEncodingToVary(response) {
160
162
  * @param {import("../../configuration-types.js").NormalizedHttpCompressionConfiguration} args.compression - Normalized compression configuration.
161
163
  * @param {import("./request.js").default | import("./websocket-request.js").default} args.request - Request object.
162
164
  * @param {import("./response.js").default} args.response - Response instance.
163
- * @returns {Promise<{outcome: "identity"} | {outcome: "compressed", body: Buffer} | {outcome: "not-acceptable"}>} - Compression outcome.
165
+ * @returns {Promise<{outcome: "identity"} | {outcome: "compressed", body: Buffer} | {outcome: "not-acceptable"}>} - Compression outcome. The caller owns the Vary header and the file/406 representation decisions.
164
166
  */
165
167
  export async function applyResponseCompression({bodyBuffer, compression, request, response}) {
166
168
  if (!compression.enabled) return {outcome: "identity"}
@@ -203,10 +205,6 @@ export async function applyResponseCompression({bodyBuffer, compression, request
203
205
  return negotiated.identityAcceptable ? {outcome: "identity"} : {outcome: "not-acceptable"}
204
206
  }
205
207
 
206
- // The representation now depends on the request's Accept-Encoding, even when this
207
- // particular response ends up identity (missing header, higher-q identity, below threshold).
208
- addAcceptEncodingToVary(response)
209
-
210
208
  if (negotiated.encoding == "identity") return {outcome: "identity"}
211
209
 
212
210
  // Below the threshold the smaller identity representation is sent instead — but only