使用缓冲区将http请求响应转换为Android中的字符串 - 未获得完整响应

Col*_*non 1 string android httpresponse buffer-overflow bufferedreader

我正在开发一个发布到网站的应用程序,我正在尝试将实体响应存储为字符串.但是,字符串似乎只包含一小部分响应,大约35行左右.我想知道它是否与缓冲区溢出有关但我真的不确定.我的代码如下:

static String getResponseBody(HttpResponse response) throws IllegalStateException, IOException{

    String content = null;
    HttpEntity entity = response.getEntity();

    if (entity != null) 
    {
        InputStream is = entity.getContent();
        BufferedReader br = new BufferedReader(new InputStreamReader(is));
        StringBuilder sb = new StringBuilder();
        String line = null;

        while ((line = br.readLine()) != null) 
        {
            if(isBlankString(line) == false)
            {
            sb.append(line + "\n");
            }
        }
        br.close();
        content = sb.toString();
    }
    return content; 
Run Code Online (Sandbox Code Playgroud)

isBlankString只是注意一条线是否包含任何字符,因为响应中有很多空白行让我烦恼.我有一个问题,即无论有没有得到整个回应.任何人都知道发生了什么或如何解决这个问题?

谢谢

GrA*_*And 8

在我的应用程序中,我只使用单行来从实体获取响应字符串:

final String responseText =  EntityUtils.toString(response.getEntity());
Run Code Online (Sandbox Code Playgroud)