Example usage for org.apache.http.client.methods HttpUriRequest isAborted

List of usage examples for org.apache.http.client.methods HttpUriRequest isAborted

Introduction

In this page you can find the example usage for org.apache.http.client.methods HttpUriRequest isAborted.

Prototype

boolean isAborted();

Source Link

Document

Tests if the request execution has been aborted.

Usage

From source file:com.soundcloud.playerapi.ApiWrapper.java

public HttpResponse safeExecute(HttpHost target, HttpUriRequest request) throws IOException {
    if (target == null) {
        target = determineTarget(request);
    }//  w  ww  . j a v a  2  s.  c  om

    try {
        return getHttpClient().execute(target, request);
    } catch (NullPointerException e) {
        // this is a workaround for a broken httpclient version,
        // cf. http://code.google.com/p/android/issues/detail?id=5255
        // NPE in DefaultRequestDirector.java:456
        if (!request.isAborted() && request.getParams().isParameterFalse("npe-retried")) {
            request.getParams().setBooleanParameter("npe-retried", true);
            return safeExecute(target, request);
        } else {
            request.abort();
            throw new BrokenHttpClientException(e);
        }
    } catch (IllegalArgumentException e) {
        // more brokenness
        // cf. http://code.google.com/p/android/issues/detail?id=2690
        request.abort();
        throw new BrokenHttpClientException(e);
    } catch (ArrayIndexOutOfBoundsException e) {
        // Caused by: java.lang.ArrayIndexOutOfBoundsException: length=7; index=-9
        // org.apache.harmony.security.asn1.DerInputStream.readBitString(DerInputStream.java:72))
        // org.apache.harmony.security.asn1.ASN1BitString.decode(ASN1BitString.java:64)
        // ...
        // org.apache.http.conn.ssl.SSLSocketFactory.createSocket(SSLSocketFactory.java:375)
        request.abort();
        throw new BrokenHttpClientException(e);
    }
}