Skip to content

Commit

Permalink
Define Content-Length parser
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
annevk authored Mar 3, 2021
1 parent 24a8670 commit f2a7922
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2807,10 +2807,44 @@ consideration for the security consequences. New exceptions can be proposed by
<a href=https://github.com/whatwg/fetch/issues/new>filing an issue</a>.


<h3 id=content-length-header>`<code>Content-Length</code>` header</h3>

<p>The `<code>Content-Length</code>` header is largely defined in HTTP. Its processing model is
defined here as the model defined in HTTP is not compatible with web content. [[HTTP]]

<p>To <dfn export for="header list" lt="extract a length|extracting a length">extract a length</dfn>
from a <a for=/>header list</a> <var>headers</var>, run these steps:

<ol>
<li><p>Let <var>values</var> be the result of
<a for="header list">getting, decoding, and splitting</a> `<code>Content-Length</code>` from
<var>headers</var>.

<li><p>If <var>values</var> is null, then return null.

<li><p>Let <var>candidateValue</var> be null.

<li>
<p><a for=list>For each</a> <var>value</var> of <var>values</var>:

<ol>
<li><p>If <var>candidateValue</var> is null, then set <var>candidateValue</var> to
<var>value</var>.

<li><p>Otherwise, if <var>value</var> is not <var>candidateValue</var>, return failure.
</ol>

<li><p>If <var>candidateValue</var> is the empty string or has a <a for=/>code point</a> that is
not an <a for=/>ASCII digit</a>, then return null.

<li><p>Return <var>candidateValue</var>, interpreted as decimal number.
</ol>


<h3 id=content-type-header>`<code>Content-Type</code>` header</h3>

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

<p>To
<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>
Expand Down

0 comments on commit f2a7922

Please sign in to comment.