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

chore(http): Refresh headers ~[s->x] #36862

Open
wants to merge 19 commits into
base: main
Choose a base branch
from
Open

Conversation

bsmth
Copy link
Member

@bsmth bsmth commented Nov 19, 2024

Description

This PR refreshes a few HTTP headers pages.

common changes:

  • Add missing properties tables
  • Capitalize Yes/No in properties table & move verbose notes/caveats under table
  • Normalize The HTTP **`Header-Name`** (request|response) header in first sentence
  • Add status text to HTTPStatus macros, e.g. {{HTTPStatus("406", "406 Not Acceptable")}}
  • Improve Syntax section where possible
  • Remove improper use of quotes in and around code
  • Avoid escaping angle brackets in directive names in favor of backticks:
- \<directive>
+ `<directive>`

Motivation

Keeping content up-to-date, fixing formatting, unifying writing conventions

@github-actions github-actions bot added Content:HTTP HTTP docs Content:Glossary Glossary entries size/l [PR only] 501-1000 LoC changed labels Nov 19, 2024
Copy link
Contributor

github-actions bot commented Nov 19, 2024

Preview URLs (41 pages)
External URLs (40)

URL: /en-US/docs/Glossary/Source_map
Title: Source map


URL: /en-US/docs/Web/HTTP/Headers/Viewport-Width
Title: Viewport-Width


URL: /en-US/docs/Web/HTTP/Headers/WWW-Authenticate
Title: WWW-Authenticate


URL: /en-US/docs/Web/HTTP/Headers/X-Forwarded-For
Title: X-Forwarded-For


URL: /en-US/docs/Web/HTTP/Headers/Proxy-Authenticate
Title: Proxy-Authenticate


URL: /en-US/docs/Web/HTTP/Headers/Set-Login
Title: Set-Login


URL: /en-US/docs/Web/HTTP/Headers/Origin-Agent-Cluster
Title: Origin-Agent-Cluster


URL: /en-US/docs/Web/HTTP/Headers/X-XSS-Protection
Title: X-XSS-Protection


URL: /en-US/docs/Web/HTTP/Headers/Want-Repr-Digest
Title: Want-Repr-Digest


URL: /en-US/docs/Web/HTTP/Headers/Proxy-Authorization
Title: Proxy-Authorization


URL: /en-US/docs/Web/HTTP/Headers/SourceMap
Title: SourceMap


URL: /en-US/docs/Web/HTTP/Headers/Vary
Title: Vary


URL: /en-US/docs/Web/HTTP/Headers/TE
Title: TE


URL: /en-US/docs/Web/HTTP/Headers/X-Content-Type-Options
Title: X-Content-Type-Options


URL: /en-US/docs/Web/HTTP/Headers/Width
Title: Width


URL: /en-US/docs/Web/HTTP/Headers/Want-Content-Digest
Title: Want-Content-Digest


URL: /en-US/docs/Web/HTTP/Headers/Set-Cookie
Title: Set-Cookie


URL: /en-US/docs/Web/HTTP/Headers/Tk
Title: Tk


URL: /en-US/docs/Web/HTTP/Headers/Strict-Transport-Security
Title: Strict-Transport-Security

(comment last updated: 2024-12-01 22:52:16)

Copy link
Contributor

This pull request has merge conflicts that must be resolved before it can be merged.

