Comments (2)
请看这个方法的JavaDoc,这个方法的意思是Http层面的请求成功,表示请求途中没有发生任何问题,和服务器通信成功。http的状态码有很多,200段、300段、400段、500段都可能是成功,服务器可以自定义这些状态码的,你所说的成功是你们业务的成功,所以需要你自己根据你们服务器约定的成功状态码来判断是否真正的成功,比如我们服务器约定的响应码是200才是成功,我是这样做的:
if(response.responseCode == 200) {
...
}
这里建议你看下ReadMe中NoHttp自定义请求的介绍,在onParseResponse方法中解析数据,并做状态码的判断,可以封装返回适合自己的业务的数据,在那里解析数据失败了可以抛出一个异常,NoHttp会自动回调onFailed()
方法的。当然你也可以在每个onSucceed()
中判断服务器数据返回是否正确(一般是解析数据的时候正确解析说明格式、数据都正确)。
from nohttp.
行, 那我以后就用responseCode来判断了
from nohttp.
Related Issues (20)
- RequestQueue多并发实现问题
- 请求头部的添加,自动把键值的首字母改成大写 HOT 1
- 上传进度条问题new FileInputStream(file), "application/octet-stream" 如何设置上传进度条 HOT 1
- 上传请求的数据中包含list list里面是map数据,请问如何上传 HOT 5
- 你好问下表单提交file能拿到上传进度的回调吗
- 报错 v1.1.11 HOT 1
- 使用studio3.2版本在安卓9.0机型请求失败
- 多文件上传 bug HOT 1
- Ftp下载 HOT 1
- 不回调success,Debug发现报 java.util.concurrent.CancellationException
- 设置返回编码无效
- NoHttpSample: java.net.SocketException: socket failed: ENONET (Machine is not on the network)
- 支持https不
- 同步请求数据返回为 “”, 同样的url 异步请求没问题
- post请求中文乱码
- The network is not available, please check the network
- target 29 下载报权限异常 HOT 1
- NoHttpSample: okhttp3.internal.http2.StreamResetException: stream was reset: PROTOCOL_ERROR HOT 1
- 为什么下载后文件正常但是重启设备后文件的后缀多了.nohttp 导致文件异常
- 请求头部的添加,自动把键值的首字母改成大写 ,这个有方法避免吗
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nohttp.