Java 类org.apache.catalina.Request 实例源码

项目:goodees    文件:CatalinaValve.java   
@Override
public int invoke(Request rqst, Response rspns) throws IOException,
        ServletException {
    if (!isStarted()) {
        try {
            start();
        } catch (LifecycleException ex) {
            throw new ServletException(ex);
        }
    }
    rqst.setNote(CatalinaAdapter.REQUEST_TIME, System.currentTimeMillis());
    if (!alreadySetLogbackStatusManager) {
        alreadySetLogbackStatusManager = true;
        org.apache.catalina.Context tomcatContext = rqst.getContext();
        if (tomcatContext != null) {
            ServletContext sc = tomcatContext.getServletContext();
            if (sc != null) {
                sc.setAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY, ctx.getStatusManager());
            }
        }
    }

    return INVOKE_NEXT;
}
项目:goodees    文件:CatalinaValve.java   
@Override
public void postInvoke(Request request, Response response)
        throws IOException, ServletException {
    final HttpServletRequest httpRequest = (HttpServletRequest) request.getRequest();
    try {
        CatalinaAdapter adapter = new CatalinaAdapter(request, response);
        IAccessEvent accessEvent = new AccessEvent(httpRequest, (HttpServletResponse) response.getResponse(),
            adapter);

        if (ctx.getFilterChainDecision(accessEvent) == FilterReply.DENY) {
            return;
        }

        // TODO better tion handling
        ctx.callAppenders(accessEvent);
    } finally {
        httpRequest.removeAttribute(AccessConstants.LOGBACK_STATUS_MANAGER_KEY);
    }
}
项目:jerrydog    文件:ErrorDispatcherValve.java   
/**
 * Invoke the next Valve in the sequence. When the invoke returns, check 
 * the response state, and output an error report is necessary.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 * @param context The valve context used to invoke the next valve
 *  in the current processing pipeline
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
public void invoke(Request request, Response response,
                   ValveContext context)
    throws IOException, ServletException {

    // Perform the request
    context.invokeNext(request, response);

    response.setSuspended(false);

    ServletRequest sreq = request.getRequest();
    Throwable t = (Throwable) sreq.getAttribute(Globals.EXCEPTION_ATTR);

    if (t != null) {
        throwable(request, response, t);
    } else {
        status(request, response);
    }

}
项目:jerrydog    文件:CertificatesValve.java   
/**
 * Expose the certificates chain if one was included on this request.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 * @param context The valve context used to invoke the next valve
 *  in the current processing pipeline
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
public void invoke(Request request, Response response,
                   ValveContext context)
    throws IOException, ServletException {

    // Identify the underlying request if this request was wrapped
    Request actual = request;
    while (actual instanceof RequestWrapper)
        actual = ((RequestWrapper) actual).getWrappedRequest();
    //        if (debug >= 2)
    //            log("Processing request");

    // Verify the existence of a certificate chain if appropriate
    if (certificates)
        verify(request, actual);

    // Expose the certificate chain if appropriate
    expose(request, actual);

    // Invoke the next Valve in our Pipeline
    context.invokeNext(request, response);

}
项目:jerrydog    文件:StandardHostMapper.java   
/**
 * Return the child Container that should be used to process this Request,
 * based upon its characteristics.  If no such child Container can be
 * identified, return <code>null</code> instead.
 *
 * @param request Request being processed
 * @param update Update the Request to reflect the mapping selection?
 */
public Container map(Request request, boolean update) {
    // Has this request already been mapped?
    if (update && (request.getContext() != null))
        return (request.getContext());

    // Perform mapping on our request URI
    String uri = ((HttpRequest) request).getDecodedRequestURI();
    Context context = host.map(uri);

    // Update the request (if requested) and return the selected Context
    if (update) {
        request.setContext(context);
        if (context != null)
            ((HttpRequest) request).setContextPath(context.getPath());
        else
            ((HttpRequest) request).setContextPath(null);
    }
    return (context);

}
项目:HowTomcatWorks    文件:SimpleContextMapper.java   
/**
 * Return the child Container that should be used to process this Request,
 * based upon its characteristics.  If no such child Container can be
 * identified, return <code>null</code> instead.
 *
 * @param request Request being processed
 * @param update Update the Request to reflect the mapping selection?
 *
 * @exception IllegalArgumentException if the relative portion of the
 *  path cannot be URL decoded
 */
