contentType here is not the contentType for imageUrl but is instead the contentType of the url that is followed when performing an httpClient.HEAD (up to 10 redirects are followed).  You'll need to return the url from the request after it follows all of the redirects.