Skip to content

Commit

Permalink
Range requests: Make status/range verification optional
Browse files Browse the repository at this point in the history
Verifying media responses performs 3 verifications:
* The response should also be a range response
* The response's range should match the request's range
* There should not be mixed origins with opaque response

While the last verification is mandatory for same-origin policy, the first two
are optional, and may be skipped if the user-agent decides to be lenient towards
servers who don't handle range requests properly.

See #7655 (comment)
  • Loading branch information
noamr committed Apr 11, 2022
1 parent 64d4e4d commit 9accf7d
Showing 1 changed file with 30 additions and 14 deletions.
44 changes: 30 additions & 14 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -34690,16 +34690,22 @@ interface <dfn interface>MediaError</dfn> {
(number, number or "<code data-x="">until end</code>") tuple <var>byteRange</var>:</p>

<ol>
<li><p>If <var>response</var> is a <span>network error</span>, then return false.</p></li>

<li><p>If <var>byteRange</var> is "<code data-x="">entire resource</code>", then return
true.</p></li>
<li><p>If <var>response</var> is a <span>network error</span>, then return
"<code data-x="">failure</code>".</p></li>

<li><p>Let <var>internalResponse</var> be <var>response</var>'s
<span>unsafe response</span>.</p></li>

<li><p>If <var>internalResponse</var>'s <span data-x="concept-response-status">status</span> is
not 206, then return false.</p></li>
neither 200 or 206, then return "<code data-x="">failure</code>".</p></li>

<li><p>If <var>internalResponse</var>'s <span data-x="concept-response-status">status</span> is
200, then: If <var>byteRange</var> is "<code data-x="">entire resource</code>" then return
"<code data-x="">success</code>". Otherwise return
"<code data-x="">range not supported</code>".</p></li>

<li><p>If <var>byteRange</var> is "<code data-x="">entire resource</code>" then set
<var>byteRange</var> to (0, "<code data-x="">until end</code>").</p></li>

<li><p>Let <var>origin</var> be "<code data-x="">rewritten</code>" if
<var>internalResponse</var>'s <span data-x="concept-response-url">URL</span> is null; otherwise
Expand All @@ -34724,7 +34730,8 @@ interface <dfn interface>MediaError</dfn> {
<p>then set <var>resource</var>'s <span data-x="media-resource-origin">origin</span> to
<var>origin</var>.</p>

<p>Otherwise, if <var>response</var> is <span>CORS-cross-origin</span>, then return false.</p>
<p>Otherwise, if <var>response</var> is <span>CORS-cross-origin</span>, then return
"<code data-x="">failure</code>".</p>

<p>Otherwise, set <var>resource</var>'s <span data-x="media-resource-origin">origin</span> to
"<code data-x="">multiple</code>".</p>
Expand All @@ -34739,9 +34746,9 @@ interface <dfn interface>MediaError</dfn> {

<li><p>If <var>start</var> is not <var>byteRange</var>[0], or if
<var>byteRange</var>[1] is neither "<code data-x="">until end</code>" or <var>end</var>,
return false.</p></li>
return "<code data-x="">range mismatch</code>".</p></li>

<li><p>Return true.</p></li>
<li><p>Return "<code data-x="">success</code>".</p></li>
</ol>

<p>The <dfn data-x="concept-media-load-resource" export>resource fetch algorithm</dfn> for a
Expand Down Expand Up @@ -34878,12 +34885,21 @@ interface <dfn interface>MediaError</dfn> {
</ol>
</li>

<li><p>If the result of <span data-x="verify a media response">verifying</span>
<var>response</var> given the <var>current media resource</var> and
<var>byteRange</var> is false, then call <var>finalize</var>. Otherwise,
<span data-x="body-incrementally-read">incrementally read</span> <var>response</var>'s
<span data-x="concept-response-body">body</span> given <var>updateMedia</var>,
<var>processEndOfMedia</var>, <var>finalize</var>, and <var>global</var>.</p></li>
<li>
<p>If the result of
<span data-x="verify a media response">verifying</span> <var>response</var> given the
<var>current media resource</var> and <var>byteRange</var> is
"<code data-x="">failure</code>", then call <var>finalize</var>. Otherwise,
<span data-x="body-incrementally-read">incrementally read</span>
<var>response</var>'s <span data-x="concept-response-body">body</span> given
<var>updateMedia</var>, <var>processEndOfMedia</var>, <var>finalize</var>, and
<var>global</var>.</p>

<p>User-agents may also treat "<code data-x="">range mismatch</code>" and
"<code data-x="">range not supported</code>" as failures. Supporting media loading from
servers without proper support for HTTP range requests requires buffering on the client
side, which might have implications on performance and memory use.</p>
</li>

<li><p>Update the <span>media data</span> with the contents of <var>response</var>'s
<span>unsafe response</span> obtained in this fashion. <var>response</var> can be
Expand Down

0 comments on commit 9accf7d

Please sign in to comment.