@@ -3747,7 +3747,8 @@ defined here as the model defined in HTTP is not compatible with web content. [[
37473747<div algorithm>
37483748<p> To
37493749<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>
3750- from a <a for=/>header list</a> <var> headers</var> , run these steps:
3750+ from a <a for=/>header list</a> <var> headers</var> , run these steps. They return failure or a
3751+ <a for=/>MIME type</a> .
37513752
37523753<ol>
37533754 <li><p> Let <var> charset</var> be null.
@@ -4773,7 +4774,7 @@ steps:
47734774 <a for="header list">extracting a MIME type</a> from <var> response</var> 's
47744775 <a for=response>header list</a> .
47754776
4776- <li><p> If <var> mimeType</var> is non-null , then set <var> bodyInfo</var> 's
4777+ <li><p> If <var> mimeType</var> is not failure , then set <var> bodyInfo</var> 's
47774778 <a for="response body info">content type</a> to the result of
47784779 <a>minimizing a supported MIME type</a> given <var> mimeType</var> .
47794780 </ol>
@@ -7138,10 +7139,6 @@ HTML, will likely not be exposed here. Rather, an HTML parser API might accept a
71387139due course.
71397140<!-- https://lists.w3.org/Archives/Public/public-whatwg-archive/2014Jun/thread.html#msg72 -->
71407141
7141- <p> Objects including the {{Body}} interface mixin need to define an associated
7142- <dfn id=concept-body-mime-type for=Body>MIME type</dfn> algorithm which takes no arguments and
7143- returns failure or a <a for=/>MIME type</a> .
7144-
71457142<p> Objects including the {{Body}} interface mixin have an associated
71467143<dfn id=concept-body-body for=Body>body</dfn> (null or a <a for=/>body</a> ).
71477144
@@ -7177,6 +7174,28 @@ returns failure or a <a for=/>MIME type</a>.
71777174
71787175<hr>
71797176
7177+ <div algorithm>
7178+ <p> To <dfn id=concept-body-mime-type for=Body>get the MIME type</dfn> , given a {{Request}} or
7179+ {{Response}} object <var> requestOrResponse</var> :
7180+
7181+ <ol>
7182+ <li><p> Let <var> headers</var> be null.
7183+
7184+ <li><p> If <var> requestOrResponse</var> is a {{Request}} object, then set <var> headers</var> to
7185+ <var> requestOrResponse</var> 's <a for=Request>request</a>' s <a for=request>header list</a> .
7186+
7187+ <li><p> Otherwise, set <var> headers</var> to <var> requestOrResponse</var> 's
7188+ <a for=Response>response</a> 's <a for=response>header list</a> .
7189+
7190+ <li><p> Let <var> mimeType</var> be the result of <a for="header list">extracting a MIME type</a>
7191+ from <var> headers</var> .
7192+
7193+ <li><p> If <var> mimeType</var> is failure, then return null.
7194+
7195+ <li><p> Return <var> mimeType</var> .
7196+ </ol>
7197+ </div>
7198+
71807199<div algorithm>
71817200<p> The <dfn attribute for=Body><code>body</code></dfn> getter steps are to return null if
71827201<a>this</a> 's <a for=Body>body</a> is null; otherwise <a>this</a>' s <a for=Body>body</a> 's
@@ -7233,69 +7252,76 @@ of running <a for=Body>consume body</a> with <a>this</a> and the following step
72337252<p> The <dfn method for=Body><code>blob()</code></dfn> method steps are to return the result
72347253of running <a for=Body>consume body</a> with <a>this</a> and the following step given a
72357254<a for=/>byte sequence</a> <var> bytes</var> : return a {{Blob}} whose contents are <var> bytes</var>
7236- and whose {{Blob/type}} attribute is <a>this</a> 's <a for=Body>MIME type</a> .
7255+ and whose {{Blob/type}} attribute is the result of <a for=Body>get the MIME type</a> with
7256+ <a>this</a> .
7257+ <!-- This is wrong. It should really set an underlying concept to this. -->
72377258</div>
72387259
72397260<div algorithm>
72407261<p> The <dfn method for=Body><code>formData()</code></dfn> method steps are to return the result of
72417262running <a for=Body>consume body</a> with <a>this</a> and the following step given a
7242- <a for=/>byte sequence</a> <var> bytes</var> : switch on <a>this</a> 's <a for=Body>MIME type</a>' s
7243- <a for="MIME type">essence</a> and run the corresponding steps:
7263+ <a for=/>byte sequence</a> <var> bytes</var> :
72447264
7245- <dl class=switch>
7246- <dt> "<code> multipart/form-data</code> ",
7247- <dd>
7248- <ol>
7249- <li>
7250- <p> Parse <var> bytes</var> , using the value of the `<code> boundary</code> ` parameter from
7251- <a>this</a> 's <a for=Body>MIME type</a> , per the rules set forth in
7252- <cite> Returning Values from Forms: multipart/form-data</cite> . [[!RFC7578]] </p>
7253-
7254- <p> Each part whose `<code> Content-Disposition</code> ` header contains a `<code> filename</code> `
7255- parameter must be parsed into an <a for="entry list">entry</a> whose value is a {{File}} object
7256- whose contents are the contents of the part. The {{File/name}} attribute of the {{File}} object
7257- must have the value of the `<code> filename</code> ` parameter of the part. The {{Blob/type}}
7258- attribute of the {{File}} object must have the value of the `<code> Content-Type</code> ` header
7259- of the part if the part has such header, and `<code> text/plain</code> ` (the default defined by
7260- [[!RFC7578]] section 4.4) otherwise.</p>
7261-
7262- <p> Each part whose `<code> Content-Disposition</code> ` header does not contain a
7263- `<code> filename</code> ` parameter must be parsed into an <a for="entry list">entry</a> whose
7264- value is the <a lt="UTF-8 decode without BOM">UTF-8 decoded without BOM</a> content of the part.
7265- <span class=note> This is done regardless of the presence or the value of a
7266- `<code> Content-Type</code> ` header and regardless of the presence or the value of a
7267- `<code> charset</code> ` parameter.</span></p>
7268-
7269- <p class=note> A part whose `<code> Content-Disposition</code> ` header contains a
7270- `<code> name</code> ` parameter whose value is `<code> _charset_</code> ` is parsed like any other
7271- part. It does not change the encoding.</p>
7272- </li>
7273-
7274- <li><p> If that fails for some reason, then <a>throw</a> a {{TypeError}} .
7275-
7276- <li><p> Return a new {{FormData}} object, appending each <a for="entry list">entry</a> , resulting
7277- from the parsing operation, to its <a for=FormData>entry list</a> .
7278- </ol>
7265+ <ol>
7266+ <li><p> Let <var> mimeType</var> be the result of <a for=Body>get the MIME type</a> with <a>this</a> .
72797267
7280- <p class=XXX> The above is a rough approximation of what is needed for
7281- ` <code> multipart/form-data </code> `, a more detailed parsing specification is to be
7282- written. Volunteers welcome.
7268+ <li>
7269+ <p> If <var> mimeType </var> is non-null, then switch on <var> mimeType </var> 's
7270+ <a for="MIME type">essence</a> and run the corresponding steps:
72837271
7284- <dt> "<code> application/x-www-form-urlencoded</code> ",
7285- <dd>
7286- <ol>
7287- <li><p> Let <var> entries</var> be the result of <a lt="urlencoded parser">parsing</a>
7288- <var> bytes</var> .
7272+ <dl class=switch>
7273+ <dt> "<code> multipart/form-data</code> "
7274+ <dd>
7275+ <ol>
7276+ <li>
7277+ <p> Parse <var> bytes</var> , using the value of the `<code> boundary</code> ` parameter from
7278+ <var> mimeType</var> , per the rules set forth in
7279+ <cite> Returning Values from Forms: multipart/form-data</cite> . [[!RFC7578]]
7280+
7281+ <p> Each part whose `<code> Content-Disposition</code> ` header contains a
7282+ `<code> filename</code> ` parameter must be parsed into an <a for="entry list">entry</a> whose
7283+ value is a {{File}} object whose contents are the contents of the part. The {{File/name}}
7284+ attribute of the {{File}} object must have the value of the `<code> filename</code> ` parameter
7285+ of the part. The {{Blob/type}} attribute of the {{File}} object must have the value of the
7286+ `<code> Content-Type</code> ` header of the part if the part has such header, and
7287+ `<code> text/plain</code> ` (the default defined by [[!RFC7578]] section 4.4) otherwise.
7288+
7289+ <p> Each part whose `<code> Content-Disposition</code> ` header does not contain a
7290+ `<code> filename</code> ` parameter must be parsed into an <a for="entry list">entry</a> whose
7291+ value is the <a lt="UTF-8 decode without BOM">UTF-8 decoded without BOM</a> content of the
7292+ part. <span class=note> This is done regardless of the presence or the value of a
7293+ `<code> Content-Type</code> ` header and regardless of the presence or the value of a
7294+ `<code> charset</code> ` parameter.</span>
7295+
7296+ <p class=note> A part whose `<code> Content-Disposition</code> ` header contains a
7297+ `<code> name</code> ` parameter whose value is `<code> _charset_</code> ` is parsed like any other
7298+ part. It does not change the encoding.
7299+
7300+ <li><p> If that fails for some reason, then <a>throw</a> a {{TypeError}} .
7301+
7302+ <li><p> Return a new {{FormData}} object, appending each <a for="entry list">entry</a> ,
7303+ resulting from the parsing operation, to its <a for=FormData>entry list</a> .
7304+ </ol>
72897305
7290- <li><p> If <var> entries</var> is failure, then <a>throw</a> a {{TypeError}} .
7306+ <p class=XXX> The above is a rough approximation of what is needed for
7307+ `<code> multipart/form-data</code> `, a more detailed parsing specification is to be written.
7308+ Volunteers welcome.
72917309
7292- <li><p> Return a new {{FormData}} object whose <a for=FormData>entry list</a> is
7293- <var> entries</var> .
7294- </ol>
7310+ <dt> "<code> application/x-www-form-urlencoded</code> "
7311+ <dd>
7312+ <ol>
7313+ <li><p> Let <var> entries</var> be the result of <a lt="urlencoded parser">parsing</a>
7314+ <var> bytes</var> .
72957315
7296- <dt> Otherwise
7297- <dd><p> <a>Throw</a> a {{TypeError}} .
7298- </dl>
7316+ <li><p> If <var> entries</var> is failure, then <a>throw</a> a {{TypeError}} .
7317+
7318+ <li><p> Return a new {{FormData}} object whose <a for=FormData>entry list</a> is
7319+ <var> entries</var> .
7320+ </ol>
7321+ </dl>
7322+
7323+ <li><p> <a>Throw</a> a {{TypeError}} .
7324+ </ol>
72997325</div>
73007326
73017327<div algorithm>
@@ -7387,10 +7413,6 @@ omitted from <a enum><code>RequestMode</code></a> as it cannot be used nor obser
73877413<p> A {{Request}} object has an associated <dfn for=Request>signal</dfn> (null or an {{AbortSignal}}
73887414object), initially null.
73897415
7390- <p> A {{Request}} object's <a for=Body>MIME type</a> is to return the result of
7391- <a for="header list">extracting a MIME type</a> from its <a for=Request>request</a> 's
7392- <a for=request>header list</a> .
7393-
73947416<p> A {{Request}} object's <a for=Body>body</a> is its
73957417<a for=Request>request</a> 's
73967418<a for=request>body</a> .
@@ -8078,10 +8100,6 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredire
80788100<p> A {{Response}} object also has an associated <dfn for=Response export>headers</dfn> (null or a
80798101{{Headers}} object), initially null.
80808102
8081- <p> A {{Response}} object's <a for=Body>MIME type</a> is to return the result of
8082- <a for="header list">extracting a MIME type</a> from its <a for=Response>response</a> 's
8083- <a for=response>header list</a> .
8084-
80858103<p> A {{Response}} object's <a for=Body>body</a> is its
80868104<a for=Response>response</a> 's <a for=response>body</a> .
80878105
@@ -8978,6 +8996,7 @@ Brad Porter,
89788996Bryan Smith,
89798997Caitlin Potter,
89808998Cameron McCormack,
8999+ 白丞祐 (Cheng-You Bai)<!-- CYBAI; GitHub -->,
89819000Chirag S Kumar<!-- fictionistique; GitHub -->,
89829001Chris Needham,
89839002Chris Rebert,
0 commit comments