Package org.apache.http.params

Examples of org.apache.http.params.DefaultedHttpParams


            HttpResponse response = this.responseFactory.newHttpResponse(
                    HttpVersion.HTTP_1_0,
                    HttpStatus.SC_INTERNAL_SERVER_ERROR,
                    context);
            response.setParams(
                    new DefaultedHttpParams(response.getParams(), this.params));
            handleException(httpex, response);
            response.setEntity(null);
           
            this.httpProcessor.process(response, context);
           
View Full Code Here


            connState.setInputState(ServerConnState.REQUEST_RECEIVED);
            connState.setRequest(request);
            connState.setWorkerRunning(true);
        }

        request.setParams(new DefaultedHttpParams(request.getParams(), this.params));

        context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        context.setAttribute(ExecutionContext.HTTP_REQUEST, request);

        ProtocolVersion ver = request.getRequestLine().getProtocolVersion();

        if (!ver.lessEquals(HttpVersion.HTTP_1_1)) {
            // Downgrade protocol version if greater than HTTP/1.1
            ver = HttpVersion.HTTP_1_1;
        }

        HttpResponse response = null;

        if (request instanceof HttpEntityEnclosingRequest) {
            HttpEntityEnclosingRequest eeRequest = (HttpEntityEnclosingRequest) request;
           
            if (eeRequest.expectContinue()) {
                response = this.responseFactory.newHttpResponse(
                        ver,
                        HttpStatus.SC_CONTINUE,
                        context);
                response.setParams(
                        new DefaultedHttpParams(response.getParams(), this.params));
                if (this.expectationVerifier != null) {
                    try {
                        this.expectationVerifier.verify(request, response, context);
                    } catch (HttpException ex) {
                        response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0,
                                HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
                        response.setParams(
                                new DefaultedHttpParams(response.getParams(), this.params));
                        handleException(ex, response);
                    }
                }
           
                if (response.getStatusLine().getStatusCode() < 200) {
                   
                    // Send 1xx response indicating the server expections
                    // have been met
                    synchronized (connState) {
                        connState.setResponse(response);
                        conn.requestOutput();
                       
                        // Block until 1xx response is sent to the client
                        try {
                            for (;;) {
                                int currentState = connState.getOutputState();
                                if (currentState == ServerConnState.RESPONSE_SENT) {
                                    break;
                                }
                                if (currentState == ServerConnState.SHUTDOWN) {
                                    return;
                                }
                                connState.wait();
                            }
                        } catch (InterruptedException ex) {
                            connState.shutdown();
                            return;
                        }
                        connState.resetOutput();
                        response = null;
                    }
                } else {
                    // Discard request entity
                    conn.resetInput();
                    eeRequest.setEntity(null);
                }

            }

            // Create a wrapper entity instead of the original one
            if (eeRequest.getEntity() != null) {
                eeRequest.setEntity(new ContentBufferEntity(
                        eeRequest.getEntity(),
                        connState.getInbuffer()));
            }
           
        }

        if (response == null) {
            response = this.responseFactory.newHttpResponse(
                    ver,
                    HttpStatus.SC_OK,
                    context);
            response.setParams(
                    new DefaultedHttpParams(response.getParams(), this.params));

            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
           
            try {

                this.httpProcessor.process(request, context);

                HttpRequestHandler handler = null;
                if (this.handlerResolver != null) {
                    String requestURI = request.getRequestLine().getUri();
                    handler = this.handlerResolver.lookup(requestURI);
                }
                if (handler != null) {
                    handler.handle(request, response, context);
                } else {
                    response.setStatusCode(HttpStatus.SC_NOT_IMPLEMENTED);
                }

            } catch (HttpException ex) {
                response = this.responseFactory.newHttpResponse(HttpVersion.HTTP_1_0,
                        HttpStatus.SC_INTERNAL_SERVER_ERROR, context);
                response.setParams(
                        new DefaultedHttpParams(response.getParams(), this.params));
                handleException(ex, response);
            }
        }

        this.httpProcessor.process(response, context);
View Full Code Here

                if (request == null) {
                    return;
                }
               
                request.setParams(
                        new DefaultedHttpParams(request.getParams(), this.params));
               
                context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
                this.httpProcessor.process(request, context);
                connState.setRequest(request);
                conn.submitRequest(request);
View Full Code Here

        try {
           
            synchronized (connState) {
                HttpResponse response = conn.getHttpResponse();
                response.setParams(
                        new DefaultedHttpParams(response.getParams(), this.params));
               
                HttpRequest request = connState.getRequest();
               
                int statusCode = response.getStatusLine().getStatusCode();
                if (statusCode < HttpStatus.SC_OK) {
View Full Code Here

            ConnState connState = (ConnState) context.getAttribute(CONN_STATE);
           
            HttpResponse response =  this.responseFactory.newHttpResponse(
                    HttpVersion.HTTP_1_0, HttpStatus.SC_BAD_REQUEST, context);
            response.setParams(
                    new DefaultedHttpParams(response.getParams(), this.params));
           
            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
            context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
           
            try {
View Full Code Here

                final NHttpServerConnection conn,
                final ConnState connState) throws HttpException, IOException {
            HttpContext context = conn.getContext();
            HttpRequest request = conn.getHttpRequest();
            request.setParams(
                    new DefaultedHttpParams(request.getParams(), this.params));

            if (request instanceof HttpEntityEnclosingRequest) {
                HttpEntityEnclosingRequest eeRequest = (HttpEntityEnclosingRequest) request;
                Header h = request.getFirstHeader(HTTP.CONTENT_TYPE);
                String contentType = null;
                if (h != null) {
                    contentType = h.getValue();
                }
                HttpNIOEntity entity = new FileNIOEntity(connState.getInputFile(), contentType);
                eeRequest.setEntity(entity);
            }
           
            ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
            HttpResponse response =  this.responseFactory.newHttpResponse(ver, 200, context);
            response.setParams(
                    new DefaultedHttpParams(response.getParams(), this.params));
           
            context.setAttribute(ExecutionContext.HTTP_REQUEST, request);
            context.setAttribute(ExecutionContext.HTTP_RESPONSE, response);
            context.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
View Full Code Here

        ctxt.setAttribute(ExecutionContext.HTTP_CONNECTION, conn);
        ctxt.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
        ctxt.setAttribute(ExecutionContext.HTTP_REQUEST, req);

        req.setParams(new DefaultedHttpParams(req.getParams(), params));
        exec.preProcess(req, proc, ctxt);
        HttpResponse rsp = exec.execute(req, conn, ctxt);
        rsp.setParams(new DefaultedHttpParams(rsp.getParams(), params));
        exec.postProcess(rsp, proc, ctxt);

        return rsp;
    }
View Full Code Here

             new ClientParamsStack(null, child, dummy, null),
             null);
        assertNull("2", ConnRouteParams.getDefaultProxy(hierarchy));

        hierarchy = new ClientParamsStack
            (null, daddy, new DefaultedHttpParams(child, dummy), null);
        assertNull("3", ConnRouteParams.getDefaultProxy(hierarchy));

        hierarchy = new DefaultedHttpParams(child, daddy);
        assertNull("4", ConnRouteParams.getDefaultProxy(hierarchy));

        hierarchy = new DefaultedHttpParams
            (new DefaultedHttpParams(child, dummy), daddy);
        assertNull("5", ConnRouteParams.getDefaultProxy(hierarchy));

        hierarchy = new DefaultedHttpParams
            (child, new DefaultedHttpParams(dummy, daddy));
        assertNull("6", ConnRouteParams.getDefaultProxy(hierarchy));
    }
View Full Code Here

                ExecutionContext.HTTP_TARGET_HOST, target);
        httpContext.setAttribute(
                ExecutionContext.HTTP_REQUEST, request);

        request.setParams(
                new DefaultedHttpParams(request.getParams(), defaultParams));
        httpExecutor.preProcess
            (request, httpProcessor, httpContext);
        HttpResponse response = httpExecutor.execute
            (request, conn, httpContext);
        response.setParams(
                new DefaultedHttpParams(response.getParams(), defaultParams));
        httpExecutor.postProcess
            (response, httpProcessor, httpContext);

        assertEquals("wrong status in response", HttpStatus.SC_OK,
                     response.getStatusLine().getStatusCode());
View Full Code Here

                    ExecutionContext.HTTP_TARGET_HOST, target);
            httpContext.setAttribute(
                    ExecutionContext.HTTP_REQUEST, request);

            request.setParams(
                    new DefaultedHttpParams(request.getParams(), defaultParams));
            httpExecutor.preProcess
                (request, httpProcessor, httpContext);
            HttpResponse response = httpExecutor.execute
                (request, conn, httpContext);
            response.setParams(
                    new DefaultedHttpParams(response.getParams(), defaultParams));
            httpExecutor.postProcess
                (response, httpProcessor, httpContext);

            assertEquals("(" + sizes[i] + ") wrong status in response",
                         HttpStatus.SC_OK,
View Full Code Here

TOP

Related Classes of org.apache.http.params.DefaultedHttpParams

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.