handling whether or not headers were sent; handling 'localhost' exception for setting HTTP host