Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AndroidHttpClient and DefaultHttpClient

Tags:

java

android

Is there much difference between those two and which one is preferably to use?

like image 738
Eugene Avatar asked Feb 27 '11 21:02

Eugene


3 Answers

Based on the Android source code:

https://github.com/CyanogenMod/android_frameworks_base/blob/gingerbread/core/java/android/net/http/AndroidHttpClient.java#L106

AndroidHttpClient is set to do the following extra settings:

  1. Turn off stale checking, since the connections can break all the time.
  2. Set ConnectionTimeout and SoTimeout (20 or 60 seconds)
  3. Turn off redirecting.
  4. Use a session cache for SSL sockets.
  5. Use gzip compressed traffic between client and server if it's possible.
  6. Doesn't retain cookies by default.
like image 71
dancefire Avatar answered Oct 12 '22 22:10

dancefire


AndroidHttpClient: Subclass of the Apache DefaultHttpClient that is configured with reasonable default settings and registered schemes for Android, and also lets the user add HttpRequestInterceptor classes. This client processes cookies but does not retain them by default. To retain cookies, simply add a cookie store to the HttpContext

[API]

like image 40
Arve Avatar answered Oct 13 '22 00:10

Arve


This interesting blog post from an android developer gives an overview of the different Android’s HTTP clients.

According to this post, URLConnection should be preferred over DefaultHttpClient or AndroidHttpClient on Gingerbread and above.

like image 35
dcoz Avatar answered Oct 12 '22 23:10

dcoz