Is AndroidHttpClient thread safe

I was wondering if AndroidHttpClient is thread safe since this is not mentioned in the documentation. This means that one instance of AndroidHttpClient can be shared between multiple threads.

+4
source share
3 answers

Yes, it is thread safe.

AndroidHttpClient is a special implementation of DefaultHttpClient that is preconfigured for Android. It registers ThreadSafeClientConnManager , which allows thread-safe HTTP access through a pool of managed connections. AndroidHttpClient also applies reasonable default settings for timeouts and socket buffer sizes. It also supports HTTPS by default.

You can find the source code here .

+9
source

This is a safe thread according to the code as it uses

 ClientConnectionManager manager = new ThreadSafeClientConnManager(params, schemeRegistry); 

by source

The only drawback to this is that the Api level is 8 or higher (2.2.x)

+2
source

Yes, it is thread safe. Also, be sure to use the factory method:

 newInstance(String userAgent, Context context) 

when used with HTTPS to provide caching of SSL sessions.

+2
source

All Articles