Package org.apache.http.protocol

Examples of org.apache.http.protocol.HttpExecutionContext


        this.httpproc.addInterceptor(new RequestExpectContinue());

        this.httpexecutor = new HttpRequestExecutor(this.httpproc);
        this.httpexecutor.setParams(this.params);
        this.connStrategy = new DefaultConnectionReuseStrategy();
        this.context = new HttpExecutionContext(null);
    }
View Full Code Here


    public void setUp() {
        // open and not stale is required for most of the tests here
        mockConnection = new MockConnection(true, false);
        reuseStrategy = new DefaultConnectionReuseStrategy();
        context = new HttpExecutionContext(null);
        context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, mockConnection);
    }
View Full Code Here

        junit.textui.TestRunner.main(testCaseName);
    }

    public void testIllegalResponseArg() throws Exception {

        HttpContext context = new HttpExecutionContext(null);

        try {
            reuseStrategy.keepAlive(null, context);
            fail("IllegalArgumentException should have been thrown");
        } catch (IllegalArgumentException ex) {
View Full Code Here

            this.conn = conn;
        }
       
        public void run() {
            System.out.println("New connection thread");
            HttpContext context = new HttpExecutionContext(null);
            try {
                while (!Thread.interrupted() && this.conn.isOpen()) {
                    this.httpservice.handleRequest(this.conn, context);
                }
            } catch (ConnectionClosedException ex) {
View Full Code Here

        httpproc.addInterceptor(new RequestUserAgent());
        httpproc.addInterceptor(new RequestExpectContinue());
       
        HttpRequestExecutor httpexecutor = new HttpRequestExecutor();

        HttpContext context = new HttpExecutionContext(null);
       
        HttpHost host = new HttpHost("localhost", 8080);
       
        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
        ConnectionReuseStrategy connStrategy = new DefaultConnectionReuseStrategy();

        context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);

        try {
           
            HttpEntity[] requestBodies = {
                    new StringEntity(
                            "This is the first test request", "UTF-8"),
                    new ByteArrayEntity(
                            "This is the second test request".getBytes("UTF-8")),
                    new InputStreamEntity(
                            new ByteArrayInputStream(
                                    "This is the third test request (will be chunked)"
                                    .getBytes("UTF-8")), -1)
            };
           
            for (int i = 0; i < requestBodies.length; i++) {
                if (!conn.isOpen()) {
                    Socket socket = new Socket(host.getHostName(), host.getPort());
                    conn.bind(socket, params);
                }
                BasicHttpEntityEnclosingRequest request = new BasicHttpEntityEnclosingRequest("POST",
                        "/servlets-examples/servlet/RequestInfoExample");
                request.setEntity(requestBodies[i]);
                System.out.println(">> Request URI: " + request.getRequestLine().getUri());

                context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
                request.setParams(params);
                httpexecutor.preProcess(request, httpproc, context);
                HttpResponse response = httpexecutor.execute(request, conn, context);
                httpexecutor.postProcess(response, httpproc, context);
               
View Full Code Here

        httpproc.addInterceptor(new RequestUserAgent());
        httpproc.addInterceptor(new RequestExpectContinue());

        HttpRequestExecutor httpexecutor = new HttpRequestExecutor();
       
        HttpContext context = new HttpExecutionContext(null);
        HttpHost host = new HttpHost("localhost", 8080);

        DefaultHttpClientConnection conn = new DefaultHttpClientConnection();
        ConnectionReuseStrategy connStrategy = new DefaultConnectionReuseStrategy();

        context.setAttribute(HttpExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(HttpExecutionContext.HTTP_TARGET_HOST, host);

        try {
           
            String[] targets = {
                    "/",
                    "/servlets-examples/servlet/RequestInfoExample",
                    "/somewhere%20in%20pampa"};
           
            for (int i = 0; i < targets.length; i++) {
                if (!conn.isOpen()) {
                    Socket socket = new Socket(host.getHostName(), host.getPort());
                    conn.bind(socket, params);
                }
                BasicHttpRequest request = new BasicHttpRequest("GET", targets[i]);
                System.out.println(">> Request URI: " + request.getRequestLine().getUri());
               
                context.setAttribute(HttpExecutionContext.HTTP_REQUEST, request);
                request.setParams(params);
                httpexecutor.preProcess(request, httpproc, context);
                HttpResponse response = httpexecutor.execute(request, conn, context);
                httpexecutor.postProcess(response, httpproc, context);
               
View Full Code Here

    }


    public void run() {
        LOG.debug("New connection thread");
        HttpContext context = new HttpExecutionContext(null);
        try {
            while (! Thread.interrupted() && ! isDestroyed() && this.conn.isOpen()) {
                this.httpservice.handleRequest(this.conn, context);
            }
        } catch (ConnectionClosedException ex) {
View Full Code Here

     * the context can be left empty.
     *
     * @return  a new, empty context
     */
    private final static HttpContext createContext() {
        return new HttpExecutionContext(null);
    }
View Full Code Here

     * the context can be left empty.
     *
     * @return  a new, empty context
     */
    private final static HttpContext createContext() {
        return new HttpExecutionContext(null);
    }
View Full Code Here

     * the context can be left empty.
     *
     * @return  a new, empty context
     */
    private final static HttpContext createContext() {
        return new HttpExecutionContext(null);
    }
View Full Code Here

TOP

Related Classes of org.apache.http.protocol.HttpExecutionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.