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