HTTP Headers
Accept Patch
The HTTP Accept-Patch
response header informs clients about which media types the server can understand in a PATCH
request.
For instance, if a server receives a PATCH
request with a media type it does not support, it may respond with a 415 Unsupported Media Type
status code and include an Accept-Patch
header indicating the supported media types.
The header should be included in OPTIONS
requests to resources that permit PATCH
method.
An Accept-Patch
header in the response to any request type implicitly indicates that using PATCH
on the target resource is allowed.
Header type | Response header |
---|---|
Forbidden request header | Yes |
Syntax
Accept-Patch: <media-type>/<subtype>
Accept-Patch: <media-type>/*
Accept-Patch: */*
Note: The Accept-Patch header can contain a comma-separated list of media types, such as:
Accept-Patch: <media-type>/<subtype>, <media-type>/<subtype>
Directives
Directives
<media-type>/<subtype>
A specific media type specifying both the type and subtype, such as
text/html
. This precisely indicates the format or data type being used, which helps in content negotiation and proper rendering by browsers or applications.<media-type>/*
This represents a media type without specifying a subtype. For example,
image/*
refers broadly to any image format, includingimage/png
,image/svg
, andimage/gif
. It is often used when the specific subtype is not crucial or when multiple subtypes are acceptable for a certain context.*/*
This denotes any media type, regardless of the specific format or subtype. It is useful when the type of content is flexible, or when the server or client does not specify a preference for particular formats.
Example
Accept-Patch: application/json
Accept-Patch: application/json, text/plain
Accept-Patch: text/plain;charset=utf-8
How to Modify Header using Requestly
Requestly is a powerful Chrome extension that allows you to modify HTTP headers, including the Accept header. This is especially useful for testing how your application responds to different media types during development or debugging. Steps to Modify the Accept Header:
- Install and open the Requestly Chrome extension. You can find it on the Chrome Web Store.
- Create a new rule: Click on “Create Rule” and choose “Modify Headers” from the list of available rule types.
- Add a new header modification:
- Under “Action”, select “Add” or “Override”.
- In the “Header Name” field, enter Accept.
- In the “Header Value” field, enter your preferred media type (e.g., text/html).
- Set the URL condition: Specify the URL or pattern where this header change should apply (e.g., https://your-api.com/*).
- Save the rule.
Once set up, Requestly will inject the Accept: text/html header into all matching requests, allowing you to simulate different client behaviors and test content negotiation on your server.
You might need to modify the Accept header to see how your website or API handles different types of content, such as HTML, JSON, or XML. This helps ensure your application works correctly with various data formats and improves debugging during development.
Table of Contents
- No headings found.