Surely you could use PHP's get_headers()
function?
http://php.net/manual/en/function.get-headers.php
http://php.net/manual/en/function.get-headers.php
The first element in the array returned will be the response code. If it contains '403' then Drupal returned an "access denied" page.
I'm not sure where the best place to call it would be. Probably hook_exit()
, depending on your needs:
http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_exit/6