Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting from HttpClient 3 to 4

I've managed to make changes to everything but the following:

HttpClient client;
HttpPost method;   
client = new DefaultHttpClient();
method = new HttpPost(url); 

InputStream rstream;
try {
    rstream = method.getResponseBodyAsStream();
} catch (IOException e) {
    return BadSpot(e.getMessage()); 
}

What I'm not sure of is what I should replace getResponseBodyAsStream() with.

like image 962
Jenny Avatar asked Jan 04 '11 22:01

Jenny


2 Answers

InputStream rstream;
try {
    HttpResponse response = client.execute(HttpHost, method);
    rstream = response.getEntity().getContent();
} catch (IOException e) {
    return BadSpot(e.getMessage()); 
}

above should do what you are asking.

like image 101
fmucar Avatar answered Oct 13 '22 05:10

fmucar


HttpResponse.getEntity(), followed by HttpEntity.getContent()

like image 30
Anon Avatar answered Oct 13 '22 07:10

Anon