-
Notifications
You must be signed in to change notification settings - Fork 22.6k
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
--- | ||
title: Prefer | ||
slug: Web/HTTP/Headers/Prefer | ||
page-type: http-header | ||
spec-urls: https://www.rfc-editor.org/rfc/rfc7240#section-2 | ||
--- | ||
|
||
{{HTTPSidebar}} | ||
|
||
The HTTP **`Prefer`** header allows clients to indicate preferences for specific server behaviors during request processing. | ||
|
||
> [!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. | ||
Comment on lines
+12
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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" |
||
<table class="properties"> | ||
<tbody> | ||
<tr> | ||
<th scope="row">Header type</th> | ||
<td> | ||
{{Glossary("Request header")}} | ||
</td> | ||
</tr> | ||
<tr> | ||
<th scope="row">{{Glossary("Forbidden header name")}}</th> | ||
<td>No</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
|
||
## Syntax | ||
|
||
```http | ||
Prefer: <preference> | ||
``` | ||
|
||
## Directives | ||
|
||
- `respond-async` | ||
- : Indicates that the client prefers asynchronous processing. | ||
- `return=minimal` | ||
- : Requests that the server return minimal content. | ||
- `return=representation` | ||
- : Requests a full resource representation in the response. | ||
- `wait=<seconds>` | ||
- : Suggests how long the server should wait for the request to complete before timing out. | ||
- Custom preferences | ||
- : Vendors or applications may define their own preferences to suit specific needs. For example, `custom-feature-enabled=true`. | ||
|
||
## Examples | ||
|
||
### Requesting minimal response | ||
|
||
```http | ||
GET /resource HTTP/1.1 | ||
Host: example.com | ||
Prefer: return=minimal | ||
``` | ||
|
||
### Requesting asynchronous processing | ||
|
||
```http | ||
POST /process HTTP/1.1 | ||
Host: example.com | ||
Prefer: respond-async | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## See also | ||
|
||
- {{HTTPHeader("Preference-Applied")}} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,61 @@ | ||||||
--- | ||||||
title: Preference-Applied | ||||||
slug: Web/HTTP/Headers/Preference-Applied | ||||||
page-type: http-header | ||||||
spec-urls: https://www.rfc-editor.org/rfc/rfc7240#section-3 | ||||||
--- | ||||||
|
||||||
{{HTTPSidebar}} | ||||||
|
||||||
The HTTP **`Preference-Applied`** header informs the client about which preferences from the `Prefer` request header were applied by the server. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
<table class="properties"> | ||||||
<tbody> | ||||||
<tr> | ||||||
<th scope="row">Header type</th> | ||||||
<td> | ||||||
{{Glossary("Response header")}} | ||||||
</td> | ||||||
</tr> | ||||||
<tr> | ||||||
<th scope="row">{{Glossary("Forbidden header name")}}</th> | ||||||
<td>No</td> | ||||||
</tr> | ||||||
<tr> | ||||||
<th scope="row"> | ||||||
{{Glossary("CORS-safelisted response header")}} | ||||||
</th> | ||||||
<td>No</td> | ||||||
</tr> | ||||||
</tbody> | ||||||
</table> | ||||||
|
||||||
## Syntax | ||||||
|
||||||
```http | ||||||
Preference-Applied: <preference> | ||||||
``` | ||||||
|
||||||
## Examples | ||||||
|
||||||
### 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 | ||||||
``` | ||||||
Comment on lines
+41
to
+53
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
|
||||||
## Specifications | ||||||
|
||||||
{{Specifications}} | ||||||
|
||||||
## See also | ||||||
|
||||||
- {{HTTPHeader("Prefer")}} |
There was a problem hiding this comment.
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.