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

Use Fetch's body read algorithms #313

Merged
merged 3 commits into from
Feb 26, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 17 additions & 17 deletions xhr.bs
Original file line number Diff line number Diff line change
Expand Up @@ -791,45 +791,45 @@ return <a>this</a>'s <a>cross-origin credentials</a>.
<li><p>If <a>this</a>'s <a>state</a> is not <i>opened</i> or <a>this</a>'s
<a><code>send()</code> flag</a> is unset, then return.

<li><p>Let <var>uploadedBytesLength</var> be 0.

<li>
<p>Let <var>processRequestBody</var>, given a <var>request</var>, be these steps:
<p>Let <var>processRequestBody</var>, given a <var>bytesLength</var>, be these steps:

<ol>
<li><p>Increase <var>uploadedBytesLength</var> by <var>bytesLength</var>.

<li><p>If not roughly 50ms have passed since these steps were last invoked, then return.

<li><p>If <a>this</a>'s <a>upload listener flag</a> is set, then <a>fire a progress event</a>
named <a event><code>progress</code></a> at <a>this</a>'s <a>upload object</a> with
<var>request</var>'s <a for=request>body</a>'s <a>transmitted bytes</a> and
<var>request</var>'s <a for=request>body</a>'s <a>total bytes</a>.
<var>uploadedBytesLength</var> and <var>req</var>'s <a for=request>body</a>'s
<a>total bytes</a>.
<!-- upload complete flag can never be set here I hope -->
</ol>

<p class=note>These steps are only invoked when new bytes are transmitted.

<li>
<p>Let <var>processRequestEndOfBody</var>, given a <var>request</var>, be these steps:
<p>Let <var>processRequestEndOfBody</var> be these steps:

<ol>
<li><p>Set <a>this</a>'s <a>upload complete flag</a>.

<li><p>If <a>this</a>'s <a>upload listener flag</a> is unset, then return.

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

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

<li><p><a>Fire a progress event</a> named <a event><code>progress</code></a> at <a>this</a>'s
<a>upload object</a> with <var>transmitted</var> and <var>length</var>.
<a>upload object</a> with <var>uploadedBytesLength</var> and <var>length</var>.

<li><p><a>Fire a progress event</a> named <a event><code>load</code></a> at <a>this</a>'s
<a>upload object</a> with <var>transmitted</var> and <var>length</var>.
<a>upload object</a> with <var>uploadedBytesLength</var> and <var>length</var>.

<li><p><a>Fire a progress event</a> named <a event><code>loadend</code></a> at <a>this</a>'s
<a>upload object</a> with <var>transmitted</var> and <var>length</var>.
<a>upload object</a> with <var>uploadedBytesLength</var> and <var>length</var>.
</ol>
<!-- upload complete flag can never be set here I hope -->

Expand Down Expand Up @@ -873,9 +873,9 @@ return <a>this</a>'s <a>cross-origin credentials</a>.
fires more often than <a>this</a>'s <a>state</a> changes.

<li><p><a>Fire a progress event</a> named <a event><code>progress</code></a> at <a>this</a>
with <a>this</a>'s <a for=XMLHttpRequest>response</a>'s <a for=response>body</a>'s
<a>read bytes</a> and <a>this</a>'s <a for=XMLHttpRequest>response</a>'s
<a for=response>body</a>'s <a>total bytes</a>.
with <a>this</a>'s <a>received bytes</a>'s <a for="byte sequence">length</a> and
<a>this</a>'s <a for=XMLHttpRequest>response</a>'s <a for=response>body</a>'s
<a>total bytes</a>.
</ol>

<li><p>Let <var>processEndOfBody</var> be this step: run <a>handle response end-of-body</a> for
Expand Down Expand Up @@ -981,8 +981,8 @@ steps:
<li><p>If <var>xhr</var>'s <a>synchronous flag</a> is unset, then update <var>xhr</var>'s
<a for=XMLHttpRequest>response</a>'s <a for=response>body</a> using <var>response</var>.

<li><p>Let <var>transmitted</var> be <var>response</var>'s <a for=response>body</a>'s
<a for=body>transmitted bytes</a>.
<li><p>Let <var>transmitted</var> be <var>xhr</var>'s <a>received bytes</a>'s
<a for="byte sequence">length</a>.

<li><p>Let <var>length</var> be <var>response</var>'s <a for=response>body</a>'s
<a for=body>total bytes</a>.
Expand Down