title: Accept and Accept-Charset - Which is superior?
body: <p>In HTTP you can specify in a request that your client can accept specific content in responses using the <code>accept</code> header, with values such as <code>application/xml</code>. The content type specification allows you to include parameters in the content type, such as <code>charset=utf-8</code>, indicating that you can accept content with a specified character set.</p>
  
  <p>There is also the <code>accept-charset</code> header, which specifies the character encodings which are accepted by the client.</p>
  
  <p>If both headers are specified and the <code>accept</code> header contains content types with the charset parameter, which should be considered the superior header by the server?</p>
  
  <p>e.g.:</p>
  
  <pre><code>Accept: application/xml; q=1,
          text/plain; charset=ISO-8859-1; q=0.8
  Accept-Charset: UTF-8
  </code></pre>
  
  <p>I've sent a few example requests to various servers using Fiddler to test how they respond:</p>
  
  <p><strong>Examples</strong></p>
  
  <p><strong>W3</strong></p>
  
  <p>Request</p>
  
  <pre><code>GET http://www.w3.org/ HTTP/1.1
  Host: www.w3.org
  Accept: text/html;charset=UTF-8
  Accept-Charset: ISO-8859-1
  </code></pre>
  
  <p>Response</p>
  
  <pre><code>Content-Type: text/html; charset=utf-8
  </code></pre>
  
  <p><strong>Google</strong></p>
  
  <p>Request</p>
  
  <pre><code>GET http://www.google.co.uk/ HTTP/1.1
  Host: www.google.co.uk
  Accept: text/html;charset=UTF-8
  Accept-Charset: ISO-8859-1
  </code></pre>
  
  <p>Response</p>
  
  <pre><code>Content-Type: text/html; charset=ISO-8859-1
  </code></pre>
  
  <p><strong>StackOverflow</strong></p>
  
  <p>Request</p>
  
  <pre><code>GET http://stackoverflow.com/ HTTP/1.1
  Host: stackoverflow.com
  Accept: text/html;charset=UTF-8
  Accept-Charset: ISO-8859-1
  </code></pre>
  
  <p>Response</p>
  
  <pre><code>Content-Type: text/html; charset=utf-8
  </code></pre>
  
  <p><strong>Microsoft</strong></p>
  
  <p>Request</p>
  
  <pre><code>GET http://www.microsoft.com/ HTTP/1.1
  Host: www.microsoft.com
  Accept: text/html;charset=UTF-8
  Accept-Charset: ISO-8859-1
  </code></pre>
  
  <p>Response </p>
  
  <pre><code>Content-Type: text/html
  </code></pre>
  
  <p>There doesn't seem to be any consensus around what the expected behaviour is. I am trying to look surprised.</p>