@@ -1465,32 +1465,19 @@ null), run these steps. <var>processBody</var> must be an algorithm accepting a
1465
1465
<li><p> If <var> taskDestination</var> is null, then set <var> taskDestination</var> to the result of
1466
1466
<a>starting a new parallel queue</a> .
1467
1467
1468
- <li><p> Let <var> promise</var> be the result of <a>fully reading body as promise</a> given
1469
- <var> body</var> .
1470
-
1471
- <li><p> Let <var> fulfilledSteps</var> given a <a>byte sequence</a> <var> bytes</var> be to
1468
+ <li><p> Let <var> successSteps</var> given a <a>byte sequence</a> <var> bytes</var> be to
1472
1469
<a>queue a fetch task</a> to run <var> processBody</var> given <var> bytes</var> , with
1473
1470
<var> taskDestination</var> .
1474
1471
1475
- <li><p> Let <var> rejectedSteps </var> be to <a>queue a fetch task</a> to run
1472
+ <li><p> Let <var> errorSteps </var> be to <a>queue a fetch task</a> to run
1476
1473
<var> processBodyError</var> , with <var> taskDestination</var> .
1477
1474
1478
- <li><p> <a for=promise>React</a> to <var> promise</var> with <var> fulfilledSteps</var> and
1479
- <var> rejectedSteps</var> .
1480
- </ol>
1481
- </div>
1482
-
1483
- <div algorithm>
1484
- <p> To <dfn export lt="fully reading body as promise">fully read body as promise</dfn> , given a
1485
- <a for=/>body</a> <var> body</var> , run these steps:
1486
-
1487
- <ol>
1488
1475
<li><p> Let <var> reader</var> be the result of <a for=ReadableStream>getting a reader</a> for
1489
- <var> body</var> 's <a for=body>stream</a> . If that threw an exception, then return
1490
- <a>a promise rejected with</a> that exception.
1476
+ <var> body</var> 's <a for=body>stream</a> . If that threw an exception, then run
1477
+ <var> errorSteps </var> with that exception and return .
1491
1478
1492
- <li><p> Return the result of <a for=ReadableStreamDefaultReader>reading all bytes</a> from
1493
- <var> reader</var> .
1479
+ <li><p> <a for=ReadableStreamDefaultReader>Read all bytes</a> from
1480
+ <var> reader</var> , given <var> successSteps </var> and <var> errorSteps </var> .
1494
1481
</ol>
1495
1482
</div>
1496
1483
@@ -6886,38 +6873,78 @@ returns failure or a <a for=/>MIME type</a>.
6886
6873
6887
6874
<hr>
6888
6875
6876
+ <div algorithm>
6889
6877
<p> The <dfn attribute for=Body><code>body</code></dfn> getter steps are to return null if
6890
6878
<a>this</a> 's <a for=Body>body</a> is null; otherwise <a>this</a>' s <a for=Body>body</a> 's
6891
6879
<a for=body>stream</a> .
6880
+ </div>
6892
6881
6882
+ <div algorithm>
6893
6883
<p> The <dfn attribute for=Body><code>bodyUsed</code></dfn> getter steps are to return true if
6894
6884
<a>this</a> 's <a for=Body>body</a> is non-null and <a>this</a>' s <a for=Body>body</a> 's
6895
6885
<a for=body>stream</a> is <a for=ReadableStream>disturbed</a> ; otherwise false.
6886
+ </div>
6896
6887
6897
- <p> The <dfn id=concept-body-package-data for=Body>package data</dfn> algorithm, given
6898
- <var> bytes</var> , <var> type</var> , and a <var> mimeType</var> , switches on <var> type</var> , and runs
6899
- the associated steps:
6888
+ <div algorithm>
6889
+ <p id=concept-body-package-data> The <dfn id=concept-body-consume-body for=Body>consume body</dfn>
6890
+ algorithm, given an object that includes {{Body}} <var> object</var> and an algorithm that takes a
6891
+ <a for=/>byte sequence</a> and returns a JavaScript value or throws an exception
6892
+ <var> convertBytesToJSValue</var> , runs these steps:
6900
6893
6901
- <dl class=switch>
6902
- <dt><i> ArrayBuffer</i>
6903
- <dd>
6904
- <p> Return a new {{ArrayBuffer}} whose contents are <var> bytes</var> .
6894
+ <ol>
6895
+ <li><p> If <var> object</var> is <a for=Body>unusable</a> , then return <a>a promise rejected with</a>
6896
+ a {{TypeError}} .
6905
6897
6906
- <p class=note> Allocating an {{ArrayBuffer}} can throw a {{RangeError}} .
6898
+ <li><p> Let <var> promise </var> be <a>a new promise</a> .
6907
6899
6908
- <dt><i> Blob</i>
6909
- <dd><p> Return a {{Blob}} whose contents are <var> bytes</var> and {{Blob/type}} attribute is
6910
- <var> mimeType</var> .
6900
+ <li> Let <var> errorSteps</var> given <var> error</var> be to <a>reject</a> <var> promise</var> with
6901
+ <var> error</var> .
6911
6902
6912
- <dt><i> FormData</i>
6913
- <dd>
6914
- <p> If <var> mimeType</var> 's <a for="MIME type">essence</a> is "<code> multipart/form-data</code> ",
6915
- then:
6903
+ <li> Let <var> successSteps</var> given a <a for=/>byte sequence</a> <var> data</var> be to
6904
+ <a for=/>resolve</a> <var> promise</var> with the result of running <var> convertBytesToJSValue</var>
6905
+ with <var> data</var> . If that threw an exception, then run <var> errorSteps</var> with that
6906
+ exception.
6907
+
6908
+ <li><p> If <var> object</var> 's <a for=Body>body</a> is null, then run <var> successSteps</var>
6909
+ with an empty <a for=/>byte sequence</a> .
6910
+
6911
+ <li><p> Otherwise, <a for=body>fully read</a> <var> object</var> 's <a for=Body>body</a> given
6912
+ <var> successSteps</var> , <var> errorSteps</var> , and <var> object</var> 's
6913
+ <a>relevant global object</a> .
6914
+
6915
+ <li><p> Return <var> promise</var> .
6916
+ </ol>
6917
+ </div>
6918
+
6919
+ <div algorithm>
6920
+ <p> The <dfn method for=Body><code>arrayBuffer()</code></dfn> method steps are to return the result
6921
+ of running <a for=Body>consume body</a> with <a>this</a> and the following step given a
6922
+ <a for=/>byte sequence</a> <var> bytes</var> : return a new {{ArrayBuffer}} whose contents are
6923
+ <var> bytes</var> .
6924
+
6925
+ <p class="note"> The above method can reject with a {{RangeError}} .
6926
+ </div>
6916
6927
6928
+ <div algorithm>
6929
+ <p> The <dfn method for=Body><code>blob()</code></dfn> method steps are to return the result
6930
+ of running <a for=Body>consume body</a> with <a>this</a> and the following step given a
6931
+ <a for=/>byte sequence</a> <var> bytes</var> : return a {{Blob}} whose contents are <var> bytes</var>
6932
+ and whose {{Blob/type}} attribute is <a>this</a> 's <a for=Body>MIME type</a> .
6933
+ </div>
6934
+
6935
+ <div algorithm>
6936
+ <p> The <dfn method for=Body><code>formData()</code></dfn> method steps are to return the result of
6937
+ running <a for=Body>consume body</a> with <a>this</a> and the following step given a
6938
+ <a for=/>byte sequence</a> <var> bytes</var> : switch on <a>this</a> 's <a for=Body>MIME type</a>' s
6939
+ <a for="MIME type">essence</a> and run the corresponding steps:
6940
+
6941
+ <dl class=switch>
6942
+ <dt> "<code> multipart/form-data</code> ",
6943
+ <dd>
6917
6944
<ol>
6918
6945
<li>
6919
6946
<p> Parse <var> bytes</var> , using the value of the `<code> boundary</code> ` parameter from
6920
- <var> mimeType </var > , per the rules set forth in
6947
+ <a>this</a> 's <a for=Body>MIME type</a > , per the rules set forth in
6921
6948
<cite> Returning Values from Forms: multipart/form-data</cite> . [[!RFC7578]] </p>
6922
6949
6923
6950
<p> Each part whose `<code> Content-Disposition</code> ` header contains a `<code> filename</code> `
@@ -6950,62 +6977,34 @@ the associated steps:
6950
6977
`<code> multipart/form-data</code> `, a more detailed parsing specification is to be
6951
6978
written. Volunteers welcome.
6952
6979
6953
- <p> Otherwise, if <var> mimeType</var> 's <a for="MIME type">essence</a> is
6954
- "<code> application/x-www-form-urlencoded</code> ", then:
6955
-
6980
+ <dt> "<code> application/x-www-form-urlencoded</code> ",
6981
+ <dd>
6956
6982
<ol>
6957
- <li><p> Let <var> entries</var> be the result of
6958
- <a lt="urlencoded parser">parsing</a> < var> bytes</var> .
6983
+ <li><p> Let <var> entries</var> be the result of <a lt="urlencoded parser">parsing</a>
6984
+ <var> bytes</var> .
6959
6985
6960
6986
<li><p> If <var> entries</var> is failure, then <a>throw</a> a {{TypeError}} .
6961
6987
6962
6988
<li><p> Return a new {{FormData}} object whose <a for=FormData>entry list</a> is
6963
6989
<var> entries</var> .
6964
6990
</ol>
6965
6991
6966
- <p> Otherwise, <a>throw</a> a {{TypeError}} .
6967
-
6968
- <dt><i> JSON</i>
6969
- <dd><p> Return the result of running <a>parse JSON from bytes</a> on <var> bytes</var> .
6970
-
6971
- <dt><i> text</i>
6972
- <dd><p> Return the result of running <a>UTF-8 decode</a> on
6973
- <var> bytes</var> .
6992
+ <dt> Otherwise
6993
+ <dd><p> <a>Throw</a> a {{TypeError}} .
6974
6994
</dl>
6995
+ </div>
6975
6996
6976
- <p> The <dfn id=concept-body-consume-body for=Body>consume body</dfn> algorithm, given an
6977
- <var> object</var> and <var> type</var> , runs these steps:
6978
-
6979
- <ol>
6980
- <li><p> If <var> object</var> is <a for=Body>unusable</a> , then return <a>a promise rejected with</a>
6981
- a {{TypeError}} .
6982
-
6983
- <li><p> Let <var> promise</var> be <a>a promise resolved with</a> an empty
6984
- <a for=/>byte sequence</a> .
6985
-
6986
- <li><p> If <var> object</var> 's <a for=Body>body</a> is non-null, then set <var> promise</var> to the
6987
- result of <a>fully reading body as promise</a> given <var> object</var> 's <a for=Body>body</a> .
6988
-
6989
- <li><p> Let <var> steps</var> be to return the result of <a>package data</a> with the first argument
6990
- given, <var> type</var> , and <var> object</var> 's <a for=Body>MIME type</a> .
6991
-
6992
- <li><p> Return the result of <a>upon fulfillment</a> of <var> promise</var> given <var> steps</var> .
6993
- </ol>
6994
-
6995
- <p> The <dfn method for=Body><code>arrayBuffer()</code></dfn> method steps are to return the result
6996
- of running <a for=Body>consume body</a> with <a>this</a> and <i> ArrayBuffer</i> .
6997
-
6998
- <p> The <dfn method for=Body><code>blob()</code></dfn> method steps are to return the result of
6999
- running <a for=Body>consume body</a> with <a>this</a> and <i> Blob</i> .
7000
-
7001
- <p> The <dfn method for=Body><code>formData()</code></dfn> method steps are to return the result of
7002
- running <a for=Body>consume body</a> with <a>this</a> and <i> FormData</i> .
6997
+ <div algorithm>
6998
+ <p> The <dfn method for=Body><code>json()</code></dfn> method steps are to return the result
6999
+ of running <a for=Body>consume body</a> with <a>this</a> and <a>parse JSON from bytes</a> .
7003
7000
7004
- <p> The <dfn method for=Body><code>json()</code></dfn> method steps are to return the result of
7005
- running <a for=Body>consume body</a> with <a>this</a> and <i> JSON </i> .
7001
+ <p class="note" > The above method can reject with a {{SyntaxError}} .
7002
+ </div>
7006
7003
7007
- <p> The <dfn method for=Body><code>text()</code></dfn> method steps are to return the result of
7008
- running <a for=Body>consume body</a> with <a>this</a> and <i> text</i> .
7004
+ <div algorithm>
7005
+ <p> The <dfn method for=Body><code>text()</code></dfn> method steps are to return the result
7006
+ of running <a for=Body>consume body</a> with <a>this</a> and <a>UTF-8 decode</a> .
7007
+ </div>
7009
7008
7010
7009
7011
7010
<h3 id=request-class>Request class</h3>
0 commit comments