-
Notifications
You must be signed in to change notification settings - Fork 22.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(http): Add Prefer, Preferrence-Applied headers
- Loading branch information
Showing
3 changed files
with
142 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
<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")}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
<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 | ||
``` | ||
|
||
## Specifications | ||
|
||
{{Specifications}} | ||
|
||
## See also | ||
|
||
- {{HTTPHeader("Prefer")}} |