Re: [whatwg/fetch] Return a `content-encoding` header for resource timing and more (PR #1796)

@annevk commented on this pull request.



> + <a for="header list">getting, decoding, and splitting</a> `<code>Content-Encoding</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>

So the idea here is that duplicate values are okay as long as they are fully identical? So `gzip` and `GZIP` is not okay?

> + <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.

Why would it only contain digits? Typical values for `Content-Encoding` are `gzip` or `deflate` as I understand it.

> @@ -5004,6 +5041,15 @@ steps:
 
      <li><p>Let <var>type</var> be <var>blob</var>'s {{Blob/type}}.
 
+     <li><p>Let <var>coding</var> be the empty string.
+
+     <li><p>Let <var>accept-coding</var> be the result of <a for="header list">getting</a>
+        `<code>Accept-Encoding</code>` from <var>request</var>'s <a for=request>header list</a>.
+        If <var>accept-encoding</var> is not null and the server selects one of the encoding options,
+        set <var>coding</var> to the selected encoding option; otherwise, i.e., no encoding is used,
+        set <var>coding</var> to <a href=https://httpwg.org/specs/rfc9110.html#field.accept-encoding>
+        <code>"identity"</code></a>.

The indentation here doesn't follow the style guide.

How would we know what the server selects here? This doesn't make much sense to me.

>       <li><p>Return a new <a for=/>response</a> whose <a for=response>status message</a> is
      `<code>OK</code>`, <a for=response>header list</a> is « (`<code>Content-Type</code>`,
-     <var>mimeType</var>) », and <a for=response>body</a> is <var>dataURLStruct</var>'s
-     <a for="data: URL struct">body</a> <a for="byte sequence">as a body</a>.
+     <var>mimeType</var>), (`<code>Content-Encoding</code>`, <var>coding</var>) », and
+     <a for=response>body</a> is <var>dataURLStruct</var>'s <a for="data: URL struct">
+     body</a> <a for="byte sequence">as a body</a>.

This also doesn't follow the formatting guidelines. Also, do we really want to return `Content-Encoding` for `data:` URLs? Why?

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

Message ID: <whatwg/fetch/pull/1796/review/2558964558@github.com>

Received on Friday, 17 January 2025 13:09:18 UTC