Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return a content-encoding header for resource timing and more #1796

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 61 additions & 4 deletions fetch.bs
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,8 @@ following <a for=struct>items</a>: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
<dd>A number.
<dt><dfn export for="response body info">content type</dfn> (default the empty string)
<dd>An <a for=/>ASCII string</a>.
<dt><dfn export for="response body info">content encoding</dfn> (default the empty string)
<dd>An <a for=/>ASCII string</a>.
</dl>

<div algorithm>
Expand Down Expand Up @@ -1176,6 +1178,7 @@ is a <a>byte-case-insensitive</a> match for one of
<li>`<a http-header><code>Access-Control-Request-Headers</code></a>`
<li>`<a http-header><code>Access-Control-Request-Method</code></a>`
<li>`<code>Connection</code>`
<li>`<code>Content-Encoding</code>`
<li>`<code>Content-Length</code>`
<li>`<code>Cookie</code>`
<li>`<code>Cookie2</code>`
Expand Down Expand Up @@ -3946,6 +3949,40 @@ Content-Type:
</div>
</div>

<h3 id=content-encoding>`<code>Content-Encoding</code>` header</h3>

<p>The `<code>Content-Encoding</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]]

<div algorithm>
<p>To <dfn export for="header list" lt="extract an encoding type|extracting an encoding type">
extract an encoding type</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-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>

<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 a string.
</ol>
</div>

<h3 id=x-content-type-options-header>`<code>X-Content-Type-Options</code>` header</h3>

Expand Down Expand Up @@ -5004,6 +5041,13 @@ steps:

<li><p>Let <var>type</var> be <var>blob</var>'s {{Blob/type}}.

<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,
let <var>coding</var> be the selected encoding option; otherwise, i.e., no encoding is used,
let <var>coding</var> be <a href=https://httpwg.org/specs/rfc9110.html#field.accept-encoding>
<code>"identity"</code></a>.

<li>
<p>If <var>request</var>'s <a for=request>header list</a>
<a for="header list">does not contain</a> `<code>Range</code>`:
Expand All @@ -5019,7 +5063,9 @@ steps:

<li><p>Set <var>response</var>'s <a for=response>header list</a> to «
(`<code>Content-Length</code>`, <var>serializedFullLength</var>),
(`<code>Content-Type</code>`, <var>type</var>) ».
(`<code>Content-Type</code>`, <var>type</var>),
(`<code>Content-Encoding</code>`, <var>coding</var>) ».

</ol>

<li>
Expand Down Expand Up @@ -5088,7 +5134,8 @@ steps:
<li><p>Set <var>response</var>'s <a for=response>header list</a> to «
(`<code>Content-Length</code>`, <var>serializedSlicedLength</var>),
(`<code>Content-Type</code>`, <var>type</var>), (`<code>Content-Range</code>`,
<var>contentRange</var>) ».
<var>contentRange</var>), (`<code>Content-Encoding</code>`, <var>coding</var>) ».

</ol>

<li><p>Return <var>response</var>.
Expand All @@ -5105,10 +5152,19 @@ steps:
<li><p>Let <var>mimeType</var> be <var>dataURLStruct</var>'s
<a for="data: URL struct">MIME type</a>, <a lt="serialize a MIME type to bytes">serialized</a>.

<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,
let <var>coding</var> be the selected encoding option; otherwise, i.e., no encoding is used,
let <var>coding</var> be <a href=https://httpwg.org/specs/rfc9110.html#field.accept-encoding>
<code>"identity"</code></a>.

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

</ol>

<dt>"<code>file</code>"
Expand Down Expand Up @@ -9127,6 +9183,7 @@ Gavin Carothers,
Glenn Maynard,
Graham Klyne,
Gregory Terzian,
Guohui Deng(邓国辉)<!-- guohuideng2024; GitHub -->,
Hal Lockhart,
Hallvord R. M. Steen,
Harris Hancock,
Expand Down