Skip to content

Commit 813788a

Browse files
authored
Ensure scheme fetch always returns a response with an actual body
Helps with #1504.
1 parent e5f025a commit 813788a

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

fetch.bs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4569,7 +4569,8 @@ steps:
45694569
"<code>blank</code>", then return a new <a for=/>response</a> whose
45704570
<a for=response>status message</a> is `<code>OK</code>`, <a for=response>header list</a> is «
45714571
(`<code>Content-Type</code>`, `<code>text/html;charset=utf-8</code>`) », and
4572-
<a for=response>body</a> is the empty byte sequence.
4572+
<a for=response>body</a> is the <a for="body with type">body</a> of the result of
4573+
<a for=BodyInit>safely extracting</a> the empty byte sequence.
45734574

45744575
<p>Otherwise, return a <a>network error</a>.
45754576

@@ -4597,22 +4598,21 @@ steps:
45974598
<p class=note>The `<code>GET</code>` <a for=/>method</a> restriction serves no useful purpose
45984599
other than being interoperable.
45994600

4600-
<li><p>Let <var>response</var> be a new <a for=/>response</a> whose
4601-
<a for=response>status message</a> is `<code>OK</code>`.
4601+
<li><p>Let <var>bodyWithType</var> be the result of <a for=BodyInit>safely extracting</a>
4602+
<var>blobURLEntry</var>'s <a for="blob URL entry">object</a>.
46024603

4603-
<li><p><a for="header list">Append</a> (`<code>Content-Length</code>`, <var>blob</var>'s
4604-
{{Blob/size}} attribute value) to <var>response</var>'s <a for=response>header list</a>.
4604+
<li><p>Let <var>body</var> be <var>bodyWithType</var>'s <a for="body with type">body</a>.
46054605

4606-
<li><p><a for="header list">Append</a> (`<code>Content-Type</code>`, <var>blob</var>'s
4607-
{{Blob/type}} attribute value) to <var>response</var>'s <a for=response>header list</a>.
4606+
<li><p>Let <var>length</var> be <var>body</var>'s <a for=body>length</a>,
4607+
<a lt="serialize an integer">serialized</a> and <a>isomorphic encoded</a>.
46084608

4609-
<li><p>Set <var>response</var>'s <a for=response>body</a> to
4610-
the result of performing the <a spec=fileapi>read operation</a> on
4611-
<var>blob</var>.
4609+
<li><p>Let <var>type</var> be <var>bodyWithType</var>'s <a for="body with type">type</a> if it
4610+
is non-null; otherwise the empty byte sequence.
46124611

4613-
<!-- This takes care of setting length, transmitted, and error flag as well -->
4614-
4615-
<li><p>Return <var>response</var>.
4612+
<li><p>Return a new <a for=/>response</a> whose <a for=response>status message</a> is
4613+
`<code>OK</code>`, <a for=response>header list</a> is « (`<code>Content-Length</code>`,
4614+
<var>length</var>), (`<code>Content-Type</code>`, <var>type</var>) », and
4615+
<a for=response>body</a> is <var>body</var>.
46164616
</ol>
46174617

46184618
<li><p><a>If aborted</a>, then return the <a for=/>appropriate network error</a> for
@@ -4630,9 +4630,10 @@ steps:
46304630
<li><p>Let <var>mimeType</var> be <var>dataURLStruct</var>'s
46314631
<a for="data: URL struct">MIME type</a>, <a lt="serialize a MIME type to bytes">serialized</a>.
46324632

4633-
<li><p>Return a <a for=/>response</a> whose <a for=response>status message</a> is
4633+
<li><p>Return a new <a for=/>response</a> whose <a for=response>status message</a> is
46344634
`<code>OK</code>`, <a for=response>header list</a> is « (`<code>Content-Type</code>`,
4635-
<var>mimeType</var>) », and <a for=response>body</a> is <var>dataURLStruct</var>'s
4635+
<var>mimeType</var>) », and <a for=response>body</a> is the <a for="body with type">body</a> of
4636+
the result of <a for=BodyInit>safely extracting</a> <var>dataURLStruct</var>'s
46364637
<a for="data: URL struct">body</a>.
46374638
</ol>
46384639

0 commit comments

Comments
 (0)