public Container map(Request request, boolean update) {
  // Has this request already been mapped?
  if (update && (request.getWrapper() != null))
    return (request.getWrapper());
  // Identify the context-relative URI to be mapped
  String contextPath =
    ((HttpServletRequest) request.getRequest()).getContextPath();
  String requestURI = ((HttpRequest) request).getDecodedRequestURI();
  String relativeURI = requestURI.substring(contextPath.length());
  // Apply the standard request URI mapping rules from the specification
  Wrapper wrapper = null;
  String servletPath = relativeURI;
  String pathInfo = null;
  String name = context.findServletMapping(relativeURI);
  if (name != null)
    wrapper = (Wrapper) context.findChild(name);

  // Update the Request (if requested) and return this Wrapper
  if (update) {
    request.setWrapper(wrapper);
    ((HttpRequest) request).setServletPath(servletPath);
    ((HttpRequest) request).setPathInfo(pathInfo);
  }
  return (wrapper);
}
项目:HowTomcatWorks    文件:SimpleContextMapper.java   
/**
 * Return the child Container that should be used to process this Request,
 * based upon its characteristics.  If no such child Container can be
 * identified, return <code>null</code> instead.
 *
 * @param request Request being processed
 * @param update Update the Request to reflect the mapping selection?
 *
 * @exception IllegalArgumentException if the relative portion of the
 *  path cannot be URL decoded
 */
public Container map(Request request, boolean update) {
  // Has this request already been mapped?
  if (update && (request.getWrapper() != null))
    return (request.getWrapper());
  // Identify the context-relative URI to be mapped
  String contextPath =
    ((HttpServletRequest) request.getRequest()).getContextPath();
  String requestURI = ((HttpRequest) request).getDecodedRequestURI();
  String relativeURI = requestURI.substring(contextPath.length());
  // Apply the standard request URI mapping rules from the specification
  Wrapper wrapper = null;
  String servletPath = relativeURI;
  String pathInfo = null;
  String name = context.findServletMapping(relativeURI);
  if (name != null)
    wrapper = (Wrapper) context.findChild(name);

  // Update the Request (if requested) and return this Wrapper
  if (update) {
    request.setWrapper(wrapper);
    ((HttpRequest) request).setServletPath(servletPath);
    ((HttpRequest) request).setPathInfo(pathInfo);
  }
  return (wrapper);
}
项目:HowTomcatWorks    文件:ErrorDispatcherValve.java   
/**
 * Invoke the next Valve in the sequence. When the invoke returns, check 
 * the response state, and output an error report is necessary.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 * @param context The valve context used to invoke the next valve
 *  in the current processing pipeline
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
public void invoke(Request request, Response response,
                   ValveContext context)
    throws IOException, ServletException {

    // Perform the request
    context.invokeNext(request, response);

    response.setSuspended(false);

    ServletRequest sreq = request.getRequest();
    Throwable t = (Throwable) sreq.getAttribute(Globals.EXCEPTION_ATTR);

    if (t != null) {
        throwable(request, response, t);
    } else {
        status(request, response);
    }

}
项目:HowTomcatWorks    文件:CertificatesValve.java   
/**
 * Expose the certificates chain if one was included on this request.
 *
 * @param request The servlet request to be processed
 * @param response The servlet response to be created
 * @param context The valve context used to invoke the next valve
 *  in the current processing pipeline
 *
 * @exception IOException if an input/output error occurs
 * @exception ServletException if a servlet error occurs
 */