@github-actions github-actions bot removed the merge conflicts 🚧 [PR only] label Nov 25, 2024
@github-actions github-actions bot added size/xl [PR only] >1000 LoC changed and removed size/l [PR only] 501-1000 LoC changed labels Nov 27, 2024
The **`SourceMap`** [HTTP](/en-US/docs/Web/HTTP) response header links generated code to a [source map](https://firefox-source-docs.mozilla.org/devtools-user/debugger/how_to/use_a_source_map/index.html), enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.
The HTTP **`SourceMap`** {{Glossary("response header")}} links generated code to a {{Glossary("source map")}}, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.

The HTTP `SourceMap` header has precedence over a source annotation (`sourceMappingURL=path-to-map.js.map`), and if both are present, the header URL is used to resolve the source map file.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link to sourceMappingURL?

```

Developer tools use the mappings between optimized code and the original source to improve readability, which can make debugging easier.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Developer tools use the mappings between optimized code and the original source to improve readability, which can make debugging easier.
Developer tools use the source map to reconstruct the original source from the optimized JavaScript returned in the response, allowing developers to debug the original code rather than the format that has been optimized for sending.

the user agent is willing to accept. (you could informally call it
`Accept-Transfer-Encoding`, which would be more intuitive).
The HTTP **`TE`** {{Glossary("request header")}} specifies the transfer encodings the user agent is willing to accept.
Some people informally consider "`Accept-Transfer-Encoding`" to be a more intuitive name for this header.
Copy link
Collaborator

@hamishwillee hamishwillee Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sure they do, as do I. But it's odd to talk about a more intuitive name that doesn't exist.

Suggested change
Some people informally consider "`Accept-Transfer-Encoding`" to be a more intuitive name for this header.

> [HTTP/2](https://httpwg.org/specs/rfc9113.html#ConnectionSpecific) and
> [HTTP/3](https://httpwg.org/specs/rfc9114.html#header-formatting), the `TE`
> header field is only accepted if the `trailers` value is set.
Note that `chunked` is always acceptable for HTTP/1.1 recipients and you don't have to specify `chunked` using the `TE` header.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is chunked? It isn't mentioned elsewhere in this doc. I would assume a kind of encoding but it is not listed

@@ -82,9 +82,14 @@ Tk: N

## Specifications

Part of the discontinued [Tracking Preference Expression (DNT)](https://www.w3.org/TR/tracking-dnt/#response-header-field) specification.
The discontinued [Tracking Preference Expression (DNT)](https://www.w3.org/TR/tracking-dnt/#response-header-field) specification.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not do this using spec-url?

dynamically generated while the message body is sent, such as a message integrity check,
digital signature, or post-processing status.
The HTTP **Trailer** {{glossary("request header", "request")}} and {{glossary("response header")}} allows the sender to include additional fields at the end of chunked messages in order to supply metadata that might be dynamically generated while the message body is sent.
The content of a trailer field may be a message integrity check, digital signature, or post-processing status.
Copy link
Collaborator

@hamishwillee hamishwillee Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or Server-Timing, and maybe other things - is this canonical or "for example"?


In this example, the {{HTTPHeader("Expires")}} header is used at the end of the chunked
message and serves as a trailing header.
In this example response, the {{HTTPHeader("Expires")}} header is used at the end of the chunked message and serves as a trailing header:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confusing.

Suggested change
In this example response, the {{HTTPHeader("Expires")}} header is used at the end of the chunked message and serves as a trailing header:
In this example response, the {{HTTPHeader("Expires")}} header is used as a trailing header:


`Transfer-Encoding` is a [hop-by-hop header](/en-US/docs/Web/HTTP/Headers#hop-by-hop_headers), that is applied to a message between two nodes, not to a resource itself.
Each segment of a multi-node connection can use different `Transfer-Encoding` values.
If you want to compress data over the whole connection, use the end-to-end {{HTTPHeader("Content-Encoding")}} header instead.

When present on a response to a {{HTTPMethod("HEAD")}} request that has no body, it indicates the value that would have applied to the corresponding {{HTTPMethod("GET")}} message.

> [!WARNING]
> HTTP/2 disallows all uses of the `Transfer-Encoding` header other than the HTTP/2 specific value `"trailers"`.
> HTTP/2 and later provides other, more efficient, mechanisms for data streaming than chunked transfer.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Provide?

Suggested change
> HTTP/2 and later provides other, more efficient, mechanisms for data streaming than chunked transfer.
> HTTP/2 and later provide other, more efficient, mechanisms for data streaming than chunked transfer.

Comment on lines +42 to +43
- `<protocol_version>` {{optional_inline}}
- : An optional protocol version may be provided prefixed with a `/` forward slash.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be indented?


The `Upgrade` header field may be used by clients to invite a server to switch to one (or more) of the listed protocols, in descending preference order.
```http
Upgrade: <protocol>[/<protocol_version>]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't remember if we normally show multiples here, rather than stating below that they are comma separated. But I think we do

> [!NOTE]
> In contrast to earlier drafts of the specifications, the weighting is _not_ declared via [q-values](/en-US/docs/Glossary/Quality_values).
```http
Want-Content-Digest: <digest-algorithm>=<preference>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implies you can set only one value, even though example below shows multiples, and you would not necessarily need preference if you could only set one.


## Directives

For permissible digest algorithms see {{HTTPHeader("Repr-Digest")}}.
- `<digest-algorithm>`
- : The algorithm used to create a digest of the message content.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be something like "the algorithm to be used to ..."

> [!NOTE]
> In contrast to earlier drafts of the specifications, the weighting is _not_ declared via [q-values](/en-US/docs/Glossary/Quality_values).
```http
Want-Repr-Digest: <digest-algorithm>=<preference>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto to above - do we need to indicate multiple values are allowed here?


## Directives

For permissible digest algorithms see {{HTTPHeader("Repr-Digest")}}.
- `<digest-algorithm>`
- : The algorithm used to create a digest of the representation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above - the "requested algorithm" or something to state that this is wanted. Perhaps this is fine.

...
WWW-Authenticate: challengeN
```plain
WWW-Authenticate = #challenge
Copy link
Collaborator

@hamishwillee hamishwillee Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why #

Oh, I see - I think you're perhaps pulling this out of the spec to mean "some kind of challenge". Lets not do that.

WWW-Authenticate: <auth-scheme> realm=<realm> auth-param1=auth-param1-token, ..., auth-paramN=auth-paramN-token
WWW-Authenticate: <auth-scheme> token68 auth-param1=auth-param1-token, ..., auth-paramN=auth-paramN-token
```plain
challenge = <auth-scheme> [ 1*SP ( <token68> / #<auth-param> ) ]
Copy link
Collaborator

@hamishwillee hamishwillee Dec 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand this syntax. We don't use it anywhere else, and it is nowhere near as clear as what it replaces.

For example, what is 1*SP? What is #<auth-param>.

Web APIs and CSS spell out the options. I'm not sure that is possible here, but certainly this is not helpful without some more work.

According to the specification, it can hold a base64, base64url, base32, or base16 (hex) encoding, with or without padding, but excluding whitespace.
- : A token that may be useful for some schemes.
The token allows the 66 unreserved URI characters plus a few others.
According to the specification, it can hold a {{glossary("base64")}}, base64url, base32, or base16 (hex) encoding, with or without padding, but excluding whitespace.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need "According to the specification, " (see similar previous comment)

WWW-Authenticate: challenge1, …, challengeN
```

Multiple challenges can be sent in separate `WWW-Authenticate` headers in the same response:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should also be said up in the syntax section.

@@ -53,6 +42,15 @@ X-Content-Type-Options: nosniff
`style` and the MIME type is not `text/css`,
or of type `script` and the MIME type is not a [JavaScript MIME type](https://html.spec.whatwg.org/multipage/scripting.html#javascript-mime-type).

## Description

This header was introduced by Microsoft in IE 8 as a way for webmasters to block content sniffing that was happening and could transform non-executable MIME types into executable MIME types.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feels like there should be a BCD entry for this and the information here should go into it.

has the meaning described in the [Directives](#directives) section. But if there's a risk the client or any proxy
is malicious or misconfigured, then it's possible any part (or the entirety) of the header may have been
spoofed (and may not be a list or contain IP addresses at all).
For example:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this. Or to put it another way, in other cases you don't have a lead in like this. Further, in some you have the comments outside the code block and others inside.

FWIW I would just remove this line.

- : The client IP address.
- `<proxy>`
- : A proxy IP address.
If a request goes through multiple proxies, the IP addresses of each successive proxy is listed.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If a request goes through multiple proxies, the IP addresses of each successive proxy is listed.
If a request goes through multiple proxies, the IP addresses of each successive proxy are listed.

X-Forwarded-For: 203.0.113.195,2001:db8:85a3:8d3:1319:8a2e:370:7348,198.51.100.178
```
This header exposes privacy-sensitive information by design, such as the IP address of the client.
Therefore, the user's privacy must be kept in mind when deploying this header.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've seen "deploying this header" a few times. Do you really deploy a header? I don't know why, but it is a bit grating. Maybe "use"

This header exposes privacy-sensitive information by design, such as the IP address of the client.
Therefore, the user's privacy must be kept in mind when deploying this header.

The `X-Forwarded-For` header is untrustworthy when no **trusted reverse proxy** (e.g., a load balancer) is between the client and server.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sounds wrong. My assumption is that you could have a trusted reverse proxy between client and server and the header is still untrustworthy, because you have several other untrusted proxies (or whatever) between them.

This can only be true if the only thing that can be setting this header is a single reverse proxy, and that must also be trusted


```http
X-Forwarded-For: 203.0.113.195,2001:db8:85a3:8d3:1319:8a2e:370:7348,198.51.100.178
```
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is all OK in this topic, but getting tired and finding it hard to parse.

<td>{{Glossary("Response header")}}</td>
</tr>
<tr>
<th scope="row">{{Glossary("Forbidden header name")}}</th>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this probably should be https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_response_header_name - since it is a response header.


> [!WARNING]
> Even though this feature can protect users of older web browsers that don't yet support {{Glossary("CSP")}}, in some cases, **XSS protection can create XSS vulnerabilities** in otherwise safe websites. See the section below for more information.
> Even though this feature can protect users of older web browsers that don't yet support {{Glossary("CSP")}}, in some cases, **XSS protection can create XSS vulnerabilities** in otherwise safe websites. See the [Security considerations](#security_considerations) section below for more information.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> Even though this feature can protect users of older web browsers that don't yet support {{Glossary("CSP")}}, in some cases, **XSS protection can create XSS vulnerabilities** in otherwise safe websites. See the [Security considerations](#security_considerations) section below for more information.
> Even though this feature can protect users of older web browsers that don't yet support {{Glossary("CSP")}}, in some cases, **`X-XSS-Protection` can create XSS vulnerabilities** in otherwise safe websites. See the [Security considerations](#security_considerations) section below for more information.

Comment on lines +21 to +23
- Chrome has [removed their XSS Auditor](https://chromestatus.com/feature/5021976655560704)
- Firefox has not, and [will not implement `X-XSS-Protection`](https://bugzil.la/528661)
- Edge has [retired their XSS filter](https://blogs.windows.com/windows-insider/2018/07/25/announcing-windows-10-insider-preview-build-17723-and-build-18204/)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this is not in BCD it should be pushed there. The sentence below would then be reworded appropriately.

@hamishwillee
Copy link
Collaborator

This has cooked my brain :-0. Probably got a bit more sloppy towards the end.

@bsmth
Copy link
Member Author

bsmth commented Dec 2, 2024

This has cooked my brain :-0. Probably got a bit more sloppy towards the end.

Yes, I can imagine - thank you very much 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:Glossary Glossary entries Content:HTTP HTTP docs size/xl [PR only] >1000 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect WWW-Authenticate formats Default value of SameSite
2 participants