Avoid security error due to accessing headers not allowed.

Browsers restrict access to all headers on cross-domain requests to
headers other than the "simple response headers". If not a simple handle
browsers handle header access in inconsistant ways. Some even throw and error
that you cannot try-catch. The conditional in this commit prevents the
error from occuring on cross-domain requests.

See http://stackoverflow.com/a/4858984/120067 for more info