Search in sources :

Example 1 with HttpClient

use of cz.msebera.android.httpclient.client.HttpClient in project android-async-http by loopj.

the class Redirect302Sample method getAsyncHttpClient.

@Override
public AsyncHttpClient getAsyncHttpClient() {
    AsyncHttpClient ahc = super.getAsyncHttpClient();
    HttpClient client = ahc.getHttpClient();
    if (client instanceof DefaultHttpClient) {
        Toast.makeText(this, String.format("redirects: %b\nrelative redirects: %b\ncircular redirects: %b", enableRedirects, enableRelativeRedirects, enableCircularRedirects), Toast.LENGTH_SHORT).show();
        ahc.setEnableRedirects(enableRedirects, enableRelativeRedirects, enableCircularRedirects);
    }
    return ahc;
}
Also used : HttpClient(cz.msebera.android.httpclient.client.HttpClient) DefaultHttpClient(cz.msebera.android.httpclient.impl.client.DefaultHttpClient) AsyncHttpClient(com.loopj.android.http.AsyncHttpClient) DefaultHttpClient(cz.msebera.android.httpclient.impl.client.DefaultHttpClient) AsyncHttpClient(com.loopj.android.http.AsyncHttpClient)

Example 2 with HttpClient

use of cz.msebera.android.httpclient.client.HttpClient in project cw-omnibus by commonsguy.

the class LoadThread method run.

@Override
public void run() {
    try {
        HttpClient client = HttpClientBuilder.create().setConnectionManager(new PoolingHttpClientConnectionManager()).build();
        HttpGet get = new HttpGet(SO_URL);
        try {
            String result = client.execute(get, new BasicResponseHandler());
            SOQuestions questions = new Gson().fromJson(result, SOQuestions.class);
            EventBus.getDefault().post(new QuestionsLoadedEvent(questions));
        } catch (IOException e) {
            Log.e(getClass().getSimpleName(), "Exception parsing JSON", e);
        }
    } catch (Exception e) {
        Log.e(getClass().getSimpleName(), "Exception parsing JSON", e);
    }
}
Also used : HttpClient(cz.msebera.android.httpclient.client.HttpClient) HttpGet(cz.msebera.android.httpclient.client.methods.HttpGet) BasicResponseHandler(cz.msebera.android.httpclient.impl.client.BasicResponseHandler) Gson(com.google.gson.Gson) IOException(java.io.IOException) IOException(java.io.IOException) PoolingHttpClientConnectionManager(cz.msebera.android.httpclient.impl.conn.PoolingHttpClientConnectionManager)

Aggregations

HttpClient (cz.msebera.android.httpclient.client.HttpClient)2 Gson (com.google.gson.Gson)1 AsyncHttpClient (com.loopj.android.http.AsyncHttpClient)1 HttpGet (cz.msebera.android.httpclient.client.methods.HttpGet)1 BasicResponseHandler (cz.msebera.android.httpclient.impl.client.BasicResponseHandler)1 DefaultHttpClient (cz.msebera.android.httpclient.impl.client.DefaultHttpClient)1 PoolingHttpClientConnectionManager (cz.msebera.android.httpclient.impl.conn.PoolingHttpClientConnectionManager)1 IOException (java.io.IOException)1