HTTP headers | Accept

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.

Syntax:

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.

Example:

  • This example accepts the text type with the subtype of html.
    Accept: text/html
  • This example accept any image subtype does not bother.
    Accept: image/*

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
  • Firefox
  • Safari
  • Opera


My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.