Package org.eclipse.jetty.server

Examples of org.eclipse.jetty.server.Request


    private int _confidentialPort;
   
    protected Session(HttpServletRequest httpServletRequest)
        {
           super(httpServletRequest);
           Request request = (Request) httpServletRequest;
           _serverName = request.getServerName();
           _scheme = request.getScheme();
           _confidentialPort = ((Request) request).getConnection().getConnector().getConfidentialPort();
           _port = request.getServerPort();
           updateSession(request);
          
        }
View Full Code Here


                             HttpServletRequest req,
                             HttpServletResponse resp) throws IOException {
        if (context == null) {
            context = servletContext;
        }
        Request baseRequest = (req instanceof Request)
            ? (Request)req : getCurrentRequest();
           
        if (!"HEAD".equals(req.getMethod())) {
            //bug in Jetty with persistent connections that if a HEAD is
            //sent, a _head flag is never reset
            AbstractConnection c = getConnectionForRequest(baseRequest);
            if (c != null) {
                setHeadFalse(c);
            }
        }
        if (getServer().isSetRedirectURL()) {
            resp.sendRedirect(getServer().getRedirectURL());
            resp.flushBuffer();
            baseRequest.setHandled(true);
            return;
        }
        QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
       
        if (null != req.getQueryString() && queryHandlerRegistry != null) {  
            String reqAddr = req.getRequestURL().toString();
            String requestURL =  reqAddr + "?" + req.getQueryString();
            String pathInfo = req.getPathInfo();                    
            for (QueryHandler qh : queryHandlerRegistry.getHandlers()) {
                boolean recognized =
                    qh instanceof StemMatchingQueryHandler
                    ? ((StemMatchingQueryHandler)qh).isRecognizedQuery(requestURL,
                                                                       pathInfo,
                                                                       endpointInfo,
                                                                       contextMatchOnExact())
                    : qh.isRecognizedQuery(requestURL, pathInfo, endpointInfo);
                if (recognized) {
                    //replace the endpointInfo address with request url only for get wsdl
                    String errorMsg = null;
                    CachedOutputStream out = new CachedOutputStream();
                    try {
                        synchronized (endpointInfo) {
                            String oldAddress = updateEndpointAddress(reqAddr);  
                            resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
                            try {
                                qh.writeResponse(requestURL, pathInfo, endpointInfo, out);
                            } catch (Exception ex) {
                                LOG.log(Level.WARNING, "writeResponse failed: ", ex);
                                errorMsg = ex.getMessage();
                            }
                            endpointInfo.setAddress(oldAddress);
                        }
                        if (errorMsg != null) {
                            resp.sendError(500, errorMsg);
                        } else {
                            out.writeCacheTo(resp.getOutputStream());
                            resp.getOutputStream().flush();                    
                        }
                    } finally {
                        out.close();
                    }
                    baseRequest.setHandled(true);
                    return;
                }
            }
        }
View Full Code Here

    protected void serviceRequest(final ServletContext context,
                                  final HttpServletRequest req,
                                  final HttpServletResponse resp)
        throws IOException {
        Request baseRequest = (req instanceof Request)
            ? (Request)req : getCurrentRequest();
       
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Service http request on thread: " + Thread.currentThread());
        }
        Message inMessage = retrieveFromContinuation(req);
       
        if (inMessage == null) {
           
            inMessage = new MessageImpl();
            ExchangeImpl exchange = new ExchangeImpl();
            exchange.setInMessage(inMessage);
            setupMessage(inMessage, context, req, resp);
           
            ((MessageImpl)inMessage).setDestination(this);
   
            exchange.setSession(new HTTPSession(req));
        }
       
        try {   
            incomingObserver.onMessage(inMessage);
            resp.flushBuffer();
            baseRequest.setHandled(true);
            ContinuationProvider p = inMessage.get(ContinuationProvider.class);
            if (p != null) {
                p.complete();
            }
        } catch (SuspendedInvocationException ex) {
View Full Code Here

    }

    //TODO: create handler mapping and war config object
    @RequestMapping("/**")
    public void handleWar(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws IOException, ServletException {
        Request jettyRequest = findRequest(servletRequest);
        String requestURI = servletRequest.getRequestURI();
        requestURI = requestURI.substring("/hello".length());
        webapp.handle(requestURI, jettyRequest, servletRequest, servletResponse);
    }
View Full Code Here

                    // Can't use sendRedirect, as that forces it to be a temp redirect.
                        jettyResponse.setStatus(HttpStatus.SC_MOVED_PERMANENTLY);
                        jettyResponse.setHeader("Location", "http://localhost:8089/redirect");
                        if (servletRequest instanceof Request) {
                            Request request = (Request) servletRequest;
                            request.setHandled(true);
                        }
                    }
                } else {
                    response.sendRedirect("http://localhost:8089/redirect");
                }