public void invoke(Request request, Response response,
                   ValveContext context)
    throws IOException, ServletException {

    // Identify the underlying request if this request was wrapped
    Request actual = request;
    while (actual instanceof RequestWrapper)
        actual = ((RequestWrapper) actual).getWrappedRequest();
    //        if (debug >= 2)
    //            log("Processing request");

    // Verify the existence of a certificate chain if appropriate
    if (certificates)
        verify(request, actual);

    // Expose the certificate chain if appropriate
    expose(request, actual);

    // Invoke the next Valve in our Pipeline
    context.invokeNext(request, response);

}
项目:HowTomcatWorks    文件:StandardHostMapper.java   
/**
 * Return the child Container that should be used to process this Request,
 * based upon its characteristics.  If no such child Container can be
 * identified, return <code>null</code> instead.
 *
 * @param request Request being processed
 * @param update Update the Request to reflect the mapping selection?
 */
public Container map(Request request, boolean update) {
    // Has this request already been mapped?
    if (update && (request.getContext() != null))
        return (request.getContext());

    // Perform mapping on our request URI
    String uri = ((HttpRequest) request).getDecodedRequestURI();
    Context context = host.map(uri);

    // Update the request (if requested) and return the selected Context
    if (update) {
        request.setContext(context);
        if (context != null)
            ((HttpRequest) request).setContextPath(context.getPath());
        else
            ((HttpRequest) request).setContextPath(null);
    }
    return (context);

}
项目:HowTomcatWorks    文件:HeaderLoggerValve.java   
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  // Pass this request on to the next valve in our pipeline
  valveContext.invokeNext(request, response);

  System.out.println("Header Logger Valve");
  ServletRequest sreq = request.getRequest();
  if (sreq instanceof HttpServletRequest) {
    HttpServletRequest hreq = (HttpServletRequest) sreq;
    Enumeration headerNames = hreq.getHeaderNames();
    while (headerNames.hasMoreElements()) {
      String headerName = headerNames.nextElement().toString();
      String headerValue = hreq.getHeader(headerName);
      System.out.println(headerName + ":" + headerValue);
    }

  }
  else
    System.out.println("Not an HTTP Request");

  System.out.println("------------------------------------");
}
项目:HowTomcatWorks    文件:SimpleContextMapper.java   
/**
 * Return the child Container that should be used to process this Request,
 * based upon its characteristics.  If no such child Container can be
 * identified, return <code>null</code> instead.
 *
 * @param request Request being processed
 * @param update Update the Request to reflect the mapping selection?
 *
 * @exception IllegalArgumentException if the relative portion of the
 *  path cannot be URL decoded
 */
public Container map(Request request, boolean update) {
  // Identify the context-relative URI to be mapped
  String contextPath =
    ((HttpServletRequest) request.getRequest()).getContextPath();
  String requestURI = ((HttpRequest) request).getDecodedRequestURI();
  String relativeURI = requestURI.substring(contextPath.length());
  // Apply the standard request URI mapping rules from the specification
  Wrapper wrapper = null;
  String servletPath = relativeURI;
  String pathInfo = null;
  String name = context.findServletMapping(relativeURI);
  if (name != null)
    wrapper = (Wrapper) context.findChild(name);
  return (wrapper);
}
项目:jerrydog    文件:RequestStream.java   
/**
 * Construct a servlet input stream associated with the specified Request.
 *
 * @param request The associated request
 */
public RequestStream(Request request) {

    super();
    closed = false;
    count = 0;
    length = request.getRequest().getContentLength();
    stream = request.getStream();

}
项目:jerrydog    文件:HttpConnector.java   
/**
 * Create (or allocate) and return a Request object suitable for
 * specifying the contents of a Request to the responsible Container.
 */
public Request createRequest() {

    //        if (debug >= 2)
    //            log("createRequest: Creating new request");
    HttpRequestImpl request = new HttpRequestImpl();
    request.setConnector(this);
    return (request);

}
项目:jerrydog    文件:HttpConnector.java   
/**
 * Create (or allocate) and return a Request object suitable for
 * specifying the contents of a Request to the responsible Container.
 */
