android-lite-http处理http异常返回时的content数据读取
来源:互联网 发布:汉仪字体淘宝侵权 编辑:程序博客网 时间:2024/06/14 20:45
背景:如果是http异常返回,android-lite-http返回的信息里面没有response的content数据,需要简单添加点东西
1、修改类HttpException.java 增加变量
private String content;public String getContent() { return content;}public void setContent(String content) { this.content = content;}
2、修改类HttpUrlClient.java
// } else if (statusCode <= 499) {// // 客户端被拒// throw new HttpServerException(httpStatus);// } else if (statusCode < 599) {// // 服务器有误// throw new HttpServerException(httpStatus);// } } else if (statusCode < 599) { // 客户端被拒/服务器有误 String charSet = getCharsetByContentType(response.getContentType(), request.getCharSet()); response.setCharSet(charSet); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, charSet)); String temp = null; StringBuilder content = new StringBuilder(); while ((temp = reader.readLine()) != null) { content.append(temp); } inputStream = null; HttpServerException httpServerException = new HttpServerException(httpStatus); httpServerException.setContent(content.toString()); throw httpServerException; }
0 0
- android-lite-http处理http异常返回时的content数据读取
- android-async-http开源项目对服务器端返回JSON数据的处理
- android-async-http开源项目对服务器端返回JSON数据的处理
- android-async-http开源项目对服务器端返回JSON数据的处理
- 处理HTTP请求并返回JSON数据的类
- Socket模拟Http协议,读取http header,根据content-length的值,读取Http body
- HTTP 读取数据的错误代码
- android使用Http的Get方式读取网络数据
- Android程序:使用Http的Get方式读取网络数据
- android 使用Http的Get方式读取网络数据
- android 使用Http的POST方式读取网络数据
- 对于dotnet中返回404后继续读取http的内容的处理
- Android里的HTTP异常
- android使用HTTP协议读取数据
- WCF HTTP异常处理
- go http异常处理
- Http常见返回数据
- JAVA 获取http返回XML的数据
- ccf2014031
- react学习笔记 item9 ---双向绑定(mixin)
- servlet
- 操作系统库-atoi()函数
- 工厂设计模式
- android-lite-http处理http异常返回时的content数据读取
- js学习笔记:Ajax
- 老毛桃U盘快速安装ghost win7系统图文教程
- React Native环境配置(android,windows)
- 11.23关于微信JSAPI缺少参数的问题解决
- Android之第三方框架使用汇总
- mysql中字段类型及字符集
- nyoj1112-求次数(map或set)
- BP神经网络原理推到&代码实现