Skip to content

Commit

Permalink
Allow for a request to finish after a response starts to arrive
Browse files Browse the repository at this point in the history
An HTTP response can arrive before an HTTP request is fully
transmitted. The model in Fetch so far assumed a request was done by
the time a response started to arrive. That model was wrong and this
change fixes that.

This fixes the first part of #229.
  • Loading branch information
annevk committed Mar 25, 2016
1 parent 1873eda commit 3a41b6f
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 40 deletions.
49 changes: 29 additions & 20 deletions Overview.html
Original file line number Diff line number Diff line change
Expand Up @@ -246,15 +246,9 @@ <h2 id="infrastructure"><span class="secno">3 </span>Infrastructure</h2>
<a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/webappapis.html#networking-task-source">networking task source</a>.
</ol>

<p>To <dfn id="queue-a-fetch-done-task">queue a fetch-done task</dfn>, given a <var>request</var> and
<var>response</var>, run these steps:

<ol>
<li><p>Set <var>request</var>'s <a href="#done-flag">done flag</a>.

<li><p><a href="#queue-a-fetch-task">Queue a fetch task</a> on <var>request</var> to
<a href="#process-response-end-of-file">process response end-of-file</a> for <var>response</var>.
</ol>
<p>To <dfn id="queue-a-fetch-request-done-task">queue a fetch-request-done task</dfn>, given a <var>request</var>,
<a href="#queue-a-fetch-task">queue a fetch task</a> on <var>request</var> to <a href="#process-request-end-of-file">process request end-of-file</a>
for <var>request</var>.

<hr>

Expand Down Expand Up @@ -554,12 +548,15 @@ <h4 id="bodies"><span class="secno">3.1.4 </span>Bodies</h4>
<li><p>A <dfn id="concept-body-total-bytes" title="concept-body-total-bytes">total bytes</dfn> (an integer), initially 0.
</ul>

<p>To <dfn id="concept-body-wait" title="concept-body-wait">wait</dfn> for a <a href="#concept-body" title="concept-body">body</a>
<var>body</var>, if <var>body</var> is non-null, wait for <var>body</var>'s
<a href="#concept-body-stream" title="concept-body-stream">stream</a> to be
<p>A <a href="#concept-body" title="concept-body">body</a> <var>body</var> is said to be
<dfn id="concept-body-done" title="concept-body-done">done</dfn> if <var>body</var> is null or <var>body</var>'s
<a href="#concept-body-stream" title="concept-body-stream">stream</a> is
<a href="#concept-readablestream-closed" title="concept-ReadableStream-closed">closed</a> or
<a href="#concept-readablestream-errored" title="concept-ReadableStream-errored">errored</a>.

<p>To <dfn id="concept-body-wait" title="concept-body-wait">wait</dfn> for a <a href="#concept-body" title="concept-body">body</a>
<var>body</var>, wait for <var>body</var> to be <a href="#concept-body-done" title="concept-body-done">done</a>.

<p>To <dfn id="concept-body-clone" title="concept-body-clone">clone</dfn> a <a href="#concept-body" title="concept-body">body</a>
<var>body</var>, run these steps:

Expand Down Expand Up @@ -2181,21 +2178,32 @@ <h3 id="main-fetch"><span class="secno">5.1 </span>Main fetch</h3>

<p class="note no-backref">This terminates <a href="#concept-fetch" title="concept-fetch">fetch</a>.

<li><p>If <var>request</var>'s <a href="#concept-request-body" title="concept-request-body">body</a> is
non-null and <var>request</var>'s
<a href="#concept-request-current-url" title="concept-request-current-url">current url</a>'s
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url-scheme" title="concept-url-scheme">scheme</a> is
"<code title="">http</code>" or "<code title="">https</code>",
<a href="#queue-a-fetch-task">queue a fetch task</a> on <var>request</var> to
<a href="#process-request-end-of-file">process request end-of-file</a> for <var>request</var>.
<li>
<p>If <var>request</var>'s <a href="#concept-request-current-url" title="concept-request-current-url">current url</a>'s
<a class="external" data-anolis-spec="url" href="https://url.spec.whatwg.org/#concept-url-scheme" title="concept-url-scheme">scheme</a> is "<code title="">http</code>" or
"<code title="">https</code>", run these substeps:</p>

<ol>
<li><p>If <var>request</var>'s <a href="#concept-request-body" title="concept-request-body">body</a> is
<a href="#concept-body-done" title="concept-body-done">done</a>, <a href="#queue-a-fetch-request-done-task">queue a fetch-request-done task</a> for
<var>request</var>.

<li><p>Otherwise, <a class="external" data-anolis-spec="html" href="https://html.spec.whatwg.org/multipage/infrastructure.html#in-parallel">in parallel</a>,
<a href="#concept-body-wait" title="concept-body-wait">wait</a> for <var>request</var>'s
<a href="#concept-request-body" title="concept-request-body">body</a>, and then
<a href="#queue-a-fetch-request-done-task">queue a fetch-request-done task</a> for <var>request</var>.
</ol>

<li><p><a href="#queue-a-fetch-task">Queue a fetch task</a> on <var>request</var> to
<a href="#process-response">process response</a> for <var>response</var>.

