Why does a header set via drupal_set_header() revert to text/html? I'm using the views_rss module in Drupal 6. Whenever I build out a View using this plugin, the following header is sent in a template_preprocess function:

drupal_set_header('Content-Type: application/rss+xml; charset=utf-8');


This seems to be ignored, as the page is ultimately sent with a text/html header. It seems that my header is getting appended, but text/html is either sent first or last (whichever is ultimately interpreted by the browser) and thus has no effect.

How can I force a non-text/html header for a page output in Drupal 6?
I think you are too late in the template_preprocess hook. The views display will have set it's header already before your hook gets called.

To test my thought have a look at the return value of the function drupal_set_header. It shows you all headers sent before.

If I'm right: Try implementing a hook which is is called earlier (maybe even before execution of the view query). Then your header will have precedence.