由于提交数据和返回都是直接传递流,xutils 如何获取直接response.getEntity(); 需要直接读取。
看到httphanlder的handleResponse方法转成string了,直接获取inputstream应该如何操作
private ResponseInfo<T> handleResponse(HttpResponse response) throws HttpException, IOException { if (response == null) { throw new HttpException("response is null"); } if (isCancelled()) return null; StatusLine status = response.getStatusLine(); int statusCode = status.getStatusCode(); if (statusCode < 300) { Object result = null; HttpEntity entity = response.getEntity(); if (entity != null) { isUploading = false; if (isDownloadingFile) { autoResume = autoResume && OtherUtils.isSupportRange(response); String responseFileName = autoRename ? OtherUtils.getFileNameFromHttpResponse(response) : null; result = mFileDownloadHandler.handleEntity(entity, this, fileSavePath, autoResume, responseFileName); } else { result = mStringDownloadHandler.handleEntity(entity, this, charset); if (HttpUtils.sHttpCache.isEnabled(requestMethod)) { HttpUtils.sHttpCache.put(requestUrl, (String) result, expiry); } } } return new ResponseInfo<T>(response, (T) result, false); } else if (statusCode == 301 || statusCode == 302) { if (httpRedirectHandler == null) { httpRedirectHandler = new DefaultHttpRedirectHandler(); } HttpRequestBase request = httpRedirectHandler.getDirectRequest(response); if (request != null) { return this.sendRequest(request); } } else if (statusCode == 416) { throw new HttpException(statusCode, "maybe the file has downloaded completely"); } else { throw new HttpException(statusCode, status.getReasonPhrase()); } return null; }
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。