Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1109519 of Accept

  • Revision slug: Web/HTTP/Headers/Accept
  • Revision title: Accept
  • Revision id: 1109519
  • Created:
  • Creator: teoli
  • Is current revision? No
  • Comment

Revision Content

{{HTTPSidebar}}

The Accept request HTTP header advertises which content types, expressed as MIME types, the client is able to understand. Using content negotiation, the server then selects one of the proposals, uses it and informs the client of its choice with the {{HTTPHeader("Content-Type")}} response header. Browsers set adequate values for this header depending of the context where the request is done: when fetching a CSS stylesheet a different value is set for the request than when they fetching an image, a video or a script.

Header type {{Glossary("Request header")}}
{{Glossary("Forbidden header name")}} no

Syntax

Accept: <MIME_type>/<MIME_subtype>
Accept: <MIME_type>/*
Accept: */*

// Multiple types, weighted with the {{glossary("quality value", "quality values")}} syntax:
Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8

Directives

<MIME_type>/<MIME_subtype>
A single, precise MIME type, like text/html.
<MIME_type>/*
A MIME type, but without any subtype. image/* will match image/png, image/svg, image/gif and any other image types.
*/*
Any MIME type
;q= (q-factor weighting)
Any value used is placed in an order of preference expressed using relative quality value called the weight.

Examples

Accept: text/html

Accept: image/*

Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8

Specifications

Specification Title
{{RFC("7232", "Accept", "5.3.2")}} Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context

Browser compatibility

{{Compat}}

See also

  • HTTP content negotiation
  • Header with the result of the content negotiation: {{HTTPHeader("Content-Type")}}
  • Other similar headers: {{HTTPHeader("TE")}}, {{HTTPHeader("Accept-Encoding")}}, {{HTTPHeader("Accept-Charset")}}, {{HTTPHeader("Accept-Language")}}

Revision Source

<div>{{HTTPSidebar}}</div>

<p>The <strong><code>Accept</code></strong> request HTTP header advertises which content types, expressed as <a href="/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types">MIME types</a>, the client is able to understand. Using <a href="/en-US/docs/Web/HTTP/Content_negotiation">content negotiation</a>, the server then selects one of the proposals, uses it and informs the client of its choice with the {{HTTPHeader("Content-Type")}} response header. Browsers set adequate values for this header depending of the context where the request is done: when fetching a CSS stylesheet a different value is set for the request than when they fetching an image, a video or a script.</p>

<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>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox">
Accept: &lt;MIME_type&gt;/&lt;MIME_subtype&gt;
Accept: &lt;MIME_type&gt;/*
Accept: */*

// Multiple types, weighted with the {{glossary("quality value", "quality values")}} syntax:
Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8</pre>

<h2 id="Directives">Directives</h2>

<dl>
 <dt><code>&lt;MIME_type&gt;/&lt;MIME_subtype&gt;</code></dt>
 <dd>A single, precise <a href="/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types">MIME type</a>, like <code>text/html</code>.</dd>
 <dt><code>&lt;MIME_type&gt;/*</code></dt>
 <dd>A MIME type, but without any subtype. <code>image/*</code> will match <code>image/png</code>, <code>image/svg</code>, <code>image/gif</code> and any other image types.</dd>
 <dt><code>*/*</code></dt>
 <dd>Any MIME type</dd>
 <dt><code>;q=</code> (q-factor weighting)</dt>
 <dd>Any value used is placed in an order of preference expressed using relative <a href="/en-US/docs/Glossary/Quality_values">quality value</a> called the <em>weight</em>.</dd>
</dl>

<h2 id="Examples">Examples</h2>

<pre>
Accept: text/html

Accept: image/*

Accept: text/html, application/xhtml+xml, application/xml;q=0.9, */*;q=0.8
</pre>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Title</th>
  </tr>
  <tr>
   <td>{{RFC("7232", "Accept", "5.3.2")}}</td>
   <td>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Context</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p class="hidden">The compatibility table in this page is generated from structured data. If you’d like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data/README.md">https://github.com/mdn/browser-compat-data/README.md</a> and send us a pull request.</p>

<p>{{Compat}}</p>

<h2 id="See_also">See also</h2>

<ul>
 <li>HTTP <a href="/en-US/docs/Web/HTTP/Content_negotiation">content negotiation</a></li>
 <li>Header with the result of the content negotiation: {{HTTPHeader("Content-Type")}}</li>
 <li>Other similar headers: {{HTTPHeader("TE")}}, {{HTTPHeader("Accept-Encoding")}}, {{HTTPHeader("Accept-Charset")}}, {{HTTPHeader("Accept-Language")}}</li>
</ul>
Revert to this revision