Arvind
Arvind

Reputation: 6474

java- apache http client v4.x- how to extract different elements of response from HTTPResponse object

I am working with the Apache HTTP Client and trying to extract content from the response...

I have the response in a HTTP Response object named 'response'.

Now, how do I extract the following from the HTTPResponse object??--

(1) Response content as byte[] (2) Content length (3) Mime type (4) Charset

Upvotes: 0

Views: 547

Answers (2)

Jacob
Jacob

Reputation: 609

HttpEntity entity = response.getEntity();
InputStream instream = entity.getContent();
instream.read();

That's the main codes. You can see the examples in:httpcomponents-client-4.1.3\examples\org\apache\http\examples\client

Upvotes: 1

kosa
kosa

Reputation: 66637

You need to get HttpEntity and do getContentLenght() and getContentType();. Here is apache tutorial

Upvotes: 1

Related Questions