public Request createRequest() {

    HttpRequestImpl request = new HttpRequestImpl();
    request.setConnector(this);
    return (request);

}
项目:jerrydog    文件:ErrorDispatcherValve.java   
/**
 * Handle an HTTP status code or Java exception by forwarding control
 * to the location included in the specified errorPage object.  It is
 * assumed that the caller has already recorded any request attributes
 * that are to be forwarded to this page.  Return <code>true</code> if
 * we successfully utilized the specified error page location, or
 * <code>false</code> if the default error report should be rendered.
 *
 * @param request The request being processed
 * @param response The response being generated
 * @param errorPage The errorPage directive we are obeying
 */
protected boolean custom(Request request, Response response,
                         ErrorPage errorPage) {

    if (debug >= 1)
        log("Processing " + errorPage);

    // Validate our current environment
    if (!(request instanceof HttpRequest)) {
        if (debug >= 1)
            log(" Not processing an HTTP request --> default handling");
        return (false);     // NOTE - Nothing we can do generically
    }
    HttpServletRequest hreq =
        (HttpServletRequest) request.getRequest();
    if (!(response instanceof HttpResponse)) {
        if (debug >= 1)
            log("Not processing an HTTP response --> default handling");
        return (false);     // NOTE - Nothing we can do generically
    }
    HttpServletResponse hres =
        (HttpServletResponse) response.getResponse();

    try {

        // Reset the response if possible (else IllegalStateException)
        hres.reset();

        // Forward control to the specified location
        ServletContext servletContext =
            request.getContext().getServletContext();
        RequestDispatcher rd =
            servletContext.getRequestDispatcher(errorPage.getLocation());
        rd.forward(hreq, hres);

        // If we forward, the response is suspended again
        response.setSuspended(false);

        // Indicate that we have successfully processed this custom page
        return (true);

    } catch (Throwable t) {

        // Report our failure to process this custom page
        log("Exception Processing " + errorPage, t);
        return (false);

    }

}
项目:jerrydog    文件:FastEngineMapper.java   
/**
 * Return the child Container that should be used to process this Request,
 * based upon its characteristics.  If no such child Container can be
 * identified, return <code>null</code> instead.
 *
 * @param request Request being processed
 * @param update Update the Request to reflect the mapping selection?
 */
public Container map(Request request, boolean update) {

    debug = engine.getDebug();

    // Extract the requested server name
    String server = request.getRequest().getServerName();
    if (server == null) {
        server = engine.getDefaultHost();
        if (update)
            request.setServerName(server);
    }
    if (server == null)
        return (null);
    if (debug >= 1)
        engine.log("Mapping server name '" + server + "'");

    // Find the specified host in our cache
    if (debug >= 2)
        engine.log(" Trying a cache match");
    Host host = (Host) cache.get(server);

    // Map to the default host if any
    if ((host == null) && (defaultHost != null)) {
        if (debug >= 2)
            engine.log(" Mapping to default host");
        host = defaultHost;
        addAlias(server, host);
    }

    // Update the Request if requested, and return the selected Host
    ;       // No update to the Request is required
    return (host);

}
项目:jerrydog    文件:StandardContext.java   
/**
 * Process the specified Request, and generate the corresponding Response,
 * according to the design of this particular Container.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 *
 * @exception IOException if an input/output error occurred while
 *  processing
 * @exception ServletException if a ServletException was thrown
 *  while processing this request
 */
public void invoke(Request request, Response response)
    throws IOException, ServletException {

    // Wait if we are reloading
    while (getPaused()) {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            ;
        }
    }

    // Normal request processing
    if (swallowOutput) {
        try {
            SystemLogHandler.startCapture();
            super.invoke(request, response);
        } finally {
            String log = SystemLogHandler.stopCapture();
            if (log != null && log.length() > 0) {
                log(log);
            }
        }
    } else {
        super.invoke(request, response);
    }

}
项目:jerrydog    文件:ContainerBase.java   
/**
 * Return the child Container that should be used to process this Request,
 * based upon its characteristics.  If no such child Container can be
 * identified, return <code>null</code> instead.
 *
 * @param request Request being processed
 * @param update Update the Request to reflect the mapping selection?
 */