<li><p><a href="#concept-body-wait" title="concept-body-wait">Wait</a> for <var>internalResponse</var>'s
<a href="#concept-response-body" title="concept-response-body">body</a>.

<li><p><a href="#queue-a-fetch-done-task">Queue a fetch-done task</a> using <var>request</var> and <var>response</var>.
<li><p>Set <var>request</var>'s <a href="#done-flag">done flag</a>.

<li><p><a href="#queue-a-fetch-task">Queue a fetch task</a> on <var>request</var> to
<a href="#process-response-end-of-file">process response end-of-file</a> for <var>response</var>.
</ol>


Expand Down Expand Up @@ -5177,6 +5185,7 @@ <h2 class="no-num" id="acknowledgments">Acknowledgments</h2>
Keith Yeung,
Kenji Baheux,
Lachlan Hunt,
Louis Ryan,
Lucas Gonze,
呂康豪 (Kang-Hao Lu),
Maciej Stachowiak,
Expand Down
49 changes: 29 additions & 20 deletions Overview.src.html
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,9 @@ <h2>Infrastructure</h2>
<span data-anolis-spec=html>networking task source</span>.
</ol>

<p>To <dfn>queue a fetch-done task</dfn>, given a <var>request</var> and
<var>response</var>, run these steps:

<ol>
<li><p>Set <var>request</var>'s <span>done flag</span>.

<li><p><span>Queue a fetch task</span> on <var>request</var> to
<span>process response end-of-file</span> for <var>response</var>.
</ol>
<p>To <dfn>queue a fetch-request-done task</dfn>, given a <var>request</var>,
<span>queue a fetch task</span> on <var>request</var> to <span>process request end-of-file</span>
for <var>request</var>.

<hr>

Expand Down Expand Up @@ -485,12 +479,15 @@ <h4>Bodies</h4>
<li><p>A <dfn title=concept-body-total-bytes>total bytes</dfn> (an integer), initially 0.
</ul>

<p>To <dfn title=concept-body-wait>wait</dfn> for a <span title=concept-body>body</span>
<var>body</var>, if <var>body</var> is non-null, wait for <var>body</var>'s
<span title=concept-body-stream>stream</span> to be
<p>A <span title=concept-body>body</span> <var>body</var> is said to be
<dfn title=concept-body-done>done</dfn> if <var>body</var> is null or <var>body</var>'s
<span title=concept-body-stream>stream</span> is
<span title=concept-ReadableStream-closed>closed</span> or
<span title=concept-ReadableStream-errored>errored</span>.

<p>To <dfn title=concept-body-wait>wait</dfn> for a <span title=concept-body>body</span>
<var>body</var>, wait for <var>body</var> to be <span title=concept-body-done>done</span>.

<p>To <dfn title=concept-body-clone>clone</dfn> a <span title=concept-body>body</span>
<var>body</var>, run these steps:

Expand Down Expand Up @@ -2112,21 +2109,32 @@ <h3>Main fetch</h3>

<p class="note no-backref">This terminates <span title=concept-fetch>fetch</span>.

<li><p>If <var>request</var>'s <span title=concept-request-body>body</span> is
non-null and <var>request</var>'s
<span title=concept-request-current-url>current url</span>'s
<span data-anolis-spec=url title=concept-url-scheme>scheme</span> is
"<code title>http</code>" or "<code title>https</code>",
<span>queue a fetch task</span> on <var>request</var> to
<span>process request end-of-file</span> for <var>request</var>.
<li>
<p>If <var>request</var>'s <span title=concept-request-current-url>current url</span>'s
<span data-anolis-spec=url title=concept-url-scheme>scheme</span> is "<code title>http</code>" or
"<code title>https</code>", run these substeps:</p>

<ol>
<li><p>If <var>request</var>'s <span title=concept-request-body>body</span> is
<span title=concept-body-done>done</span>, <span>queue a fetch-request-done task</span> for
<var>request</var>.

<li><p>Otherwise, <span data-anolis-spec=html>in parallel</span>,
<span title=concept-body-wait>wait</span> for <var>request</var>'s
<span title=concept-request-body>body</span>, and then
<span>queue a fetch-request-done task</span> for <var>request</var>.
</ol>

<li><p><span>Queue a fetch task</span> on <var>request</var> to
<span>process response</span> for <var>response</var>.

<li><p><span title=concept-body-wait>Wait</span> for <var>internalResponse</var>'s
<span title=concept-response-body>body</span>.

<li><p><span>Queue a fetch-done task</span> using <var>request</var> and <var>response</var>.
<li><p>Set <var>request</var>'s <span>done flag</span>.

<li><p><span>Queue a fetch task</span> on <var>request</var> to
<span>process response end-of-file</span> for <var>response</var>.
</ol>


Expand Down Expand Up @@ -5019,6 +5027,7 @@ <h2 class=no-num>Acknowledgments</h2>
Keith Yeung,
Kenji Baheux,
Lachlan Hunt,
Louis Ryan,
Lucas Gonze,
呂康豪 (Kang-Hao Lu),
Maciej Stachowiak,
Expand Down

0 comments on commit 3a41b6f

Please sign in to comment.