Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http神器组件Retrofit的使用(四)——忽略body的表达 #135

Open
soapgu opened this issue Apr 19, 2022 · 0 comments
Open

Http神器组件Retrofit的使用(四)——忽略body的表达 #135

soapgu opened this issue Apr 19, 2022 · 0 comments
Labels
安卓 安卓

Comments

@soapgu
Copy link
Owner

soapgu commented Apr 19, 2022

  • 怎么处理无数据的返回?

针对RxJava的适配
可以参考下文档

  • Observable, Observable<Response>, and Observable<Result> where T is the body type.

  • Flowable, Flowable<Response> and Flowable<Result> where T is the body type.

  • Single, Single<Response>, and Single<Result> where T is the body type.

  • Maybe, Maybe<Response>, and Maybe<Result> where T is the body type.

  • Completable where response bodies are discarded.
    对于不关心返回数据的可以直接用Completable

  • 状态码和结果的关联性

那针对状态码204,是判定为成功吗?
回答是是!
参考源码
图片
对于状态码成功的判断,是照抄okhttp3.Response
源码不翻了,有文档先看文档吧
图片
OK,状态码是2XX的都判成功,放心了。

模拟器和本机是一个小型内置局域网,本机能访问的问题,安卓模拟器访问都没问题。
一直以来相安无事
这次问题来了。我安卓要连本机的服务
一开始我用localhost,显然不行,localhost不是安卓本机嘛。
查下资料。
所有本机的IP都会解析为 10.0.2.2

@soapgu soapgu added the 安卓 安卓 label Apr 19, 2022
@soapgu soapgu changed the title Http神器组件Retrofit的使用(四) Http神器组件Retrofit的使用(四)——忽略body的表达 Apr 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
安卓 安卓
Projects
None yet
Development

No branches or pull requests

1 participant