Skip to content

Editorial: Create the build a content range algorithm #1696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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