Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2015-05-06 04:32:06 +0000
committerGreg Wilkins2015-05-06 04:32:06 +0000
commitf4d6f49d2f4cbc248e18f59423465c7b8cb200ad (patch)
tree1f6d160f254ff5036d14f8aba09d7830061e5239
parent4573e20033208579121e40a0e59c80ef227f63ef (diff)
downloadorg.eclipse.jetty.project-f4d6f49d2f4cbc248e18f59423465c7b8cb200ad.tar.gz
org.eclipse.jetty.project-f4d6f49d2f4cbc248e18f59423465c7b8cb200ad.tar.xz
org.eclipse.jetty.project-f4d6f49d2f4cbc248e18f59423465c7b8cb200ad.zip
466329 Fixed local only TestFilter
-rw-r--r--tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestFilter.java16
1 files changed, 6 insertions, 10 deletions
diff --git a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestFilter.java b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestFilter.java
index 4456c25817..95721c7524 100644
--- a/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestFilter.java
+++ b/tests/test-webapps/test-jetty-webapp/src/main/java/com/acme/TestFilter.java
@@ -64,6 +64,7 @@ public class TestFilter implements Filter
_remote=Boolean.parseBoolean(filterConfig.getInitParameter("remote"));
_allowed.add("/favicon.ico");
_allowed.add("/jetty_banner.gif");
+ _allowed.add("/remote.html");
LOG.debug("TestFilter#remote="+_remote);
}
@@ -76,18 +77,13 @@ public class TestFilter implements Filter
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException
{
- String from = request.getRemoteHost();
- String to = request.getServerName();
+ String from = request.getRemoteAddr();
+ String to = request.getLocalAddr();
String path=((HttpServletRequest)request).getServletPath();
-
- if (!"/remote.html".equals(path) && !_remote && !_allowed.contains(path) && (
- !from.equals("localhost") && !from.startsWith("127.") && from.indexOf(":1")<0 ||
- !to.equals("localhost")&&!to.startsWith("127.0.0.") && to.indexOf(":1")<0))
+
+ if (!_remote && !_allowed.contains(path) && !from.equals(to))
{
- if ("/".equals(path))
- _context.getRequestDispatcher("/remote.html").forward(request,response);
- else
- ((HttpServletResponse)response).sendRedirect("/remote.html");
+ _context.getRequestDispatcher("/remote.html").forward(request,response);
return;
}

Back to the top