public Container map(Request request, boolean update) {

    // Select the Mapper we will use
    Mapper mapper = findMapper(request.getRequest().getProtocol());
    if (mapper == null)
        return (null);

    // Use this Mapper to perform this mapping
    return (mapper.map(request, update));

}
项目:jerrydog    文件:StandardEngineValve.java   
/**
 * Select the appropriate child Host to process this request,
 * based on the requested server name.  If no matching Host can
 * be found, return an appropriate HTTP error.
 *
 * @param request Request to be processed
 * @param response Response to be produced
 * @param valveContext Valve context used to forward to the next Valve
 *
 * @exception IOException if an input/output error occurred
 * @exception ServletException if a servlet error occurred
 */
public void invoke(Request request, Response response,
                   ValveContext valveContext)
    throws IOException, ServletException {
    // Validate the request and response object types
    if (!(request.getRequest() instanceof HttpServletRequest) ||
        !(response.getResponse() instanceof HttpServletResponse)) {
        return;     // NOTE - Not much else we can do generically
    }

    // Validate that any HTTP/1.1 request included a host header
    HttpServletRequest hrequest = (HttpServletRequest) request;
    if ("HTTP/1.1".equals(hrequest.getProtocol()) &&
        (hrequest.getServerName() == null)) {
        ((HttpServletResponse) response.getResponse()).sendError
            (HttpServletResponse.SC_BAD_REQUEST,
             sm.getString("standardEngine.noHostHeader",
                          request.getRequest().getServerName()));
        return;
    }

    // Select the Host to be used for this Request
    StandardEngine engine = (StandardEngine) getContainer();
    Host host = (Host) engine.map(request, true);
    if (host == null) {
        ((HttpServletResponse) response.getResponse()).sendError
            (HttpServletResponse.SC_BAD_REQUEST,
             sm.getString("standardEngine.noHost",
                          request.getRequest().getServerName()));
        return;
    }

    // Ask this Host to process this request
    host.invoke(request, response);

}
项目:jerrydog    文件:ApplicationDispatcher.java   
/**
 * Unwrap the request if we have wrapped it.
 */
private void unwrapRequest() {

    if (wrapRequest == null)
        return;

    ServletRequest previous = null;
    ServletRequest current = outerRequest;
    while (current != null) {

        // If we run into the container request we are done
        if ((current instanceof Request)
            || (current instanceof RequestFacade))
            break;

        // Remove the current request if it is our wrapper
        if (current == wrapRequest) {
            ServletRequest next =
              ((ServletRequestWrapper) current).getRequest();
            if (previous == null)
                outerRequest = next;
            else
                ((ServletRequestWrapper) previous).setRequest(next);
            break;
        }

        // Advance to the next request in the chain
        previous = current;
        current = ((ServletRequestWrapper) current).getRequest();

    }

}
项目:jerrydog    文件:ApplicationDispatcher.java   
/**
 * Create and return a request wrapper that has been inserted in the
 * appropriate spot in the request chain.
 */
