avoid failing with an exception if the remote server doesn't give us a Content-Type header. Also, clean up the exception handling a bit.