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

feat(http): Add Prefer, Preferrence-Applied headers #37659

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

alivedise
Copy link

Description

This PR adds two pages for Prefer related headers which are specified in RFC7240 and IETF header registry.

Motivation

I am not sure why they(Prefer, Preferrence-Applied) are not listed on MDN. Is it because the browser has nothing to do with the header? But I see Expect also in the MDN header list and I think it is not a browser-oriented header, either.

Additional details

Related issues and pull requests

None AFAIK.

@alivedise alivedise requested a review from a team as a code owner January 15, 2025 17:13
@alivedise alivedise requested review from hamishwillee and removed request for a team January 15, 2025 17:13
@github-actions github-actions bot added Content:HTTP HTTP docs size/m [PR only] 51-500 LoC changed labels Jan 15, 2025
Copy link
Contributor

github-actions bot commented Jan 16, 2025

Preview URLs

Flaws (6)

Note! 2 documents with no flaws that don't need to be listed. 🎉

URL: /en-US/docs/Web/HTTP/Headers
Title: HTTP headers
Flaw count: 6

  • macros:
    • Can't resolve /en-US/docs/Web/HTTP/Headers/Sec-CH-UA-Form-Factor
    • Can't resolve /en-US/docs/Web/HTTP/Headers/Sec-CH-UA-WoW64
    • Can't resolve /en-US/docs/Web/HTTP/Headers/Accept-Signature
    • Can't resolve /en-US/docs/Web/HTTP/Headers/Signature
    • Can't resolve /en-US/docs/Web/HTTP/Headers/Signed-Headers
  • unknown:
    • No generic content config found

(comment last updated: 2025-01-31 06:13:46)

@bsmth
Copy link
Member

bsmth commented Jan 16, 2025

Thanks for suggesting, typically the criteria for inclusion is whether there's current browser support, but there are some exceptions. In the HTTP section, some mechanisms and headers are described that are basically transparent to the browser. For those it's mostly decided case-by-case and whether they're used in other systems / web technologies.

For these two headers, they look important for the Open Data (OData) protocol (https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-odata/b4768cbf-13d5-40df-bfa3-7d43ef73e882, https://docs.oasis-open.org/odata/odata/v4.01/odata-v4.01-part1-protocol.html#_Toc31358871) and PGRest, among others, so I'm +1 on adding these as the footprint is small for the additions 👍🏻


{{HTTPSidebar}}

The HTTP **`Preference-Applied`** header informs the client about which preferences from the `Prefer` request header were applied by the server.
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
The HTTP **`Preference-Applied`** header informs the client about which preferences from the `Prefer` request header were applied by the server.
The HTTP **`Preference-Applied`** header informs the client about which preferences from the {{httpheader("Prefer"}} request header were applied by the server.

Comment on lines +41 to +53
### Server acknowledges a minimal response preference

```http
HTTP/1.1 200 OK
Preference-Applied: return=minimal
```

### Server acknowledges an asynchronous processing preference

```http
HTTP/1.1 202 Accepted
Preference-Applied: respond-async
```
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you please update the examples to show the request that caused this response (with appropriate words). You could do the same for prefer. The whole thing is a little abstract otherwise.

Comment on lines +12 to +14
> [!NOTE]
> The `Prefer` header is often used in custom client-server implementations. Ensure both client and server support this header before relying on it in production.
> The `Prefer` header does not cause the server to return an error if it does not support or apply the specified preferences. Instead, the server processes the request as if the header was not present.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is good. My concern here is that this has no specific browser integration. That might be worth spelling out (it is implied but not said). Words like "(browsers have no specific handling for these header: they are processed custom client code) or similar

Further, if this is used in a few protocols it might be worth listing a few, such as "Open Data (OData) protocol"

@@ -167,6 +167,13 @@ For more information, refer to the [CORS documentation](/en-US/docs/Web/HTTP/COR
- {{HTTPHeader("Content-Location")}}
- : Indicates an alternate location for the returned data.

## Preference

Copy link
Collaborator

Choose a reason for hiding this comment

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

Again, might we worth a prefix line custom client-server implementations: they have no specific handling in the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Content:HTTP HTTP docs size/m [PR only] 51-500 LoC changed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants