Search in sources :

Example 1 with RequestDirector

use of org.apache.http.client.RequestDirector in project robovm by robovm.

the class AbstractHttpClient method execute.

// non-javadoc, see interface HttpClient
public final HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException {
    if (request == null) {
        throw new IllegalArgumentException("Request must not be null.");
    }
    // a null target may be acceptable, this depends on the route planner
    // a null context is acceptable, default context created below
    HttpContext execContext = null;
    RequestDirector director = null;
    // all shared objects that are potentially threading unsafe.
    synchronized (this) {
        HttpContext defaultContext = createHttpContext();
        if (context == null) {
            execContext = defaultContext;
        } else {
            execContext = new DefaultedHttpContext(context, defaultContext);
        }
        // Create a director for this request
        director = createClientRequestDirector(getRequestExecutor(), getConnectionManager(), getConnectionReuseStrategy(), getConnectionKeepAliveStrategy(), getRoutePlanner(), getHttpProcessor().copy(), getHttpRequestRetryHandler(), getRedirectHandler(), getTargetAuthenticationHandler(), getProxyAuthenticationHandler(), getUserTokenHandler(), determineParams(request));
    }
    try {
        return director.execute(target, request, execContext);
    } catch (HttpException httpException) {
        throw new ClientProtocolException(httpException);
    }
}
Also used : RequestDirector(org.apache.http.client.RequestDirector) DefaultedHttpContext(org.apache.http.protocol.DefaultedHttpContext) DefaultedHttpContext(org.apache.http.protocol.DefaultedHttpContext) HttpContext(org.apache.http.protocol.HttpContext) HttpException(org.apache.http.HttpException) ClientProtocolException(org.apache.http.client.ClientProtocolException)

Example 2 with RequestDirector

use of org.apache.http.client.RequestDirector in project platform_external_apache-http by android.

the class AbstractHttpClient method execute.

// non-javadoc, see interface HttpClient
public final HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException {
    if (request == null) {
        throw new IllegalArgumentException("Request must not be null.");
    }
    // a null target may be acceptable, this depends on the route planner
    // a null context is acceptable, default context created below
    HttpContext execContext = null;
    RequestDirector director = null;
    // all shared objects that are potentially threading unsafe.
    synchronized (this) {
        HttpContext defaultContext = createHttpContext();
        if (context == null) {
            execContext = defaultContext;
        } else {
            execContext = new DefaultedHttpContext(context, defaultContext);
        }
        // Create a director for this request
        director = createClientRequestDirector(getRequestExecutor(), getConnectionManager(), getConnectionReuseStrategy(), getConnectionKeepAliveStrategy(), getRoutePlanner(), getHttpProcessor().copy(), getHttpRequestRetryHandler(), getRedirectHandler(), getTargetAuthenticationHandler(), getProxyAuthenticationHandler(), getUserTokenHandler(), determineParams(request));
    }
    try {
        return director.execute(target, request, execContext);
    } catch (HttpException httpException) {
        throw new ClientProtocolException(httpException);
    }
}
Also used : RequestDirector(org.apache.http.client.RequestDirector) DefaultedHttpContext(org.apache.http.protocol.DefaultedHttpContext) DefaultedHttpContext(org.apache.http.protocol.DefaultedHttpContext) HttpContext(org.apache.http.protocol.HttpContext) HttpException(org.apache.http.HttpException) ClientProtocolException(org.apache.http.client.ClientProtocolException)

Example 3 with RequestDirector

use of org.apache.http.client.RequestDirector in project XobotOS by xamarin.

the class AbstractHttpClient method execute.

// non-javadoc, see interface HttpClient
public final HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context) throws IOException, ClientProtocolException {
    if (request == null) {
        throw new IllegalArgumentException("Request must not be null.");
    }
    // a null target may be acceptable, this depends on the route planner
    // a null context is acceptable, default context created below
    HttpContext execContext = null;
    RequestDirector director = null;
    // all shared objects that are potentially threading unsafe.
    synchronized (this) {
        HttpContext defaultContext = createHttpContext();
        if (context == null) {
            execContext = defaultContext;
        } else {
            execContext = new DefaultedHttpContext(context, defaultContext);
        }
        // Create a director for this request
        director = createClientRequestDirector(getRequestExecutor(), getConnectionManager(), getConnectionReuseStrategy(), getConnectionKeepAliveStrategy(), getRoutePlanner(), getHttpProcessor().copy(), getHttpRequestRetryHandler(), getRedirectHandler(), getTargetAuthenticationHandler(), getProxyAuthenticationHandler(), getUserTokenHandler(), determineParams(request));
    }
    try {
        return director.execute(target, request, execContext);
    } catch (HttpException httpException) {
        throw new ClientProtocolException(httpException);
    }
}
Also used : RequestDirector(org.apache.http.client.RequestDirector) DefaultedHttpContext(org.apache.http.protocol.DefaultedHttpContext) DefaultedHttpContext(org.apache.http.protocol.DefaultedHttpContext) HttpContext(org.apache.http.protocol.HttpContext) HttpException(org.apache.http.HttpException) ClientProtocolException(org.apache.http.client.ClientProtocolException)

Aggregations

HttpException (org.apache.http.HttpException)3 ClientProtocolException (org.apache.http.client.ClientProtocolException)3 RequestDirector (org.apache.http.client.RequestDirector)3 DefaultedHttpContext (org.apache.http.protocol.DefaultedHttpContext)3 HttpContext (org.apache.http.protocol.HttpContext)3