remm 2003/01/29 13:23:29 Modified: catalina/src/share/org/apache/catalina/core ApplicationFilterFactory.java StandardContextValve.java StandardWrapperValve.java Log: - Code simplifications using the request path. Revision Changes Path 1.6 +10 -6 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationFilterFactory.java Index: ApplicationFilterFactory.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/ApplicationFilterFactory.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- ApplicationFilterFactory.java 27 Nov 2002 20:34:20 -0000 1.5 +++ ApplicationFilterFactory.java 29 Jan 2003 21:23:29 -0000 1.6 @@ -91,10 +91,14 @@ public final class ApplicationFilterFactory { public static final int ERROR = 1; - public static final int FORWARD =2; - public static final int INCLUDE =4; + public static final Integer ERROR_INTEGER = new Integer(ERROR); + public static final int FORWARD = 2; + public static final Integer FORWARD_INTEGER = new Integer(FORWARD); + public static final int INCLUDE = 4; + public static final Integer INCLUDE_INTEGER = new Integer(INCLUDE); public static final int REQUEST = 8; - + public static final Integer REQUEST_INTEGER = new Integer(REQUEST); + public static final String DISPATCHER_TYPE_ATTR="org.apache.catalina.core.DISPATCHER_TYPE"; public static final String DISPATCHER_REQUEST_PATH_ATTR="org.apache.catalina.core.DISPATCHER_REQUEST_PATH"; 1.5 +9 -27 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContextValve.java Index: StandardContextValve.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardContextValve.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- StandardContextValve.java 29 Jan 2003 12:50:52 -0000 1.4 +++ StandardContextValve.java 29 Jan 2003 21:23:29 -0000 1.5 @@ -162,29 +162,11 @@ // Disallow any direct access to resources under WEB-INF or META-INF HttpRequest hreq = (HttpRequest) request; - MessageBytes contextPathMB = hreq.getContextPathMB(); - int length = contextPathMB.getLength(); - MessageBytes decodedURIMB = hreq.getDecodedRequestURIMB(); - decodedURIMB.toChars(); - CharChunk decodedURIBC = decodedURIMB.getCharChunk(); - int bcLength = decodedURIBC.getLength(); - boolean notFound = false; - if (decodedURIBC.startsWithIgnoreCase("/META-INF", length)) { - if ((decodedURIBC.getLength() == ("/META-INF".length() + length)) - || (decodedURIBC.getBuffer()["/META-INF".length() + length] - == '/')) { - notFound = true; - } - } - if (decodedURIBC.startsWithIgnoreCase("/WEB-INF", length)) { - if ((decodedURIBC.getLength() == ("/WEB-INF".length() + length)) - || (decodedURIBC.getBuffer()["/WEB-INF".length() + length] - == '/')) { - System.out.println("Not found"); - notFound = true; - } - } - if (notFound) { + MessageBytes requestPathMB = hreq.getRequestPathMB(); + if ((requestPathMB.startsWithIgnoreCase("/META-INF/", 0)) + || (requestPathMB.equalsIgnoreCase("/META-INF")) + || (requestPathMB.startsWithIgnoreCase("/WEB-INF/", 0)) + || (requestPathMB.equalsIgnoreCase("/WEB-INF"))) { String requestURI = hreq.getDecodedRequestURI(); notFound(requestURI, (HttpServletResponse) response.getResponse()); return; 1.10 +14 -13 jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java Index: StandardWrapperValve.java =================================================================== RCS file: /home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/core/StandardWrapperValve.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- StandardWrapperValve.java 24 Jan 2003 23:47:46 -0000 1.9 +++ StandardWrapperValve.java 29 Jan 2003 21:23:29 -0000 1.10 @@ -79,6 +79,9 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; + +import org.apache.tomcat.util.buf.MessageBytes; + import org.apache.catalina.Container; import org.apache.catalina.Context; import org.apache.catalina.Globals; @@ -185,6 +188,9 @@ long t1=System.currentTimeMillis(); requestCount++; StandardWrapper wrapper = (StandardWrapper) getContainer(); + HttpRequest hrequest = null; + if (request instanceof HttpRequest) + hrequest = (HttpRequest) request; ServletRequest sreq = request.getRequest(); ServletResponse sres = response.getResponse(); Servlet servlet = null; @@ -259,21 +265,16 @@ exception(request, response, e); servlet = null; } - String requestPath = null; + MessageBytes requestPathMB = null; if (hreq != null) { - String contextPath = hreq.getContextPath(); - if (contextPath == null) - contextPath = ""; - String requestURI = ((HttpRequest) request).getDecodedRequestURI(); - if (requestURI.length() >= contextPath.length()) - requestPath = requestURI.substring(contextPath.length()); + requestPathMB = hrequest.getRequestPathMB(); } sreq.setAttribute (ApplicationFilterFactory.DISPATCHER_TYPE_ATTR, - new Integer(ApplicationFilterFactory.REQUEST)); + ApplicationFilterFactory.REQUEST_INTEGER); sreq.setAttribute (ApplicationFilterFactory.DISPATCHER_REQUEST_PATH_ATTR, - requestPath); + requestPathMB.toString()); // Create the filter chain for this request ApplicationFilterFactory factory = ApplicationFilterFactory.getInstance();
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]