It would be good if a subset of modules could get a hook to allow them to contribute/take over HTTP headers.

Example uses of this capability:
- issue redirects from modules
- web browser level user authentication (rather than cookie authentication) using real drupal user set (as opposed to web_auth module that turns it all over to the web browser)
- different expires settings for different pages (again, under module control)

The reason why I say 'a subset' is that calling all modules before cache checking etc could introduce bags of overhead.

Comments

Brian@brianpuccio.net’s picture

I second this, I already implemented a minor code change to change the MIME type depending on the browser. It would be nice if this was in a module. Maybe the filestore modules can use it as well depending on the type of file that is being served.

TheLibrarian’s picture

I know it's not what you're looking for, but some modules already modify headers before they are sent. Check out pdfview for an example.

jonbob’s picture

Before any page output is sent, hook_init() is fired. This can do what you ask. In fact, in many cases even this is not necessary, as if your module is responding to the path in question it can use header() before it calls print theme('page').

Anonymous’s picture

not_Dries_Buytaert’s picture

Title: modules that can generate HTTP headers » Drupal 6.* module that allows adding, changing and removing HTTP headers
Version: » 6.14
Component: module system » base system

As explained here it is more secure, if admins can change the http header "Expires: Sun, 19 Nov 1978 05:00:00 GMT", which is hard coded in 'includes/bootstrap.inc':
drupal_page_header: http://api.drupal.org/api/function/drupal_page_header/6
and
drupal_page_cache_header: http://api.drupal.org/api/function/drupal_page_cache_header/6
Aforementioned header is often used to fingerprint Drupal, such as via this Drupal filter of a backend software fingerprinting add-on for FF:
http://code.google.com/p/backendinfo/source/browse/trunk/content/filters...

This feature may already be implemented with this Drupal 5.* module: http://drupal.org/project/httpHeaders

I did find this Drupal 6.* dev module: http://ftp.drupal.org/files/projects/httpHeaders-6.x-1.x-dev.tar.gz