private ServletRequest wrapRequest() {

    // Locate the request we should insert in front of
    ServletRequest previous = null;
    ServletRequest current = outerRequest;
    while (current != null) {
        if ("org.apache.catalina.servlets.InvokerHttpRequest".
            equals(current.getClass().getName()))
            break; // KLUDGE - Make nested RD.forward() using invoker work
        if (!(current instanceof ServletRequestWrapper))
            break;
        if (current instanceof ApplicationHttpRequest)
            break;
        if (current instanceof ApplicationRequest)
            break;
        if (current instanceof Request)
            break;
        previous = current;
        current = ((ServletRequestWrapper) current).getRequest();
    }

    // Instantiate a new wrapper at this point and insert it in the chain
    ServletRequest wrapper = null;
    if ((current instanceof ApplicationHttpRequest) ||
        (current instanceof HttpRequest) ||
        (current instanceof HttpServletRequest))
        wrapper = new ApplicationHttpRequest((HttpServletRequest) current);
    else
        wrapper = new ApplicationRequest(current);
    if (previous == null)
        outerRequest = wrapper;
    else
        ((ServletRequestWrapper) previous).setRequest(wrapper);
    wrapRequest = wrapper;
    return (wrapper);

}
项目:psi-probe-plus    文件:Tomcat50AgentValve.java   
public void invoke(Request request, Response response, ValveContext valveContext) throws IOException, ServletException {
    valveContext.invokeNext(request, response);
    ServletRequest servletRequest = request.getRequest();
    if (servletRequest instanceof HttpServletRequest) {
        HttpServletRequest hsr = (HttpServletRequest) request;
        HttpSession session = hsr.getSession(false);
        if (session != null) {
            String ip = IPInfo.getClientAddress(hsr);
            session.setAttribute(ApplicationSession.LAST_ACCESSED_BY_IP, ip);
        }
    }
}
项目:HowTomcatWorks    文件:SimplePipeline.java   
public void invokeNext(Request request, Response response)
  throws IOException, ServletException {
  int subscript = stage;
  stage = stage + 1;
  // Invoke the requested Valve for the current request thread
  if (subscript < valves.length) {
    valves[subscript].invoke(request, response, this);
  }
  else if ((subscript == valves.length) && (basic != null)) {
    basic.invoke(request, response, this);
  }
  else {
    throw new ServletException("No valve");
  }
}
项目:HowTomcatWorks    文件:SimpleWrapperValve.java   
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  SimpleWrapper wrapper = (SimpleWrapper) getContainer();
  ServletRequest sreq = request.getRequest();
  ServletResponse sres = response.getResponse();
  Servlet servlet = null;
  HttpServletRequest hreq = null;
  if (sreq instanceof HttpServletRequest)
    hreq = (HttpServletRequest) sreq;
  HttpServletResponse hres = null;
  if (sres instanceof HttpServletResponse)
    hres = (HttpServletResponse) sres;

  //-- new addition -----------------------------------
  Context context = (Context) wrapper.getParent();
  request.setContext(context);
  //-------------------------------------
  // Allocate a servlet instance to process this request
  try {
    servlet = wrapper.allocate();
    if (hres!=null && hreq!=null) {
      servlet.service(hreq, hres);
    }
    else {
      servlet.service(sreq, sres);
    }
  }
  catch (ServletException e) {
  }
}
项目:HowTomcatWorks    文件:SimpleContext.java   
public Container map(Request request, boolean update) {
  //this method is taken from the map method in org.apache.cataline.core.ContainerBase
  //the findMapper method always returns the default mapper, if any, regardless the
  //request's protocol
  Mapper mapper = findMapper(request.getRequest().getProtocol());
  if (mapper == null)
    return (null);

  // Use this Mapper to perform this mapping
  return (mapper.map(request, update));
}
项目:HowTomcatWorks    文件:SimpleContextValve.java   
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {
  // Validate the request and response object types
  if (!(request.getRequest() instanceof HttpServletRequest) ||
    !(response.getResponse() instanceof HttpServletResponse)) {
    return;     // NOTE - Not much else we can do generically
  }

  // Disallow any direct access to resources under WEB-INF or META-INF
  HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
  String contextPath = hreq.getContextPath();
  String requestURI = ((HttpRequest) request).getDecodedRequestURI();
  String relativeURI =
    requestURI.substring(contextPath.length()).toUpperCase();

  Context context = (Context) getContainer();
  // Select the Wrapper to be used for this Request
  Wrapper wrapper = null;
  try {
    wrapper = (Wrapper) context.map(request, true);
  }
  catch (IllegalArgumentException e) {
    badRequest(requestURI, (HttpServletResponse) response.getResponse());
    return;
  }
  if (wrapper == null) {
    notFound(requestURI, (HttpServletResponse) response.getResponse());
    return;
  }
  // Ask this Wrapper to process this Request
  response.setContext(context);
  wrapper.invoke(request, response);
}
项目:HowTomcatWorks    文件:SimplePipeline.java   
public void invokeNext(Request request, Response response)
  throws IOException, ServletException {
  int subscript = stage;
  stage = stage + 1;
  // Invoke the requested Valve for the current request thread
  if (subscript < valves.length) {
    valves[subscript].invoke(request, response, this);
  }
  else if ((subscript == valves.length) && (basic != null)) {
    basic.invoke(request, response, this);
  }
  else {
    throw new ServletException("No valve");
  }
}
项目:HowTomcatWorks    文件:SimpleWrapperValve.java   
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  SimpleWrapper wrapper = (SimpleWrapper) getContainer();
  ServletRequest sreq = request.getRequest();
  ServletResponse sres = response.getResponse();
  Servlet servlet = null;
  HttpServletRequest hreq = null;
  if (sreq instanceof HttpServletRequest)
    hreq = (HttpServletRequest) sreq;
  HttpServletResponse hres = null;
  if (sres instanceof HttpServletResponse)
    hres = (HttpServletResponse) sres;

  // Allocate a servlet instance to process this request
  try {
    servlet = wrapper.allocate();
    if (hres!=null && hreq!=null) {
      servlet.service(hreq, hres);
    }
    else {
      servlet.service(sreq, sres);
    }
  }
  catch (ServletException e) {
  }
}
项目:HowTomcatWorks    文件:SimplePipeline.java   
public void invokeNext(Request request, Response response)
  throws IOException, ServletException {
  int subscript = stage;
  stage = stage + 1;
  // Invoke the requested Valve for the current request thread
  if (subscript < valves.length) {
    valves[subscript].invoke(request, response, this);
  }
  else if ((subscript == valves.length) && (basic != null)) {
    basic.invoke(request, response, this);
  }
  else {
    throw new ServletException("No valve");
  }
}
项目:HowTomcatWorks    文件:SimpleWrapperValve.java   
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  SimpleWrapper wrapper = (SimpleWrapper) getContainer();
  ServletRequest sreq = request.getRequest();
  ServletResponse sres = response.getResponse();
  Servlet servlet = null;
  HttpServletRequest hreq = null;
  if (sreq instanceof HttpServletRequest)
    hreq = (HttpServletRequest) sreq;
  HttpServletResponse hres = null;
  if (sres instanceof HttpServletResponse)
    hres = (HttpServletResponse) sres;

  // Allocate a servlet instance to process this request
  try {
    servlet = wrapper.allocate();
    if (hres!=null && hreq!=null) {
      servlet.service(hreq, hres);
    }
    else {
      servlet.service(sreq, sres);
    }
  }
  catch (ServletException e) {
  }
}
项目:HowTomcatWorks    文件:SimplePipeline.java   
public void invokeNext(Request request, Response response)
  throws IOException, ServletException {
  int subscript = stage;
  stage = stage + 1;
  // Invoke the requested Valve for the current request thread
  if (subscript < valves.length) {
    valves[subscript].invoke(request, response, this);
  }
  else if ((subscript == valves.length) && (basic != null)) {
    basic.invoke(request, response, this);
  }
  else {
    throw new ServletException("No valve");
  }
}
项目:HowTomcatWorks    文件:SimpleWrapperValve.java   
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  SimpleWrapper wrapper = (SimpleWrapper) getContainer();
  ServletRequest sreq = request.getRequest();
  ServletResponse sres = response.getResponse();
  Servlet servlet = null;
  HttpServletRequest hreq = null;
  if (sreq instanceof HttpServletRequest)
    hreq = (HttpServletRequest) sreq;
  HttpServletResponse hres = null;
  if (sres instanceof HttpServletResponse)
    hres = (HttpServletResponse) sres;

  // Allocate a servlet instance to process this request
  try {
    servlet = wrapper.allocate();
    if (hres!=null && hreq!=null) {
      servlet.service(hreq, hres);
    }
    else {
      servlet.service(sreq, sres);
    }
  }
  catch (ServletException e) {
  }
}
项目:HowTomcatWorks    文件:SimpleContext.java   
public Container map(Request request, boolean update) {
  //this method is taken from the map method in org.apache.cataline.core.ContainerBase
  //the findMapper method always returns the default mapper, if any, regardless the
  //request's protocol
  Mapper mapper = findMapper(request.getRequest().getProtocol());
  if (mapper == null)
    return (null);

  // Use this Mapper to perform this mapping
  return (mapper.map(request, update));
}
项目:HowTomcatWorks    文件:SimpleContextValve.java   
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {
  // Validate the request and response object types
  if (!(request.getRequest() instanceof HttpServletRequest) ||
    !(response.getResponse() instanceof HttpServletResponse)) {
    return;     // NOTE - Not much else we can do generically
  }

  // Disallow any direct access to resources under WEB-INF or META-INF
  HttpServletRequest hreq = (HttpServletRequest) request.getRequest();
  String contextPath = hreq.getContextPath();
  String requestURI = ((HttpRequest) request).getDecodedRequestURI();
  String relativeURI =
    requestURI.substring(contextPath.length()).toUpperCase();

  Context context = (Context) getContainer();
  // Select the Wrapper to be used for this Request
  Wrapper wrapper = null;
  try {
    wrapper = (Wrapper) context.map(request, true);
  }
  catch (IllegalArgumentException e) {
    badRequest(requestURI, (HttpServletResponse) response.getResponse());
    return;
  }
  if (wrapper == null) {
    notFound(requestURI, (HttpServletResponse) response.getResponse());
    return;
  }
  // Ask this Wrapper to process this Request
  response.setContext(context);
  wrapper.invoke(request, response);
}
项目:HowTomcatWorks    文件:SimplePipeline.java   
public void invokeNext(Request request, Response response)
  throws IOException, ServletException {
  int subscript = stage;
  stage = stage + 1;
  // Invoke the requested Valve for the current request thread
  if (subscript < valves.length) {
    valves[subscript].invoke(request, response, this);
  }
  else if ((subscript == valves.length) && (basic != null)) {
    basic.invoke(request, response, this);
  }
  else {
    throw new ServletException("No valve");
  }
}
项目:HowTomcatWorks    文件:SimpleWrapperValve.java   
public void invoke(Request request, Response response, ValveContext valveContext)
  throws IOException, ServletException {

  SimpleWrapper wrapper = (SimpleWrapper) getContainer();
  ServletRequest sreq = request.getRequest();
  ServletResponse sres = response.getResponse();
  Servlet servlet = null;
  HttpServletRequest hreq = null;
  if (sreq instanceof HttpServletRequest)
    hreq = (HttpServletRequest) sreq;
  HttpServletResponse hres = null;
  if (sres instanceof HttpServletResponse)
    hres = (HttpServletResponse) sres;

  // Allocate a servlet instance to process this request
  try {
    servlet = wrapper.allocate();
    if (hres!=null && hreq!=null) {
      servlet.service(hreq, hres);
    }
    else {
      servlet.service(sreq, sres);
    }
  }
  catch (ServletException e) {
  }
}
项目:HowTomcatWorks    文件:RequestStream.java   
/**
 * Construct a servlet input stream associated with the specified Request.
 *
 * @param request The associated request
 */
public RequestStream(Request request) {

    super();
    closed = false;
    count = 0;
    length = request.getRequest().getContentLength();
    stream = request.getStream();

}
项目:HowTomcatWorks    文件:HttpConnector.java   
/**
 * Create (or allocate) and return a Request object suitable for
 * specifying the contents of a Request to the responsible Container.
 */
public Request createRequest() {

    //        if (debug >= 2)
    //            log("createRequest: Creating new request");
    HttpRequestImpl request = new HttpRequestImpl();
    request.setConnector(this);
    return (request);

}
项目:HowTomcatWorks    文件:HttpConnector.java   
/**
 * Create (or allocate) and return a Request object suitable for
 * specifying the contents of a Request to the responsible Container.
 */
public Request createRequest() {

    HttpRequestImpl request = new HttpRequestImpl();
    request.setConnector(this);
    return (request);

}