Fix NPE when request is empty / host is not given

When the request is not valid, the response will be null, leading to a NPE.
After the try block, the null response will be caught and an error will be
logged which is better than throwing a NPE.