You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: draft-ietf-httpbis-variants.md
+65-65Lines changed: 65 additions & 65 deletions
Original file line number
Diff line number
Diff line change
@@ -222,15 +222,15 @@ When more than one Variant-Key value is in a response, the first one present MUS
222
222
This algorithm generates a list of normalised strings from Variant-Key, suitable for comparison with
223
223
values generated by {{cache}}.
224
224
225
-
Given stored-headers (a set of headers from a stored response), a normalised list of variant-keys for that message can be generated by following this algorithm:
225
+
Given `stored-headers` (a set of headers from a stored response), a normalised list of variant-keys for that message can be generated by following this algorithm:
226
226
227
-
1. Let variant-keys be an empty list.
228
-
2. Let variant-key-header be a string, the result of selecting all field-values of stored-headers whose field-name is "Variant-Key" and joining them with a comma (",").
229
-
3. Let value-list be the result of splitting variant-key-header on commas (",").
230
-
4. For each value in value-list:
231
-
1. Remove all whitespace from value.
232
-
2. Append value to variant-keys.
233
-
5. Return variant-keys.
227
+
1. Let `variant-keys` be an empty list.
228
+
2. Let `variant-key-header` be a string, the result of selecting all field-values of `stored-headers` whose field-name is "Variant-Key" and joining them with a comma (",").
229
+
3. Let `value-list` be the result of splitting `variant-key-header` on commas (",").
230
+
4. For each `value` in `value-list`:
231
+
1. Remove all whitespace from `value`.
232
+
2. Append `value` to `variant-keys`.
233
+
5. Return `variant-keys`.
234
234
235
235
236
236
# Cache Behaviour {#cache}
@@ -239,23 +239,23 @@ Caches that implement the Variants header field and the relevant semantics of th
239
239
240
240
They do so by running this algorithm (or its functional equivalent) upon receiving a request:
241
241
242
-
Given incoming-request (a mapping of field-names to lists of field values), and stored-responses (a list of stored responses suitable for reuse as defined in Section 4 of {{!RFC7234}}, excepting the requirement to calculate a secondary cache key):
242
+
Given `incoming-request` (a mapping of field-names to lists of field values), and `stored-responses` (a list of stored responses suitable for reuse as defined in Section 4 of {{!RFC7234}}, excepting the requirement to calculate a secondary cache key):
243
243
244
-
1. If stored-responses is empty, return an empty list.
245
-
2. Order stored-responses by the "Date" header field, most recent to least recent.
246
-
3. Let sorted-variants be an empty list.
247
-
4. If the freshest member of stored-responses (as per {{!RFC7234}}, Section 4.2) has one or more "Variants" header field(s):
248
-
1. Select one member of stored-responses and let variants-header be its "Variants" header field-value(s). This SHOULD be the most recent response, but MAY be from an older one as long as it is still fresh.
249
-
3. For each variant in variants-header, parsed according to the ABNF:
250
-
1. If variant's field-name corresponds to the request header field identified by a content negotiation mechanism that the implementation supports:
251
-
1. Let request-value be the field-value(s) associated with field-name in incoming-request.
252
-
2. Let available-values be a list containing all available-value for variant.
253
-
3. Let sorted-values be the result of running the algorithm defined by the content negotiation mechanism with request-value and available-values.
254
-
4. Append sorted-values to sorted-variants.
244
+
1. If `stored-responses` is empty, return an empty list.
245
+
2. Order `stored-responses` by the "Date" header field, most recent to least recent.
246
+
3. Let `sorted-variants` be an empty list.
247
+
4. If the freshest member of `stored-`responses` (as per {{!RFC7234}}, Section 4.2) has one or more "Variants" header field(s):
248
+
1. Select one member of `stored-responses` and let `variants-header` be its "Variants" header field-value(s). This SHOULD be the most recent response, but MAY be from an older one as long as it is still fresh.
249
+
3. For each `variant` in `variants-header`, parsed according to the ABNF:
250
+
1. If `variant`'s field-name corresponds to the request header field identified by a content negotiation mechanism that the implementation supports:
251
+
1. Let `request-value` be the field-value(s) associated with field-name in `incoming-request`.
252
+
2. Let `available-values` be a list containing all available-value for variant.
253
+
3. Let `sorted-values` be the result of running the algorithm defined by the content negotiation mechanism with `request-value` and `available-values`.
254
+
4. Append `sorted-values` to `sorted-variants`.
255
255
256
-
At this point, sorted-variants will be a list of lists, each member of the top-level list corresponding to a variant-item in the Variants header field-value, containing zero or more items indicating available-values that are acceptable to the client, in order of preference, greatest to least.
256
+
At this point, `sorted-variants` will be a list of lists, each member of the top-level list corresponding to a variant-item in the Variants header field-value, containing zero or more items indicating available-values that are acceptable to the client, in order of preference, greatest to least.
257
257
258
-
5. Return result of running Compute Possible Keys ({{find}}) on sorted-variants, an empty string and an empty list.
258
+
5. Return result of running Compute Possible Keys ({{find}}) on `sorted-variants`, an empty string and an empty list.
259
259
260
260
This returns a list of strings suitable for comparing to normalised Variant-Keys ({{gen-variant-key}}) that represent possible responses on the server that can be used to satisfy the request, in preference order, provided that their secondary cache key (after removing the headers covered by Variants) matches. {{check_vary}} illustrates one way to do this.
261
261
@@ -264,34 +264,34 @@ This returns a list of strings suitable for comparing to normalised Variant-Keys
264
264
265
265
This algorithm computes the cross-product of the elements of key-facets.
266
266
267
-
Given key-facets (a list of lists), and key-stub (a string representing a partial key), and possible-keys (a list):
267
+
Given `key-facets` (a list of lists), and `key-stub` (a string representing a partial key), and `possible-keys` (a list):
268
268
269
-
1. Let values be the first member of key-facets.
270
-
2. For each value in values:
271
-
1. If key-stub is an empty string, let this-key be a copy of value.
269
+
1. Let `values` be the first member of `key-facets`.
270
+
2. For each `value` in `values`:
271
+
1. If `key-stub` is an empty string, let `this-key` be a copy of `value`.
272
272
1. Otherwise:
273
-
1. Let this-key be a copy of key-stub.
274
-
2. Append a semicolon (";") to this-key.
275
-
3. Append value to this-key.
276
-
3. Let remaining-facets be a copy of all of the members of key-facets except the first.
277
-
4. If remaining-facets is empty, append this-key to possible-keys.
278
-
5. Otherwise, run Compute Possible Keys on remaining-facets, this-key and possible-keys.
279
-
3. Return possible-keys.
273
+
1. Let `this-key` be a copy of `key-stub`.
274
+
2. Append a semicolon (";") to `this-key`.
275
+
3. Append `value` to `this-key`.
276
+
3. Let `remaining-facets` be a copy of all of the members of `key-facets` except the first.
277
+
4. If `remaining-facets` is empty, append `this-key` to `possible-keys`.
278
+
5. Otherwise, run Compute Possible Keys on `remaining-facets`, `this-key` and `possible-keys`.
279
+
3. Return `possible-keys`.
280
280
281
281
282
282
## Check Vary {#check_vary}
283
283
284
284
This algorithm is an example of how an implementation can meet the requirement to apply the members of the Vary header field that are not covered by Variants.
285
285
286
-
Given stored-response (a stored response):
286
+
Given `stored-response` (a stored response):
287
287
288
-
1. Let filtered-vary be the field-value(s) of stored-response's "Vary" header field.
289
-
2. Let processed-variants be a list containing the request header fields that identify the content negotiation mechanisms supported by the implementation.
290
-
3. Remove any member of filtered-vary that is a case-insensitive match for a member of processed-variants.
291
-
4. If the secondary cache key (as calculated in {{!RFC7234}}, Section 4.1) for stored_response matches incoming-request, using filtered-vary for the value of the "Vary" response header, return True.
288
+
1. Let `filtered-vary` be the field-value(s) of `stored-response`'s "Vary" header field.
289
+
2. Let `processed-variants` be a list containing the request header fields that identify the content negotiation mechanisms supported by the implementation.
290
+
3. Remove any member of `filtered-vary` that is a case-insensitive match for a member of `processed-variants`.
291
+
4. If the secondary cache key (as calculated in {{!RFC7234}}, Section 4.1) for `stored-response` matches incoming-request, using `filtered-vary` for the value of the "Vary" response header, return True.
292
292
5. Return False.
293
293
294
-
This returns a Boolean that indicates whether stored-response can be used to satisfy the request.
294
+
This returns a Boolean that indicates whether `stored-response` can be used to satisfy the request.
295
295
296
296
Note that implementation of the Vary header field varies in practice, and the algorithm above illustrates only one way to apply it. It is equally viable to forward the request if there is a request header listed in Vary but not Variants.
@@ -320,7 +320,7 @@ Then the sorted-variants would be:
320
320
]
321
321
~~~
322
322
323
-
Which means that the sorted-keys would be:
323
+
Which means that the `sorted-keys` would be:
324
324
325
325
~~~ example
326
326
[
@@ -449,8 +449,8 @@ Here, the cache will need to calculate a secondary cache key as per {{!RFC7234}}
449
449
To be usable with Variants, proactive content negotiation mechanisms need to be specified to take advantage of it. Specifically, they:
450
450
451
451
* MUST define a request header field that advertises the clients preferences or capabilities, whose field-name SHOULD begin with "Accept-".
452
-
* MUST define the syntax of an available-value that will occur in Variants and Variant-Key.
453
-
* MUST define an algorithm for selecting a result. It MUST return a list of available-values that are suitable for the request, in order of preference, given the value of the request header nominated above and an available-values list from the Variants header. If the result is an empty list, it implies that the cache cannot satisfy the request.
452
+
* MUST define the syntax of an `available-value` that will occur in Variants and Variant-Key.
453
+
* MUST define an algorithm for selecting a result. It MUST return a list of `available-value`s that are suitable for the request, in order of preference, given the value of the request header nominated above and an `available-values` list from the Variants header. If the result is an empty list, it implies that the cache cannot satisfy the request.
454
454
455
455
{{backports}} fulfils these requirements for some existing proactive content negotiation mechanisms in HTTP.
456
456
@@ -499,14 +499,14 @@ The syntax of an available-value for Accept is:
499
499
accept-available-value = type "/" subtype
500
500
~~~
501
501
502
-
To perform content negotiation for Accept given a request-value and available-values:
502
+
To perform content negotiation for Accept given a `request-value` and `available-values`:
503
503
504
-
1. Let preferred-available be an empty list.
505
-
2. Let preferred-types be a list of the types in the request-value, ordered by their weight, highest to lowest, as per Section 5.3.2 of {{!RFC7231}} (omitting any coding with a weight of 0). If "Accept" is not present or empty, preferred-types will be empty. If a type lacks an explicit weight, an implementation MAY assign one.
506
-
3. If the first member of available-values is not a member of preferred-types, append it to preferred-types (thus making it the default).
507
-
4. For each preferred-type in preferred-types:
508
-
1. If any member of available-values matches preferred-type, using the media-range matching mechanism specified in Section 5.3.2 of {{!RFC7231}} (which is case-insensitive), append those members of available-values to preferred-available (preserving the precedence order implied by the media ranges' specificity).
509
-
5. Return preferred-available.
504
+
1. Let `preferred-available` be an empty list.
505
+
2. Let `preferred-types` be a list of the types in the `request-value`, ordered by their weight, highest to lowest, as per Section 5.3.2 of {{!RFC7231}} (omitting any coding with a weight of 0). If "Accept" is not present or empty, `preferred-types` will be empty. If a type lacks an explicit weight, an implementation MAY assign one.
506
+
3. If the first member of `available-values` is not a member of `preferred-types`, append it to `preferred-types` (thus making it the default).
507
+
4. For each `preferred-type` in `preferred-types`:
508
+
1. If any member of `available-values` matches `preferred-type`, using the media-range matching mechanism specified in Section 5.3.2 of {{!RFC7231}} (which is case-insensitive), append those members of `available-values` to `preferred-available` (preserving the precedence order implied by the media ranges' specificity).
509
+
5. Return `preferred-available`.
510
510
511
511
Note that this algorithm explicitly ignores extension parameters on media types (e.g., "charset").
512
512
@@ -521,15 +521,15 @@ The syntax of an available-value for Accept-Encoding is:
To perform content negotiation for Accept-Encoding given a request-value and available-values:
524
+
To perform content negotiation for Accept-Encoding given a `request-value` and `available-values`:
525
525
526
-
1. Let preferred-available be an empty list.
527
-
2. Let preferred-codings be a list of the codings in the request-value, ordered by their weight, highest to lowest, as per Section 5.3.1 of {{!RFC7231}} (omitting any coding with a weight of 0). If "Accept-Encoding" is not present or empty, preferred-codings will be empty. If a coding lacks an explicit weight, an implementation MAY assign one.
528
-
3. If "identity" is not a member of preferred-codings, append "identity".
529
-
4. Append "identity" to available-values.
530
-
5. For each preferred-coding in preferred-codings:
531
-
1. If there is a case-insensitive, character-for-character match for preferred-coding in available-values, append that member of available-values to preferred-available.
532
-
6. Return preferred-available.
526
+
1. Let `preferred-available` be an empty list.
527
+
2. Let `preferred-codings` be a list of the codings in the `request-value`, ordered by their weight, highest to lowest, as per Section 5.3.1 of {{!RFC7231}} (omitting any coding with a weight of 0). If "Accept-Encoding" is not present or empty, `preferred-codings` will be empty. If a coding lacks an explicit weight, an implementation MAY assign one.
528
+
3. If "identity" is not a member of `preferred-codings`, append "identity".
529
+
4. Append "identity" to `available-values`.
530
+
5. For each `preferred-coding` in `preferred-codings`:
531
+
1. If there is a case-insensitive, character-for-character match for `preferred-coding` in `available-values`, append that member of `available-values` to `preferred-available`.
532
+
6. Return `preferred-available`.
533
533
534
534
Note that the unencoded variant needs to have a Variant-Key header field with a value of "identity" (as defined in Section 5.3.4 of {{!RFC7231}}).
535
535
@@ -543,14 +543,14 @@ The syntax of an available-value for Accept-Language is:
543
543
accept-encoding-available-value = language-range
544
544
~~~
545
545
546
-
To perform content negotiation for Accept-Language given a request-value and available-values:
546
+
To perform content negotiation for Accept-Language given a `request-value` and `available-values`:
547
547
548
-
1. Let preferred-available be an empty list.
549
-
2. Let preferred-langs be a list of the language-ranges in the request-value, ordered by their weight, highest to lowest, as per Section 5.3.1 of {{!RFC7231}} (omitting any language-range with a weight of 0). If a language-range lacks a weight, an implementation MAY assign one.
550
-
3. If the first member of available-values is not a member of preferred-langs, append it to preferred-langs (thus making it the default).
551
-
4. For each preferred-lang in preferred-langs:
552
-
1. If any member of available-values matches preferred-lang, using either the Basic or Extended Filtering scheme defined in Section 3.3 of {{!RFC4647}}, append those members of available-values to preferred-available (preserving their order).
553
-
5. Return preferred-available.
548
+
1. Let `preferred-available` be an empty list.
549
+
2. Let `preferred-langs` be a list of the language-ranges in the `request-value`, ordered by their weight, highest to lowest, as per Section 5.3.1 of {{!RFC7231}} (omitting any language-range with a weight of 0). If a language-range lacks a weight, an implementation MAY assign one.
550
+
3. If the first member of `available-values` is not a member of `preferred-langs`, append it to `preferred-langs` (thus making it the default).
551
+
4. For each `preferred-lang` in `preferred-langs`:
552
+
1. If any member of `available-values` matches `preferred-lang`, using either the Basic or Extended Filtering scheme defined in Section 3.3 of {{!RFC4647}}, append those members of `available-values` to `preferred-available` (preserving their order).
0 commit comments