-
Notifications
You must be signed in to change notification settings - Fork 0
Home
wangchen edited this page Mar 20, 2017
·
53 revisions
####本项目的目的是学习研究并最终实现基于Retrofit OkHttp 和RxJava Gson的Android 网络请求库
- 实现AuthToken的过期和二次自动获取机制 100%
- 实现基础的参数的自动加入 100%
- 实现参数的加密和签名 100%
- 支持GET POST 以及文件传输 60%
- 实现一个NodeJs Server 模拟真实的服务器 100%
- 方便的支持Mock 40%
- 支持自定义Cache 100%
###URL Connection和 OkHttp 之间的关系 首先是conn = (HttpURLConnection) myUrl.openConnection();
public URLConnection openConnection() throws IOException {
return streamHandler.openConnection(this);
} /**
* Sets the stream handler factory for this VM.
*
* @throws Error if a URLStreamHandlerFactory has already been installed
* for the current VM.
*/
public static synchronized void setURLStreamHandlerFactory(URLStreamHandlerFactory factory) {
if (streamHandlerFactory != null) {
throw new Error("Factory already set");
}
streamHandlers.clear();
streamHandlerFactory = factory;
} void setupStreamHandler() {
// Check for a cached (previously looked up) handler for
// the requested protocol.
streamHandler = streamHandlers.get(protocol);
if (streamHandler != null) {
return;
}
if (protocol.equals("http")) {
try {
String name = "com.android.okhttp.HttpHandler";
streamHandler = (URLStreamHandler) Class.forName(name).newInstance();
} catch (Exception e) {
throw new AssertionError(e);
}
} else if (protocol.equals("https")) {
try {
String name = "com.android.okhttp.HttpsHandler";
streamHandler = (URLStreamHandler) Class.forName(name).newInstance();
} catch (Exception e) {
throw new AssertionError(e);
}
} else if (protocol.equals("jar")) {
streamHandler = new JarHandler();
}
if (streamHandler != null) {
streamHandlers.put(protocol, streamHandler);
}
}怎么统计网络请求时间?
###什么是Retrofit 它 的使用方法API 简介
- Retrofit 是Square公司提供的高效的Http库
###内部原理
###项目代码分析
依赖和参考项目
- https://github.com/alighters/AndroidDemos
- npm modules express body-parser
参考文献 http://expressjs.com/ https://github.com/alighters/AndroidDemos