365370 ServletHandler can fall through to nested handler

This commit is contained in:
Greg Wilkins 2011-12-02 11:09:11 +11:00
parent 7e9fbc7493
commit 050afb8d57
1 changed files with 37 additions and 23 deletions

View File

@ -394,22 +394,19 @@ public class ServletHandler extends ScopedHandler
try try
{ {
// Do the filter/handling thang // Do the filter/handling thang
if (servlet_holder!=null) old_scope=baseRequest.getUserIdentityScope();
{ baseRequest.setUserIdentityScope(servlet_holder);
old_scope=baseRequest.getUserIdentityScope();
baseRequest.setUserIdentityScope(servlet_holder);
// start manual inline of nextScope(target,baseRequest,request,response); // start manual inline of nextScope(target,baseRequest,request,response);
if (never()) if (never())
nextScope(target,baseRequest,request,response); nextScope(target,baseRequest,request,response);
else if (_nextScope!=null) else if (_nextScope!=null)
_nextScope.doScope(target,baseRequest,request, response); _nextScope.doScope(target,baseRequest,request, response);
else if (_outerScope!=null) else if (_outerScope!=null)
_outerScope.doHandle(target,baseRequest,request, response); _outerScope.doHandle(target,baseRequest,request, response);
else else
doHandle(target,baseRequest,request, response); doHandle(target,baseRequest,request, response);
// end manual inline (pathentic attempt to reduce stack depth) // end manual inline (pathentic attempt to reduce stack depth)
}
} }
finally finally
{ {
@ -460,7 +457,10 @@ public class ServletHandler extends ScopedHandler
{ {
if (servlet_holder==null) if (servlet_holder==null)
{ {
notFound(request, response); if (getHandler()==null)
notFound(request, response);
else
nextHandle(target,baseRequest,request,response);
} }
else else
{ {
@ -1230,6 +1230,7 @@ public class ServletHandler extends ScopedHandler
HttpServletResponse response) HttpServletResponse response)
throws IOException throws IOException
{ {
new Throwable().printStackTrace();
if(LOG.isDebugEnabled()) if(LOG.isDebugEnabled())
LOG.debug("Not Found "+request.getRequestURI()); LOG.debug("Not Found "+request.getRequestURI());
response.sendError(HttpServletResponse.SC_NOT_FOUND); response.sendError(HttpServletResponse.SC_NOT_FOUND);
@ -1319,6 +1320,8 @@ public class ServletHandler extends ScopedHandler
public void doFilter(ServletRequest request, ServletResponse response) public void doFilter(ServletRequest request, ServletResponse response)
throws IOException, ServletException throws IOException, ServletException
{ {
final Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
// pass to next filter // pass to next filter
if (_filterHolder!=null) if (_filterHolder!=null)
{ {
@ -1329,7 +1332,6 @@ public class ServletHandler extends ScopedHandler
filter.doFilter(request, response, _next); filter.doFilter(request, response, _next);
else else
{ {
final Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
final boolean suspendable=baseRequest.isAsyncSupported(); final boolean suspendable=baseRequest.isAsyncSupported();
if (suspendable) if (suspendable)
{ {
@ -1350,15 +1352,20 @@ public class ServletHandler extends ScopedHandler
} }
// Call servlet // Call servlet
HttpServletRequest srequest = (HttpServletRequest)request;
if (_servletHolder != null) if (_servletHolder != null)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("call servlet " + _servletHolder); LOG.debug("call servlet " + _servletHolder);
final Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
_servletHolder.handle(baseRequest,request, response); _servletHolder.handle(baseRequest,request, response);
} }
else // Not found else if (getHandler()==null)
notFound((HttpServletRequest)request, (HttpServletResponse)response); notFound(srequest, (HttpServletResponse)response);
else
nextHandle(URIUtil.addPaths(srequest.getServletPath(),srequest.getPathInfo()),
baseRequest,srequest,(HttpServletResponse)response);
} }
public String toString() public String toString()
@ -1424,14 +1431,21 @@ public class ServletHandler extends ScopedHandler
} }
// Call servlet // Call servlet
HttpServletRequest srequest = (HttpServletRequest)request;
if (_servletHolder != null) if (_servletHolder != null)
{ {
if (LOG.isDebugEnabled()) if (LOG.isDebugEnabled())
LOG.debug("call servlet " + _servletHolder); LOG.debug("call servlet " + _servletHolder);
_servletHolder.handle(_baseRequest,request, response); _servletHolder.handle(_baseRequest,request, response);
} }
else // Not found else if (getHandler()==null)
notFound((HttpServletRequest)request, (HttpServletResponse)response); notFound(srequest, (HttpServletResponse)response);
else
{
Request baseRequest=(request instanceof Request)?((Request)request):AbstractHttpConnection.getCurrentConnection().getRequest();
nextHandle(URIUtil.addPaths(srequest.getServletPath(),srequest.getPathInfo()),
baseRequest,srequest,(HttpServletResponse)response);
}
} }
/* ------------------------------------------------------------ */ /* ------------------------------------------------------------ */