Skip to content

Commit

Permalink
Editorial: create the build a content range algorithm
Browse files Browse the repository at this point in the history
Move the content-range algorithm to a standalone algorithm to avoid the additional inlined steps in scheme fetch.

Fixes #1552.
  • Loading branch information
dlrobertson committed Aug 24, 2023
1 parent 53e4c3d commit f64d43f
Showing 1 changed file with 26 additions and 15 deletions.
41 changes: 26 additions & 15 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1300,6 +1300,30 @@ run these steps:
</ol>
</div>

<div algorithm>
<p>To <dfn>build a content range</dfn> given an integer <var>rangeStart</var>, an integer
<var>rangeEnd</var>, and an integer <var>fullLength</var>, run these steps:

<ol>
<li><p>Let <var>contentRange</var> be `<code>bytes </code>`.

<li><p>Append <var>rangeStart</var>, <a lt="serialize an integer">serialized</a> and
<a>isomorphic encoded</a>, to <var>contentRange</var>.

<li><p>Append 0x2D (-) to <var>contentRange</var>.

<li><p>Append <var>rangeEnd</var>, <a lt="serialize an integer">serialized</a> and
<a>isomorphic encoded</a> to <var>contentRange</var>.

<li><p>Append 0x2F (/) to <var>contentRange</var>.

<li><p>Append <var>fullLength</var>, <a lt="serialize an integer">serialized</a> and
<a>isomorphic encoded</a> to <var>contentRange</var>.

<li><p>Return <var>contentRange</var>.
</ol>
</div>

<div algorithm>
<p>To <dfn id=simple-range-header-value>parse a single range header value</dfn> from a
<a>byte sequence</a> <var>value</var> and a boolean <var>allowWhitespace</var>, run these steps:
Expand Down Expand Up @@ -5004,21 +5028,8 @@ steps:
<li><p>Let <var>serializedSlicedLength</var> be <var>slicedBlob</var>'s {{Blob/size}},
<a lt="serialize an integer">serialized</a> and <a>isomorphic encoded</a>.

<!-- The following steps for content-range should be definined in a separate algorithm.
See https://github.com/whatwg/fetch/issues/1552 for future work -->
<li><p>Let <var>contentRange</var> be `<code>bytes </code>`.

<li><p>Append <var>rangeStart</var>, <a lt="serialize an integer">serialized</a> and
<a>isomorphic encoded</a>, to <var>contentRange</var>.

<li><p>Append 0x2D (-) to <var>contentRange</var>.

<li><p>Append <var>rangeEnd</var>, <a lt="serialize an integer">serialized</a> and
<a>isomorphic encoded</a> to <var>contentRange</var>.

<li><p>Append 0x2F (/) to <var>contentRange</var>.

<li><p>Append <var>serializedFullLength</var> to <var>contentRange</var>.
<li><p>Let <var>contentRange</var> be the result of invoking <a>build a content range</a>
given <var>rangeStart</var>, <var>rangeEnd</var>, and <var>fullLength</var>.

<li><p>Set <var>response</var>'s <a for=response>status</a> to 206.

Expand Down

0 comments on commit f64d43f

Please sign in to comment.