FileDocCategorySizeDatePackage
TestHttpClient.javaAPI DocAndroid 5.1 API5024Thu Mar 12 22:22:42 GMT 2015android.core

TestHttpClient

public class TestHttpClient extends Object

Fields Summary
private final HttpParams
params
private final BasicHttpProcessor
httpproc
private final HttpRequestExecutor
httpexecutor
private final ConnectionReuseStrategy
connStrategy
private final HttpContext
context
Constructors Summary
public TestHttpClient()

        super();
        this.params = new BasicHttpParams();
        this.params
            .setIntParameter(CoreConnectionPNames.SO_TIMEOUT, 5000)
            .setBooleanParameter(CoreConnectionPNames.STALE_CONNECTION_CHECK, false)
            .setParameter(CoreProtocolPNames.PROTOCOL_VERSION, HttpVersion.HTTP_1_1)
            .setParameter(CoreProtocolPNames.USER_AGENT, "TEST-CLIENT/1.1");

        this.httpproc = new BasicHttpProcessor();
        // Required protocol interceptors
        this.httpproc.addInterceptor(new RequestContent());
        this.httpproc.addInterceptor(new RequestTargetHost());
        // Recommended protocol interceptors
        this.httpproc.addInterceptor(new RequestConnControl());
        this.httpproc.addInterceptor(new RequestUserAgent());
        this.httpproc.addInterceptor(new RequestExpectContinue());

        this.httpexecutor = new HttpRequestExecutor();
        this.connStrategy = new DefaultConnectionReuseStrategy();
        this.context = new BasicHttpContext(null);
    
Methods Summary
public org.apache.http.HttpResponseexecute(org.apache.http.HttpRequest request, org.apache.http.HttpHost targetHost, org.apache.http.HttpClientConnection conn)

        this.context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
        this.context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, targetHost);
        this.context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        request.setParams(
                    new DefaultedHttpParams(request.getParams(), this.params));
        this.httpexecutor.preProcess(request, this.httpproc, this.context);
        HttpResponse response = this.httpexecutor.execute(request, conn, this.context);
        response.setParams(
                new DefaultedHttpParams(response.getParams(), this.params));
        this.httpexecutor.postProcess(response, this.httpproc, this.context);
        return response;
    
public org.apache.http.params.HttpParamsgetParams()

        return this.params;
    
public booleankeepAlive(org.apache.http.HttpResponse response)

        return this.connStrategy.keepAlive(response, this.context);