最近,组长让把项目里的apache HTTP client换成HttpURLConnection,目的是减少apk的大小.
1,对HttpURLConnection不熟悉的,可以移步官方文档https://developer.android.com/reference/java/net/HttpURLConnection.html;
2,该类返回的InputStream和OutputStream是不带缓存的.多数情况下,调用者应当使用BufferedInputStream和BufferedOutputStream包裹返回的流;
3,当上传数据给服务器时,使用setDoOutput(true)来配置输出连接.为达到最优的性能,当请求体的长度已知时,可以调用setFixedLengthStreamingMode(int),或者当请求体的长度未知时,调用setChunkedStreamingMode(int)方法
4,GZIP的问题,自己还不明白...
参考连接:
1,http://droidyue.com/blog/2015/05/30/android-http-clients/
2,http://blog.csdn.net/woxueliuyun/article/details/43267365