The HTTP Accept header is a request type header. The Accept header is used to inform the server by the client that which content type is understandable by the client expressed as MIME-types. By using the Content-negotiation the server selects a proposal of the content type and informs the client of its choice with the Content-type response header. If the Accept header is not present in the request, then the server assumes that the client accepts all types of media.
Accept: <MIME_type>/<MIME_subtype> | <MIME_type>/* | */*
Directives: This header accept below mentioned directives:
- <MIME_type>/<MIME_subtype>: This directive holds the type/subtype of the web content that the client will received by content-type header which is chosen by the server from Accept header. Basically it holds the single mime type like text/html.
- <MIME_type>/*: This directive holds the type but can accept any subtyping like image/* means the image can be jpg, png, or can svg everything will be accepted.
- */* This directive accepts any kind of type/subtype.
- This example accepts the text type with the subtype of html.
- This example accept any image subtype does not bother.
To check this Accept in action go to Inspect Element -> Network check the request header for Accept like below, Accept is highlighted you can see.
Supported Browsers: The browsers are compatible with HTTP Accept header are listed below:
- Google Chrome
- Internet Explorer
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.