Paolo Dodet wrote:
That is. If you access my personal site using IE you will notice that I use
a meta tag to declare the mime-type, and in the case of IE it would be
text/html, whereas if you access using any other browser the page will be
served as XML, using a xml declaration, without any meta-tag to declare the
mime-type.

http://www.noblocodenotas.com/

That makes no sense whatsoever! You never need to use the meta element for content served over HTTP for *any* browser. IE supports the HTTP headers just fine:

Besides, your server is not sending the correct HTTP response headers to any browser, even though it is stripping the meta element and adding the xml declaration for those that support it.

These are the response headers sent to Firefox regardless of the value of the Accept header.

HTTP/1.x 200 OK
Date: Tue, 17 Jan 2006 21:49:22 GMT
Server: Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.10 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7e
X-Powered-By: PHP/4.3.10
Keep-Alive: timeout=1, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/html

Regardless of whether the Accept header contained application/xhtml+xml or only text/html, the meta element was stripped and the XML declaration was added, yet the Content-Type of text/html remained the same.

These response headers were sent when the browser identified itself as IE (including Firefox when I modified the User-Agent header to match IE6):

HTTP/1.1 200 OK
Date: Tue, 17 Jan 2006 21:44:21 GMT
Server: Apache/1.3.34 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 PHP/4.3.10 FrontPage/5.0.2.2635 mod_ssl/2.8.25 OpenSSL/0.9.7e
X-Powered-By: PHP/4.3.10
Transfer-Encoding: chunked
Content-Type: text/html

Regardless of the Accept header again, the meta was element was included, the XML declation was not.

This proves that not only are you failing to set the HTTP headers correctly, but you're changing the document based on the perceived browser support judged only by the the User-Agent request header. In other words, you're browser sniffing and that is never the right way to do things.

If you wish to do content negotiation, please do so properly. This article [1] posted here earlier explains the correct way to set the headers and detect based on the Accept header.

For HTML, the Content-Type response header should contain this:

Content-Type: text/html; charset=ISO-8859-1

Don't include the XML declaration.

(Note: I recommend you switch to using UTF-8 instead, but it requires that your files actually be saved as UTF-8, not just changing the value in this header)


For XHTML, use this:

Content-Type: application/xhtml+xml

Include the XML declaration to declare the encoding.

*DO NOT* use the meta element for any browser at all, in fact don't even include it in your document under any circumstances when serving over HTTP. (It can be useful for testing on the local file system, but useless for anything beyond that).

[1] http://www.thatstandardsguy.co.uk/2006/01/16/content-negotiation/

--
Lachlan Hunt
http://lachy.id.au/

******************************************************
The discussion list for  http://webstandardsgroup.org/

See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************

Reply via email to