This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 5900 - Dynamic Content-Type
Summary: Dynamic Content-Type
Status: RESOLVED WORKSFORME
Alias: None
Product: Validator
Classification: Unclassified
Component: Parser (show other bugs)
Version: HEAD
Hardware: All All
: P2 enhancement
Target Milestone: ---
Assignee: This bug has no owner yet - up for the taking
QA Contact: qa-dev tracking
URL: http://validator.w3.org/
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-07-28 00:30 UTC by Peter Hanneman
Modified: 2008-07-28 04:45 UTC (History)
1 user (show)

See Also:


Attachments

Description Peter Hanneman 2008-07-28 00:30:22 UTC
I am serving an XHTML 1.1 Strict document via PHP.  I use the fallowing PHP code to check if the browser supports the "application/xhtml+xml" content type and serve the appropriate type:

header("Vary: Accept");
if(stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) 
	header("Content-Type: application/xhtml+xml; charset=utf-8");
else
	header("Content-Type: text/html; charset=utf-8");


This code works very well for actual browsers, but creates a warning if I try to validate the site.  This is because your site doesn't provide the proper information in it's HTTP header.  I know this is a minor bug, but it's frustrating having perfect markup, but still having that one error pop up every time.

Thanks for looking into this!
- Peter Hanneman
hannemanp@gmail.com
Comment 1 Olivier Thereaux 2008-07-28 04:44:56 UTC
(In reply to comment #0)
> I am serving an XHTML 1.1 Strict document via PHP.  I use the fallowing PHP
> code to check if the browser supports the "application/xhtml+xml" content type
> and serve the appropriate type:
> 
> header("Vary: Accept");
> if(stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml")) 
>         header("Content-Type: application/xhtml+xml; charset=utf-8");
> else
>         header("Content-Type: text/html; charset=utf-8");

You could send application/xhtml+xml if no Accept: is sent, and only send as text/html for agents that send an Accept: but do not include application/xhtml+xml.

> This code works very well for actual browsers, but creates a warning if I try
> to validate the site.

The warning has been removed from the version to be released.
http://qa-dev.w3.org/wmvs/HEAD/

  This is because your site doesn't provide the proper
> information in it's HTTP header.  I know this is a minor bug, but it's
> frustrating having perfect markup, but still having that one error pop up every
> time.

Warning, not error. Also, if that really frustrates you, you may want to look into 
http://validator.localhost/docs/users.html#option-accept