View Full Code Here

                    Response jettyResponse = (Response) response;
                    jettyResponse.setStatus(HttpStatus.SC_MOVED_PERMANENTLY);
                    jettyResponse.setHeader("Location", REDIRECT_TARGET_URL);
                }
                if (request instanceof Request) {
                    Request jettyRequest = (Request) request;
                    jettyRequest.setHandled(true);
                }
            } else {
                response.sendRedirect(REDIRECT_TARGET_URL);
            }
        }
View Full Code Here

        });

        this.listener = new ContinuationListener() {
            @Override
            public void onComplete(Continuation continuation) {
                final Request request = ((AsyncContinuation) continuation).getBaseRequest();
                updateResponses(request);
                if (!continuation.isResumed()) {
                    activeSuspendedRequests.dec();
                }
                expires.mark();
            }

            @Override
            public void onTimeout(Continuation continuation) {
                final Request request = ((AsyncContinuation) continuation).getBaseRequest();
                updateResponses(request);
                if (!continuation.isResumed()) {
                    activeSuspendedRequests.dec();
                }
            }
View Full Code Here

                             HttpServletRequest req,
                             HttpServletResponse resp) throws IOException {
        if (context == null) {
            context = servletContext;
        }
        Request baseRequest = (req instanceof Request)
            ? (Request)req : HttpConnection.getCurrentConnection().getRequest();
           
        if (!"HEAD".equals(req.getMethod())) {
            //bug in Jetty with persistent connections that if a HEAD is
            //sent, a _head flag is never reset
            HttpConnection c = baseRequest.getConnection();
            if (c != null) {
                c.getGenerator().setHead(false);
            }
        }
        if (getServer().isSetRedirectURL()) {
            resp.sendRedirect(getServer().getRedirectURL());
            resp.flushBuffer();
            baseRequest.setHandled(true);
            return;
        }
        QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
       
        if (null != req.getQueryString() && queryHandlerRegistry != null) {  
            String reqAddr = req.getRequestURL().toString();
            String requestURL =  reqAddr + "?" + req.getQueryString();
            String pathInfo = req.getPathInfo();                    
            for (QueryHandler qh : queryHandlerRegistry.getHandlers()) {
                boolean recognized =
                    qh instanceof StemMatchingQueryHandler
                    ? ((StemMatchingQueryHandler)qh).isRecognizedQuery(requestURL,
                                                                       pathInfo,
                                                                       endpointInfo,
                                                                       contextMatchOnExact())
                    : qh.isRecognizedQuery(requestURL, pathInfo, endpointInfo);
                if (recognized) {
                    //replace the endpointInfo address with request url only for get wsdl
                    String errorMsg = null;
                    CachedOutputStream out = new CachedOutputStream();
                    try {
                        synchronized (endpointInfo) {
                            String oldAddress = updateEndpointAddress(reqAddr);  
                            resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
                            try {
                                qh.writeResponse(requestURL, pathInfo, endpointInfo, out);
                            } catch (Exception ex) {
                                LOG.log(Level.WARNING, "writeResponse failed: ", ex);
                                errorMsg = ex.getMessage();
                            }
                            endpointInfo.setAddress(oldAddress);
                        }
                        if (errorMsg != null) {
                            resp.sendError(500, errorMsg);
                        } else {
                            out.writeCacheTo(resp.getOutputStream());
                            resp.getOutputStream().flush();                    
                        }
                    } finally {
                        out.close();
                    }
                    baseRequest.setHandled(true);
                    return;
                }
            }
        }
View Full Code Here

    protected void serviceRequest(final ServletContext context,
                                  final HttpServletRequest req,
                                  final HttpServletResponse resp)
        throws IOException {
        Request baseRequest = (req instanceof Request)
            ? (Request)req : HttpConnection.getCurrentConnection().getRequest();
       
        if (LOG.isLoggable(Level.FINE)) {
            LOG.fine("Service http request on thread: " + Thread.currentThread());
        }
        Message inMessage = retrieveFromContinuation(req);
       
        if (inMessage == null) {
           
            inMessage = new MessageImpl();
            setupMessage(inMessage, context, req, resp);
           
            ((MessageImpl)inMessage).setDestination(this);
   
            ExchangeImpl exchange = new ExchangeImpl();
            exchange.setInMessage(inMessage);
            exchange.setSession(new HTTPSession(req));
        }
       
        try {   
            incomingObserver.onMessage(inMessage);
            resp.flushBuffer();
            baseRequest.setHandled(true);
        } catch (SuspendedInvocationException ex) {
            if (ex.getRuntimeException() != null) {
                throw ex.getRuntimeException();
            }
            //else nothing to do
View Full Code Here

                             HttpServletRequest req,
                             HttpServletResponse resp) throws IOException {
        if (context == null) {
            context = servletContext;
        }
        Request baseRequest = (req instanceof Request)
            ? (Request)req : getCurrentRequest();
           
        if (!"HEAD".equals(req.getMethod())) {
            //bug in Jetty with persistent connections that if a HEAD is
            //sent, a _head flag is never reset
            AbstractConnection c = getConnectionForRequest(baseRequest);
            if (c != null) {
                setHeadFalse(c);
            }
        }
        if (getServer().isSetRedirectURL()) {
            resp.sendRedirect(getServer().getRedirectURL());
            resp.flushBuffer();
            baseRequest.setHandled(true);
            return;
        }
        QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
       
        if (null != req.getQueryString() && queryHandlerRegistry != null) {  
            String reqAddr = req.getRequestURL().toString();
            String requestURL =  reqAddr + "?" + req.getQueryString();
            String pathInfo = req.getPathInfo();                    
            for (QueryHandler qh : queryHandlerRegistry.getHandlers()) {
                boolean recognized =
                    qh instanceof StemMatchingQueryHandler
                    ? ((StemMatchingQueryHandler)qh).isRecognizedQuery(requestURL,
                                                                       pathInfo,
                                                                       endpointInfo,
                                                                       contextMatchOnExact())
                    : qh.isRecognizedQuery(requestURL, pathInfo, endpointInfo);
                if (recognized) {
                    //replace the endpointInfo address with request url only for get wsdl
                    String errorMsg = null;
                    CachedOutputStream out = new CachedOutputStream();
                    try {
                        synchronized (endpointInfo) {
                            String oldAddress = updateEndpointAddress(reqAddr);  
                            resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
                            try {
                                qh.writeResponse(requestURL, pathInfo, endpointInfo, out);
                            } catch (Exception ex) {
                                LOG.log(Level.WARNING, "writeResponse failed: ", ex);
                                errorMsg = ex.getMessage();
                            }
                            endpointInfo.setAddress(oldAddress);
                        }
                        if (errorMsg != null) {
                            resp.sendError(500, errorMsg);
                        } else {
                            out.writeCacheTo(resp.getOutputStream());
                            resp.getOutputStream().flush();                    
                        }
                    } finally {
                        out.close();
                    }
                    baseRequest.setHandled(true);
                    return;
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.eclipse.jetty.server.Request

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.