Does Apache submit headers when a error occurs ?
No. You sent the headers with your send_http_header command. Mason doesn't have this issue because it waits and builds up the entire output in a string before it sends any headers out. You can do the same in your script if you want to.
Take a look at http://perl.apache.org/docs/1.0/guide/snippets.html#Redirecting_Errors_to_the_Client_Instead_of_error_log for more info on these issues.
$r->('HI');
That's not a method of $r. Don't do that.
- Perrin