Skip to content

Commit 4525c22

Browse files
committed
Define Content-Length parser
As the body concept is refactored for #604, XMLHttpRequest will need to use this algorithm for its events. We also want to require browsers to use this algorithm instead of the one defined by HTTP as part of #1156. Tests: web-platform-tests/wpt#10548 & web-platform-tests/wpt#27837.
1 parent 24a8670 commit 4525c22

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

fetch.bs

+35-1
Original file line numberDiff line numberDiff line change
@@ -2807,10 +2807,44 @@ consideration for the security consequences. New exceptions can be proposed by
28072807
<a href=https://github.com/whatwg/fetch/issues/new>filing an issue</a>.
28082808

28092809

2810+
<h3 id=content-length-header>`<code>Content-Length</code>` header</h3>
2811+
2812+
<p>The `<code>Content-Length</code>` header is largely defined in HTTP. Its processing model is
2813+
defined here as the model defined in HTTP is not compatible with web content. [[HTTP]]
2814+
2815+
<p>To <dfn export for="header list" lt="extract a length|extracting a length">extract a length</dfn>
2816+
from a <a for=/>header list</a> <var>headers</var>, run these steps:
2817+
2818+
<ol>
2819+
<li><p>Let <var>values</var> be the result of
2820+
<a for="header list">getting, decoding, and splitting</a> `<code>Content-Length</code>` from
2821+
<var>headers</var>.
2822+
2823+
<li><p>If <var>values</var> is null, then return null.
2824+
2825+
<li><p>Let <var>candidateValue</var> be null.
2826+
2827+
<li>
2828+
<p><a for=list>For each</a> <var>value</var> of <var>values</var>:
2829+
2830+
<ol>
2831+
<li><p>If <var>candidateValue</var> is null, then set <var>candidateValue</var> to
2832+
<var>value</var>.
2833+
2834+
<li><p>Otherwise, if <var>value</var> is not <var>candidateValue</var>, then return failure.
2835+
</ol>
2836+
2837+
<li><p>If <var>candidateValue</var> is the empty string or has a <a for=/>code point</a> that is
2838+
not an <a for=/>ASCII digit</a>, then return null.
2839+
2840+
<li><p>Return <var>candidateValue</var>, interpreted as decimal number.
2841+
</ol>
2842+
2843+
28102844
<h3 id=content-type-header>`<code>Content-Type</code>` header</h3>
28112845

28122846
<p>The `<code>Content-Type</code>` header is largely defined in HTTP. Its processing model is
2813-
defined here as the ABNF defined in HTTP is not compatible with web content. [[HTTP]]
2847+
defined here as the model defined in HTTP is not compatible with web content. [[HTTP]]
28142848

28152849
<p>To
28162850
<dfn export for="header list" lt="extract a MIME type|extracting a MIME type" id=concept-header-extract-mime-type>extract a MIME type</dfn>

0 commit comments

Comments
 (0)