Response headers can be added by any part of the system at basically any time (Unless you've sent a blank line already), so basically you are stuck. If you can some how arrange for your module to be loaded before any headers are sent, you could tie STDOUT and capture the headers before sending them off.