Skip to content

Commit 62e5d0b

Browse files
authored
Editorial: add <div algorithm> wrappers to header algorithms
Helps with #1526.
1 parent 5b47129 commit 62e5d0b

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

fetch.bs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,7 @@ for consistency.
548548
<p class="note no-backref">A <a for=/>header list</a> is essentially a
549549
specialized multimap: an ordered list of key-value pairs with potentially duplicate keys.
550550

551+
<div algorithm>
551552
<p>To
552553
<dfn export for="header list" id=concept-header-list-get-structured-header>get a structured field value</dfn>
553554
given a <a for=/>header name</a> <var>name</var> and a string <var>type</var> from a
@@ -574,7 +575,9 @@ given a <a for=/>header name</a> <var>name</var> and a string <var>type</var> fr
574575
<p class="note"><a>Get a structured field value</a> intentionally does not distinguish between a
575576
<a for=/>header</a> not being present and its <a for=header>value</a> failing to parse as a
576577
<a>structured field value</a>. This ensures uniform processing across the web platform.
578+
</div>
577579

580+
<div algorithm>
578581
<p>To
579582
<dfn export for="header list" id=concept-header-list-set-structured-header>set a structured field value</dfn>
580583
given a <a for=/>tuple</a> (<a for=/>header name</a> <var>name</var>, <a>structured field value</a>
@@ -594,15 +597,19 @@ serialize in interesting and efficient ways. For the moment, Fetch only supports
594597
<a for=/>header lists</a> only via serialization, and they can be obtained from
595598
<a for=/>header lists</a> only by parsing. In the future the fact that they are objects might be
596599
preserved end-to-end. [[!RFC8941]]
600+
</div>
597601

598602
<hr>
599603

604+
<div algorithm>
600605
<p>A <a for=/>header list</a> <var>list</var>
601606
<dfn export for="header list" lt="contains|does not contain">contains</dfn> a
602607
<a for=/>header name</a> <var>name</var> if <var>list</var> <a for=list>contains</a> a
603608
<a for=/>header</a> whose <a for=header>name</a> is a <a>byte-case-insensitive</a> match for
604609
<var>name</var>.
610+
</div>
605611

612+
<div algorithm>
606613
<p>To <dfn export for="header list" id=concept-header-list-get>get</dfn> a <a for=/>header name</a>
607614
<var>name</var> from a <a for=/>header list</a> <var>list</var>, run these steps:
608615

@@ -614,7 +621,9 @@ preserved end-to-end. [[!RFC8941]]
614621
whose <a for=header>name</a> is a <a>byte-case-insensitive</a> match for <var>name</var>, separated
615622
from each other by 0x2C 0x20, in order.
616623
</ol>
624+
</div>
617625

626+
<div algorithm>
618627
<p>To
619628
<dfn export for="header list" lt="get, decode, and split|getting, decoding, and splitting" id=concept-header-list-get-decode-split>get, decode, and split</dfn>
620629
a <a for=/>header name</a> <var>name</var> from <a for=/>header list</a> <var>list</var>, run these
@@ -629,6 +638,7 @@ steps:
629638
<li><p>Return the result of <a for="header value">getting, decoding, and splitting</a>
630639
<var>value</var>.
631640
</ol>
641+
</div>
632642

633643
<div class=example id=example-header-list-get-decode-split>
634644
<p>This is how <a for="header list">get, decode, and split</a> functions in practice with
@@ -703,6 +713,7 @@ A: 3
703713
</table>
704714
</div>
705715

716+
<div algorithm>
706717
<p>To
707718
<dfn for="header value" lt="get, decode, and split|getting, decoding, and splitting">get, decode, and split</dfn>
708719
a <a for=/>header value</a> <var>value</var>, run these steps:
@@ -766,7 +777,9 @@ a <a for=/>header value</a> <var>value</var>, run these steps:
766777

767778
<p class=note>Except for blessed call sites, the algorithm directly above is not to be invoked
768779
directly. Use <a for="header list">get, decode, and split</a> instead.
780+
</div>
769781

782+
<div algorithm>
770783
<p>To <dfn export for="header list" id=concept-header-list-append>append</dfn> a <a for=/>header</a>
771784
(<var>name</var>, <var>value</var>) to a <a for=/>header list</a> <var>list</var>, run these steps:
772785

@@ -781,12 +794,16 @@ directly. Use <a for="header list">get, decode, and split</a> instead.
781794

782795
<li><p><a for=list>Append</a> (<var>name</var>, <var>value</var>) to <var>list</var>.
783796
</ol>
797+
</div>
784798

799+
<div algorithm>
785800
<p>To <dfn export for="header list" id=concept-header-list-delete>delete</dfn> a
786801
<a for=/>header name</a> <var>name</var> from a <a for=/>header list</a> <var>list</var>,
787802
<a for=list>remove</a> all <a for=/>headers</a> whose <a for=header>name</a> is a
788803
<a>byte-case-insensitive</a> match for <var>name</var> from <var>list</var>.
804+
</div>
789805

806+
<div algorithm>
790807
<p>To <dfn export for="header list" id=concept-header-list-set>set</dfn> a <a for=/>header</a>
791808
(<var>name</var>, <var>value</var>) in a <a for=/>header list</a> <var>list</var>, run these steps:
792809

@@ -797,7 +814,9 @@ directly. Use <a for="header list">get, decode, and split</a> instead.
797814

798815
<li><p>Otherwise, <a for=list>append</a> (<var>name</var>, <var>value</var>) to <var>list</var>.
799816
</ol>
817+
</div>
800818

819+
<div algorithm>
801820
<p>To <dfn export for="header list" id=concept-header-list-combine>combine</dfn> a
802821
<a for=/>header</a> (<var>name</var>, <var>value</var>) in a <a for=/>header list</a>
803822
<var>list</var>, run these steps:
@@ -812,7 +831,9 @@ directly. Use <a for="header list">get, decode, and split</a> instead.
812831

813832
<p class=note><a for="header list">Combine</a> is used by {{XMLHttpRequest}} and the
814833
<a spec=websockets lt="establish a WebSocket connection">WebSocket protocol handshake</a>.
834+
</div>
815835

836+
<div algorithm>
816837
<p>To <dfn>convert header names to a sorted-lowercase set</dfn>, given a <a for=/>list</a> of
817838
<a lt=name for=header>names</a> <var>headerNames</var>, run these steps:
818839

@@ -826,7 +847,9 @@ directly. Use <a for="header list">get, decode, and split</a> instead.
826847
<li><p>Return the result of <a for=set>sorting</a> <var>headerNamesSet</var> in ascending order
827848
with <a>byte less than</a>.
828849
</ol>
850+
</div>
829851

852+
<div algorithm>
830853
<p>To
831854
<dfn export for="header list" id=concept-header-list-sort-and-combine>sort and combine</dfn>
832855
a <a for=/>header list</a> <var>list</var>, run these steps:
@@ -853,6 +876,7 @@ a <a for=/>header list</a> <var>list</var>, run these steps:
853876

854877
<li><p>Return <var>headers</var>.
855878
</ol>
879+
</div>
856880

857881
<hr>
858882

@@ -875,12 +899,15 @@ conditions:
875899
production as
876900
<a href=https://github.com/httpwg/http11bis/issues/19 title="fix field-value ABNF">it is broken</a>.
877901

902+
<div algorithm>
878903
<p>To <dfn export for="header value" id=concept-header-value-normalize>normalize</dfn> a
879904
<a for=/>byte sequence</a> <var>potentialValue</var>, remove any leading and trailing
880905
<a>HTTP whitespace bytes</a> from <var>potentialValue</var>.
906+
</div>
881907

882908
<hr>
883909

910+
<div algorithm>
884911
<p id=simple-header>To determine whether a <a for=/>header</a> (<var>name</var>, <var>value</var>)
885912
is a <dfn export>CORS-safelisted request-header</dfn>, run these steps:
886913

@@ -964,7 +991,9 @@ fetch("https://victim.example/naïve-endpoint", {
964991

965992
<p class="note">There are limited exceptions to the `<code>Content-Type</code>` header safelist, as
966993
documented in <a href=#cors-protocol-exceptions>CORS protocol exceptions</a>.
994+
</div>
967995

996+
<div algorithm>
968997
<p>A <dfn>CORS-unsafe request-header byte</dfn> is a byte <var>byte</var> for which one of the
969998
following is true:
970999

@@ -976,7 +1005,9 @@ following is true:
9761005
<!-- Delimiters from https://datatracker.ietf.org/doc/html/rfc7230#section-3.2.6 except for ,/;=
9771006
and including DEL -->
9781007
</ul>
1008+
</div>
9791009

1010+
<div algorithm>
9801011
<p>The <dfn noexport>CORS-unsafe request-header names</dfn>, given a <a for=/>header list</a>
9811012
<var>headers</var>, are determined as follows:
9821013

@@ -1006,6 +1037,7 @@ following is true:
10061037
<li><p>Return the result of <a>convert header names to a sorted-lowercase set</a> with
10071038
<var>unsafeNames</var>.
10081039
</ol>
1040+
</div>
10091041

10101042
<p>A <dfn export>CORS non-wildcard request-header name</dfn> is a <a for=/>header name</a> that is a
10111043
<a>byte-case-insensitive</a> match for `<code>Authorization</code>`.
@@ -1054,6 +1086,7 @@ is a <a>byte-case-insensitive</a> match for one of
10541086
<li>`<code>Content-Type</code>`
10551087
</ul>
10561088

1089+
<div algorithm>
10571090
<p>To determine whether a <a for/>header</a> (<var>name</var>, <var>value</var>) is a
10581091
<dfn noexport>no-CORS-safelisted request-header</dfn>, run these steps:
10591092

@@ -1064,7 +1097,9 @@ is a <a>byte-case-insensitive</a> match for one of
10641097
<li><p>Return whether (<var>name</var>, <var>value</var>) is a
10651098
<a>CORS-safelisted request-header</a>.
10661099
</ol>
1100+
</div>
10671101

1102+
<div algorithm>
10681103
<p id=forbidden-header-name>A <a for=/>header</a> (<var>name</var>, <var>value</var>) is
10691104
<dfn export>forbidden request-header</dfn> if these steps return true:
10701105

@@ -1135,6 +1170,7 @@ is a <a>byte-case-insensitive</a> match for one of
11351170
handling in the {{Headers}} object. It is forbidden here to avoid leaking this complexity into
11361171
requests.
11371172
</div>
1173+
</div>
11381174

11391175
<p>A <dfn export>forbidden response-header name</dfn> is a <a for=/>header name</a> that is a
11401176
<a>byte-case-insensitive</a> match for one of:
@@ -1156,6 +1192,7 @@ is a <a>byte-case-insensitive</a> match for one of
11561192

11571193
<hr>
11581194

1195+
<div algorithm>
11591196
<p>To <dfn export lt="extract header values|extracting header values">extract header values</dfn>
11601197
given a <a for=/>header</a> <var>header</var>, run these steps:
11611198

@@ -1166,7 +1203,9 @@ given a <a for=/>header</a> <var>header</var>, run these steps:
11661203
<li><p>Return one or more <a for=header>values</a> resulting from parsing <var>header</var>'s
11671204
<a for=header>value</a>, per the <a>ABNF</a> for <var>header</var>'s <a for=header>name</a>.
11681205
</ol>
1206+
</div>
11691207

1208+
<div algorithm>
11701209
<p>To
11711210
<dfn export lt="extract header list values|extracting header list values">extract header list values</dfn>
11721211
given a <a for=/>header name</a> <var>name</var> and a <a for=/>header list</a> <var>list</var>,
@@ -1200,7 +1239,9 @@ run these steps:
12001239

12011240
<li><p>Return <var>values</var>.
12021241
</ol>
1242+
</div>
12031243

1244+
<div algorithm>
12041245
<p>To <dfn id=simple-range-header-value>parse a single range header value</dfn> from a
12051246
<a>byte sequence</a> <var>value</var>, run these steps:
12061247

@@ -1247,6 +1288,7 @@ run these steps:
12471288
<p class=note><a>Parse a single range header value</a> succeeds for a subset of allowed range header
12481289
values, but it is the most common form used by user agents when requesting media or resuming
12491290
downloads. This format of range header value can be set using <a>add a range header</a>.
1291+
</div>
12501292

12511293
<hr>
12521294

@@ -2125,6 +2167,7 @@ is to return the result of <a>serializing a request origin</a> with <var>request
21252167

21262168
<hr>
21272169

2170+
<div algorithm>
21282171
<p>To <dfn export for=request id=concept-request-add-range-header>add a range header</dfn> to a
21292172
<a for=/>request</a> <var>request</var>, with an integer <var>first</var>, and an optional integer
21302173
<var>last</var>, run these steps:
@@ -2152,6 +2195,7 @@ is to return the result of <a>serializing a request origin</a> with <var>request
21522195

21532196
<p class=note>Features that combine multiple responses into one logical resource are historically a
21542197
source of security bugs. Please seek security review for features that deal with partial responses.
2198+
</div>
21552199

21562200
<hr>
21572201

0 commit comments

Comments
 (0)