Added checks for response headers as they could be null causing a NullPointerException