Skip to content

Commit

Permalink
Fix null-body issues
Browse files Browse the repository at this point in the history
  • Loading branch information
noamr committed Mar 13, 2024
1 parent e5cec34 commit 6c38f41
Showing 1 changed file with 46 additions and 42 deletions.
88 changes: 46 additions & 42 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -6711,67 +6711,71 @@ i.e. when a <a>fetch group</a> is <a for="fetch group">terminated</a>, or after
<li><p>If <var>request</var>'s <a for=request>URL</a> is not a
[=potentially trustworthy url=], then throw a "{{SecurityError}}" {{DOMException}}.

<li><p>If <var>request</var>'s <a for=request>body</a> is null then throw a {{TypeError}}.

<li><p>If <var>request</var>'s
<a for=request>body</a>'s <a for=body>length</a> is null, then throw a {{TypeError}}.

<li><p>Set <var>request</var>'s <a for=request>service-workers mode</a> to "<code>none</code>".

<li>
<p>If <var>request</var>'s <a for=request>body</a>'s <a for=body>source</a> is null, then throw a
{{TypeError}}.

<p class=note>This disallows sending deferred fetches with a live {{ReadableStream}}.

<li><p>If the result of calling <a>is feature enabled in document for origin?</a> given
"<code>deferred-fetch</code>", <var>document</var>, and <var>request</var>'s
<a for=request>origin</a> is <code>Disabled</code>, then throw a {{NotAllowedError}}.

<li><p>Let <var>totalScheduledDeferredBytesForTopLevelDocument</var> be
<var>request</var>'s <a for=request>body</a>'s <a for=body>length</a>.
<li>
<p>If <var>request</var>'s <a for=request>body</a> is not null then:

<li><p>Let <var>totalScheduledDeferredBytesForOrigin</var> be <var>request</var>'s
<a for=request>body</a>'s <a for=body>length</a>.
<ol>
<li><p>If <var>request</var>'s
<a for=request>body</a>'s <a for=body>length</a> is null, then throw a {{TypeError}}.

<li>
<p><a for=list>For each</a> <var>navigable</var> of <var>document</var>'s
<a>node navigable</a>'s <a for=navigable>top-level traversable</a>'s
<a for=Document>inclusive descendant navigables</a>:
<li>
<p>If <var>request</var>'s <a for=request>body</a>'s <a for=body>source</a> is null, then throw a
{{TypeError}}.

<p class=note>This algorithm asserts that this deferred fetch doesn't exceed two quotas: one for
the top-level document (640kb), and one for the reporting origin (64kb). The larger quota ensures
that the top-level {{Document}} and its subresources don't continue using an unlimited amount of
bandwidth after being destroyed. The smaller quota ensures that a single reporting sink doesn't
reserve the whole quota to itself.
<p class=note>This disallows sending deferred fetches with a live {{ReadableStream}}.

<li><p>Let <var>totalScheduledDeferredBytesForTopLevelDocument</var> be
<var>request</var>'s <a for=request>body</a>'s <a for=body>length</a>.

<li><p>Let <var>totalScheduledDeferredBytesForOrigin</var> be <var>request</var>'s
<a for=request>body</a>'s <a for=body>length</a>.

<ol>
<li>
<p><a for=list>For each</a> <a>deferred fetch record</a> <var>deferredRecord</var> in
<var>navigable</var>'s <a>active document</a>'s <a for=fetch>fetch group</a>'s
<a for="fetch group">deferred fetch records</a>:</p>
<p><a for=list>For each</a> <var>navigable</var> of <var>document</var>'s
<a>node navigable</a>'s <a for=navigable>top-level traversable</a>'s
<a for=Document>inclusive descendant navigables</a>:

<p class=note>This algorithm asserts that this deferred fetch doesn't exceed two quotas: one for
the top-level document (640kb), and one for the reporting origin (64kb). The larger quota ensures
that the top-level {{Document}} and its subresources don't continue using an unlimited amount of
bandwidth after being destroyed. The smaller quota ensures that a single reporting sink doesn't
reserve the whole quota to itself.

<ol>
<li><p>Let <var>length</var> be <var>deferredRecord</var>'s
<a for="deferred fetch record">request</a>'s <a for=request>body</a>'s
<a for=body>length</a>.
<li>
<p><a for=list>For each</a> <a>deferred fetch record</a> <var>deferredRecord</var> in
<var>navigable</var>'s <a>active document</a>'s <a for=fetch>fetch group</a>'s
<a for="fetch group">deferred fetch records</a>:</p>

<li><p>Increment <var>totalScheduledDeferredBytesForTopLevelDocument</var> by <var>length</var>.
<ol>
<li><p>Let <var>length</var> be <var>deferredRecord</var>'s
<a for="deferred fetch record">request</a>'s <a for=request>body</a>'s
<a for=body>length</a>.

<li><p>Increment <var>totalScheduledDeferredBytesForTopLevelDocument</var> by <var>length</var>.

<li><p>If <var>totalScheduledDeferredBytesForTopLevelDocument</var> is greater than 640
kilobytes, then throw a "{{QuotaExceededError}}" {{DOMException}}.
<li><p>If <var>totalScheduledDeferredBytesForTopLevelDocument</var> is greater than 640
kilobytes, then throw a "{{QuotaExceededError}}" {{DOMException}}.

<li><p>If <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>'s
<a for=request>URL</a>'s <a for=url>origin</a> is <a>same origin</a> with
<var>request</var>'s <a for=request>origin</a>, then increment
<var>totalScheduledDeferredBytesForOrigin</var> by <var>length</var>.
<li><p>If <var>deferredRecord</var>'s <a for="deferred fetch record">request</a>'s
<a for=request>URL</a>'s <a for=url>origin</a> is <a>same origin</a> with
<var>request</var>'s <a for=request>origin</a>, then increment
<var>totalScheduledDeferredBytesForOrigin</var> by <var>length</var>.

<li><p>If <var>totalScheduledDeferredBytesForOrigin</var> is greater than 64 kilobytes, then
throw a "{{QuotaExceededError}}" {{DOMException}}.
<li><p>If <var>totalScheduledDeferredBytesForOrigin</var> is greater than 64 kilobytes, then
throw a "{{QuotaExceededError}}" {{DOMException}}.
</ol>
</li>
</ol>
</li>
</ol>

<li><p>Set <var>request</var>'s <a for=request>service-workers mode</a> to "<code>none</code>".

<li><p>Set <var>request</var>'s <a for=request>keepalive</a> to true.

<li><p>Let <var>deferredRecord</var> be a new <a>deferred fetch record</a> whose
Expand Down

0 comments on commit 6c38f41

Please sign in to comment.