While issuing a GET request using Apache HTTP Client v4, how do I obtain the response media type (formally MIME type)?
Using Apache HTTP Client v3, the MIME type was obtained with:
String mimeType = response.getMimeType();
How do I get the media type using Apache HTTP Client v4?
A “Content-type” HTTP header should give you mime type information:
or as
Then you can extract mime type itself as the content-type may include encoding as well.
Of course, don’t forget about null-check before getting value of the header (in case the content-type header is not sent by server).