Initial support for preferred content types. See http://drupal.org/node/475242 for more details. Signed-off-by: Antonio Ospite Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.913 diff -u -r1.913 common.inc --- includes/common.inc 27 May 2009 14:33:41 -0000 1.913 +++ includes/common.inc 28 May 2009 18:05:40 -0000 @@ -158,7 +158,8 @@ * Retrieve output to be displayed in the head tag of the HTML page. */ function drupal_get_html_head() { - $output = "\n"; + global $content_type; + $output = "\n"; return $output . drupal_add_html_head(); } @@ -3223,8 +3224,29 @@ return (($skip_anonymous && $user->uid == 0) || ($token == md5(session_id() . $value . variable_get('drupal_private_key', '')))); } +function _drupal_init_content_type() { + global $content_type; + + /* this should be exposed byt some API so that themes can specify theis + * preferred content types + */ + $preferred_types = array("application/xhtml+xml", "application/xml", "text/xml"); + + + $content_type = "text/html"; /* default */ + $http_accept = $_SERVER["HTTP_ACCEPT"]; + foreach ($preferred_types as $type) { + if (stristr($http_accept, $type)) { + $content_type = $type; + break; + } + } + +} + function _drupal_bootstrap_full() { static $called; + global $content_type; if ($called) { return; @@ -3245,8 +3267,11 @@ set_exception_handler('_drupal_exception_handler'); // Emit the correct charset HTTP header. - drupal_set_header('Content-Type', 'text/html; charset=utf-8'); // Detect string handling method + _drupal_init_content_type(); + drupal_set_header('Content-Type', "$content_type; charset=utf-8"); + drupal_set_header('Vary', 'Accept'); + unicode_check(); // Undo magic quotes fix_gpc_magic();