我刚刚开始使用 Apache 的 HTTP 客户端库,并注意到没有将 HTTP 响应作为字符串获取的内置方法。我只是想把它作为字符串来获取,这样我就可以将它传递给我正在使用的任何解析库。
将 HTTP 响应作为字符串获取的推荐方法是什么?这是我提出请求的代码:
public String doGet(String strUrl, List<NameValuePair> lstParams) {
    String strResponse = null;
    try {
        HttpGet htpGet = new HttpGet(strUrl);
        htpGet.setEntity(new UrlEncodedFormEntity(lstParams));
        DefaultHttpClient dhcClient = new DefaultHttpClient();
        PersistentCookieStore pscStore = new PersistentCookieStore(this);
        dhcClient.setCookieStore(pscStore);
        HttpResponse resResponse = dhcClient.execute(htpGet);
        //strResponse = getResponse(resResponse);
    } catch (ClientProtocolException e) {
        throw e;
    } catch (IOException e) {
        throw e;
    }
    return strResponse;
}