从HttpClient 3转换为4

Jen*_*nny 10 java apache-commons-httpclient

我设法对以下所有内容进行了更改:

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

InputStream rstream;
try {
    rstream = method.getResponseBodyAsStream();
} catch (IOException e) {
    return BadSpot(e.getMessage()); 
}
Run Code Online (Sandbox Code Playgroud)

我不确定的是我应该替换getResponseBodyAsStream().

fmu*_*car 5

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

以上应该做你所要求的。