Re: [whatwg/xhr] Define Content-Type manipulation in terms of MIME Sniffing (#176)

domenic requested changes on this pull request.



> @@ -775,17 +775,31 @@ method must run these steps:
   <a for="header list">append</a> `<code>Content-Type</code>`/<var>mimeType</var> to
   <a>author request headers</a>.
 
-  <p>Otherwise, if the <a>header</a> whose <a for=header>name</a> is a <a>byte-case-insensitive</a>
-  match for `<code>Content-Type</code>` in <a>author request headers</a> has a
-  <a for=header>value</a> that is a <a>valid MIME type</a>, which has a `<code>charset</code>`
-  parameter whose value is not a <a>byte-case-insensitive</a> match for <var>encoding</var>, and
-  <var>encoding</var> is not null, then set all the `<code>charset</code>` parameters whose value is
-  not a <a>byte-case-insensitive</a> match for <var>encoding</var> of that <a>header</a>'s
-  <a for=header>value</a> to <var>encoding</var>.
-  <!-- XXX could still be better with parameter cross-ref -->
-
-  <!-- reminder: if we ever change this to always include charset it has
-  to be included as the first parameter for compatibility reasons -->
+  <p>Otherwise, if <var>encoding</var> is non-null, run these steps:

What if mimeType is null but author request headers does not contain a Content-Type header?

> -  match for `<code>Content-Type</code>` in <a>author request headers</a> has a
-  <a for=header>value</a> that is a <a>valid MIME type</a>, which has a `<code>charset</code>`
-  parameter whose value is not a <a>byte-case-insensitive</a> match for <var>encoding</var>, and
-  <var>encoding</var> is not null, then set all the `<code>charset</code>` parameters whose value is
-  not a <a>byte-case-insensitive</a> match for <var>encoding</var> of that <a>header</a>'s
-  <a for=header>value</a> to <var>encoding</var>.
-  <!-- XXX could still be better with parameter cross-ref -->
-
-  <!-- reminder: if we ever change this to always include charset it has
-  to be included as the first parameter for compatibility reasons -->
+  <p>Otherwise, if <var>encoding</var> is non-null, run these steps:
+
+  <ol>
+   <li><p>Let <var>value</var> be the <a for=header>value</a> of the <a>header</a> whose
+   <a for=header>name</a> is a <a>byte-case-insensitive</a> match for `<code>Content-Type</code>` in
+   <a>author request headers</a>.

I'm surprised header list doesn't have a "get" operation that does the byte-case-insensitive part for you. It has so many of the other operations you'd expect.

> -  <var>encoding</var> is not null, then set all the `<code>charset</code>` parameters whose value is
-  not a <a>byte-case-insensitive</a> match for <var>encoding</var> of that <a>header</a>'s
-  <a for=header>value</a> to <var>encoding</var>.
-  <!-- XXX could still be better with parameter cross-ref -->
-
-  <!-- reminder: if we ever change this to always include charset it has
-  to be included as the first parameter for compatibility reasons -->
+  <p>Otherwise, if <var>encoding</var> is non-null, run these steps:
+
+  <ol>
+   <li><p>Let <var>value</var> be the <a for=header>value</a> of the <a>header</a> whose
+   <a for=header>name</a> is a <a>byte-case-insensitive</a> match for `<code>Content-Type</code>` in
+   <a>author request headers</a>.
+
+   <li><p>Let <var>mimeTypeRecord</var> be <var>value</var>,
+   <a for="parse a MIME type from bytes">parsed</a>.

This (and serialized) isn't linking in the previous but probably that's because this is an old PR. Worth confirming before merging.

> -
-  <!-- reminder: if we ever change this to always include charset it has
-  to be included as the first parameter for compatibility reasons -->
+  <p>Otherwise, if <var>encoding</var> is non-null, run these steps:
+
+  <ol>
+   <li><p>Let <var>value</var> be the <a for=header>value</a> of the <a>header</a> whose
+   <a for=header>name</a> is a <a>byte-case-insensitive</a> match for `<code>Content-Type</code>` in
+   <a>author request headers</a>.
+
+   <li><p>Let <var>mimeTypeRecord</var> be <var>value</var>,
+   <a for="parse a MIME type from bytes">parsed</a>.
+
+   <li>
+    <p>If <var>mimeTypeRecord</var> is not failure and
+    <var>mimeTypeRecord</var>["<code>charset</code>"] is not nothing, then:

This should be referencing the record's parameters, right?

And using "exists" for ordered maps, not "is not nothing"

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/xhr/pull/176#pullrequestreview-93997355

Received on Monday, 5 February 2018 14:08:35 UTC