Skip to content

Commit 2e24866

Browse files
committed
Extract 'total request length' to a function
1 parent 417dd32 commit 2e24866

File tree

1 file changed

+36
-27
lines changed

1 file changed

+36
-27
lines changed

fetch.bs

Lines changed: 36 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6774,30 +6774,7 @@ i.e., when a <a>fetch group</a> is <a for="fetch group">terminated</a>, or after
67746774
<li><p>If <var>request</var>'s <a for=request>URL</a> is not a
67756775
<a>potentially trustworthy url</a>, then throw a "{{SecurityError}}" {{DOMException}}.
67766776

6777-
<li><p>Let <var>totalRequestLength</var> be the [=string/length=] of <var>request</var>'s
6778-
<a for=request>URL</a>, <a lt="URL serializer">serialized</a> with
6779-
[=URL serializer/exclude fragment=] set to true.
6780-
6781-
<li><p><a for=list>For each</a> (<var>name</var>, <var>value</var>) in
6782-
<a for=request>header list</a>, increment <var>totalRequestLength</var> by <var>name</var>'s
6783-
[=byte sequence/length=] + <var>value</var>'s [=byte sequence/length=].
6784-
6785-
<li>
6786-
<p>If <var>request</var>'s <a for=request>body</a> is non-null then:
6787-
6788-
<ol>
6789-
<li><p>If <var>request</var>'s
6790-
<a for=request>body</a>'s <a for=body>length</a> is null, then throw a {{TypeError}}.
6791-
6792-
<li>
6793-
<p>If <var>request</var>'s <a for=request>body</a>'s <a for=body>source</a> is null, then throw a
6794-
{{TypeError}}.
6795-
6796-
<p class=note>This disallows sending deferred fetches with a live {{ReadableStream}}.
6797-
6798-
<li><p>Increment <var>totalRequestLength</var> by <var>request</var>'s
6799-
<a for=request>body</a>'s <a for=body>length</a>.
6800-
</ol>
6777+
<li><p>Let <var>totalRequestLength</var> be <var>request</var>'s <a>total request length</a>
68016778

68026779
<li><p>If the <a>available deferred fetching quota</a> given <var>request</var>'s
68036780
<a for=request>client</a> and <var>request</var>'s <a for=request>URL</a>'s <a for=url>origin</a>
@@ -6836,6 +6813,39 @@ i.e., when a <a>fetch group</a> is <a for="fetch group">terminated</a>, or after
68366813
</ol>
68376814
</div>
68386815

6816+
<div algorithm>
6817+
<p>To compute the <dfn>total request length</dfn> of a <a for=/>request</a> <var>request</var>:
6818+
6819+
<ol>
6820+
<li><p>Let <var>totalRequestLength</var> be the [=string/length=] of <var>request</var>'s
6821+
<a for=request>URL</a>, <a lt="URL serializer">serialized</a> with
6822+
[=URL serializer/exclude fragment=] set to true.
6823+
6824+
<li><p><a for=list>For each</a> (<var>name</var>, <var>value</var>) in
6825+
<a for=request>header list</a>, increment <var>totalRequestLength</var> by <var>name</var>'s
6826+
[=byte sequence/length=] + <var>value</var>'s [=byte sequence/length=].
6827+
6828+
<li>
6829+
<p>If <var>request</var>'s <a for=request>body</a> is non-null then:
6830+
6831+
<ol>
6832+
<li><p>If <var>request</var>'s
6833+
<a for=request>body</a>'s <a for=body>length</a> is null, then throw a {{TypeError}}.
6834+
6835+
<li>
6836+
<p>If <var>request</var>'s <a for=request>body</a>'s <a for=body>source</a> is null, then throw a
6837+
{{TypeError}}.
6838+
6839+
<p class=note>This disallows sending deferred fetches with a live {{ReadableStream}}.
6840+
6841+
<li><p>Increment <var>totalRequestLength</var> by <var>request</var>'s
6842+
<a for=request>body</a>'s <a for=body>length</a>.
6843+
</ol>
6844+
6845+
<li><ol>Return <var>totalRequestLength</var>.
6846+
</ol>
6847+
</div>
6848+
68396849
<div algorithm>
68406850
<p>To <dfn export>process deferred fetches</dfn> given a <a>fetch group</a> <var>fetchGroup</var>:
68416851

@@ -6939,9 +6949,8 @@ This specification defined a <a>policy-controlled feature</a> identified by the
69396949
<a for="fetch group">deferred fetch records</a>:</p>
69406950

69416951
<ol>
6942-
<li><p>Let <var>length</var> be <var>deferredRecord</var>'s
6943-
<a for="deferred fetch record">request</a>'s <a for=request>body</a>'s
6944-
<a for=body>length</a>.
6952+
<li><p>Let <var>length</var> be the <a>total request length</a> of <var>deferredRecord</var>'s
6953+
<a for="deferred fetch record">request</a>.
69456954

69466955
<li><p>Decrement <var>remainingTotalQuota</var> by <var>length</var>.
69476956

0 commit comments

Comments
 (0)