diff src/org/eclipse/jetty/server/handler/ContextHandler.java @ 1000:32d4b569567c

simplify handle()
author Franklin Schmidt <fschmidt@gmail.com>
date Wed, 19 Oct 2016 04:22:51 -0600
parents 7d28be82ab75
children 6939226e0ac4
line wrap: on
line diff
--- a/src/org/eclipse/jetty/server/handler/ContextHandler.java	Wed Oct 19 00:59:46 2016 -0600
+++ b/src/org/eclipse/jetty/server/handler/ContextHandler.java	Wed Oct 19 04:22:51 2016 -0600
@@ -57,7 +57,6 @@
 import javax.servlet.FilterRegistration;
 import javax.servlet.FilterRegistration.Dynamic;
 import javax.servlet.descriptor.JspConfigDescriptor;
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import org.eclipse.jetty.http.HttpException;
@@ -151,9 +150,9 @@
 		LOG.info("stopped {}",this);
 	}
 
-	private boolean checkContext(final String target, final Request baseRequest, final HttpServletResponse response) throws IOException, ServletException
+	private boolean checkContext(final String target, final Request request, final HttpServletResponse response) throws IOException, ServletException
 	{
-		if (baseRequest.isHandled())
+		if (request.isHandled())
 			return false;
 
 		// Are we not the root context?
@@ -169,11 +168,11 @@
 			if (_contextPath.length() == target.length())
 			{
 				// context request must end with /
-				baseRequest.setHandled(true);
-				if (baseRequest.getQueryString() != null)
-					response.sendRedirect(URIUtil.addPaths(baseRequest.getRequestURI(),URIUtil.SLASH) + "?" + baseRequest.getQueryString());
+				request.setHandled(true);
+				if (request.getQueryString() != null)
+					response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH) + "?" + request.getQueryString());
 				else
-					response.sendRedirect(URIUtil.addPaths(baseRequest.getRequestURI(),URIUtil.SLASH));
+					response.sendRedirect(URIUtil.addPaths(request.getRequestURI(),URIUtil.SLASH));
 				return false;
 			}
 		}
@@ -182,18 +181,18 @@
 	}
 
 	@Override
-	public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
+	public void handle(String target, Request request, HttpServletResponse response) throws IOException, ServletException
 	{
 		String old_context_path = null;
 		String old_path_info = null;
 		String pathInfo = target;
 
-		ContextHandler oldContextHandler = baseRequest._contextHandler;
+		ContextHandler oldContextHandler = request._contextHandler;
 
 		// Are we already in this context?
 		if (oldContextHandler != this)
 		{
-			if (!checkContext(target,baseRequest,response))
+			if (!checkContext(target,request,response))
 				return;
 
 			if (target.length() > _contextPath.length())
@@ -216,28 +215,28 @@
 
 		try
 		{
-			old_context_path = baseRequest.getContextPath();
-			old_path_info = baseRequest.getPathInfo();
+			old_context_path = request.getContextPath();
+			old_path_info = request.getPathInfo();
 
 			// Update the paths
-			baseRequest._contextHandler = this;
+			request._contextHandler = this;
 			if (target.startsWith("/"))
 			{
 				if (_contextPath.length() == 1)
-					baseRequest.setContextPath("");
+					request.setContextPath("");
 				else
-					baseRequest.setContextPath(_contextPath);
-				baseRequest.setPathInfo(pathInfo);
+					request.setContextPath(_contextPath);
+				request.setPathInfo(pathInfo);
 			}
 
 			try
 			{
-				super.handle(target,baseRequest,request,response);
+				super.handle(target,request,response);
 			}
 			catch (HttpException e)
 			{
 				LOG.debug("",e);
-				baseRequest.setHandled(true);
+				request.setHandled(true);
 				response.sendError(e.getStatus(),e.getReason());
 			}
 		}
@@ -246,9 +245,9 @@
 			if (oldContextHandler != this)
 			{
 				// reset the context and servlet path.
-				baseRequest._contextHandler = oldContextHandler;
-				baseRequest.setContextPath(old_context_path);
-				baseRequest.setPathInfo(old_path_info);
+				request._contextHandler = oldContextHandler;
+				request.setContextPath(old_context_path);
+				request.setPathInfo(old_path_info);
 			}
 		}
 	}