Skip to content
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

Allow range header without preflight #1312

Merged
merged 15 commits into from
Oct 5, 2021
81 changes: 78 additions & 3 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -770,6 +770,9 @@ production as
<ol>
<li><p>Let <var>value</var> be <var>header</var>'s <a for=header>value</a>.

<li><p>If <var>value</var>'s <a for="byte sequence">length</a> is greater than 128, then return
false.
jakearchibald marked this conversation as resolved.
Show resolved Hide resolved

<li>
<p><a>Byte-lowercase</a> <var>header</var>'s <a for=header>name</a> and switch on the result:

Expand Down Expand Up @@ -822,13 +825,13 @@ fetch("https://victim.example/naïve-endpoint", {
</code></pre>
</div>

<dt>`<code>Range</code>`
jakearchibald marked this conversation as resolved.
Show resolved Hide resolved
<dd><p>If <var>value</var> is not a <a>simple range header value</a>, then return false.

<dt>Otherwise
<dd><p>Return false.
</dl>

<li><p>If <var>value</var>'s <a for="byte sequence">length</a> is greater than 128, then return
false.

<li><p>Return true.
</ol>

Expand Down Expand Up @@ -1038,6 +1041,75 @@ run these steps:
<li><p>Return <var>values</var>.
</ol>

<p>To determine if a <a>byte sequence</a> <var>value</var> is a
<dfn>simple range header value</dfn>, perform the following steps. They return a <a>boolean</a>.

<ol>
jakearchibald marked this conversation as resolved.
Show resolved Hide resolved
<li><p>If <var>value</var> does not <a for="byte sequence" lt="starts with">start with</a>
`<code>bytes </code>`, then return false.

<li><p>If the 6th <a>byte</a> of <var>value</var> is not in the range 0x30 (0) to 0x39 (9),
inclusive, then return false.

<li><p>Let <var>rangeStartBytes</var> be the 6th <a>byte</a> of <var>value</var>.
jakearchibald marked this conversation as resolved.
Show resolved Hide resolved

<li><p>Let <var>rangeEndBytes</var> be an empty <a>byte sequence</a>.

<li><p>Let <var>state</var> be "<code>rangeStart</code>".

<li><p>Let <var>i</var> be 7.

<li>
<p>While <var>i</var> is less than <var>value</var>'s <a for="byte sequence">length</a>:

<ol>
<li>
<p>Switch on <var>state</var>:

<dl class="switch">
<dt>"<code>rangeStart</code>"
<dd>
<ol>
<li><p>If the <var>i</var>th <a>byte</a> of <var>value</var> is 0x2D (-), then set
<var>state</var> to "<code>rangeEnd</code>".

<li>
<p>Otherwise:

<ol>
<li><p>If the <var>i</var>th <a>byte</a> of <var>value</var> is not in the range 0x30 (0)
to 0x39 (9), inclusive, then return false.

<li><p>Append the <var>i</var>th <a>byte</a> of <var>value</var> to
<var>rangeStartBytes</var>.
</ol>
</ol>

<dt>"<code>rangeEnd</code>"
<dd>
<ol>
<li><p>If the <var>i</var>th <a>byte</a> of <var>value</var> is not in the range 0x30 (0) to
0x39 (9), inclusive, then return false.

<li><p>Append the <var>i</var>th <a>byte</a> of <var>value</var> to <var>rangeEndBytes</var>.
</ol>
</dl>

<li><p>Increment <var>i</var>.
</ol>

<li>If <var>rangeEndBytes</var>'s <a for="byte sequence">length</a> is 0, then return true.

<li><p>If <var>rangeStartBytes</var>, parsed as an integer, is greater than
<var>rangeEndBytes</var>, parsed as an integer, then return false.
jakearchibald marked this conversation as resolved.
Show resolved Hide resolved

<li><p>Return true.
</ol>

<p class="note">A <a>simple range header value</a> is a subset of allowed range header values, but
it's the most common form used by user agents when requesting media or resuming downloads. This
jakearchibald marked this conversation as resolved.
Show resolved Hide resolved
format of range header value can be set using <a>add a range header</a>.

<hr>

<p>A <dfn id=default-user-agent-value export>default `<code>User-Agent</code>` value</dfn> is a
Expand Down Expand Up @@ -1847,6 +1919,9 @@ is to return the result of <a>serializing a request origin</a> with <var>request
<var>last</var>, run these steps:

<ol>
<li><p>Assert: <var>last</var> is not given, or <var>first</var> is less than or equal to
<var>last</var>.

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

<li><p><a lt="serialize an integer">Serialize</a> and <a>isomorphic encode</a> <var>first</var>,
Expand Down