Revert "Bug 497510 - [http]
HttpServletRequestWrapperImpl::getRequestUri()"

This reverts commit 3eb1d9e3c39039085c5a6298eb6be6ae12c74760.

Change-Id: I655087a9ea5beff49c3d6f3245d837f1481efee7
Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java
index a3711f5..c9a9990 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/DispatchingTest.java
@@ -1576,61 +1576,4 @@
 		Assert.assertEquals(10, counter.get());
 	}
 
-	@Test
-	public void test_Bug497510_1() throws Exception {
-		Servlet servlet = new HttpServlet() {
-			private static final long serialVersionUID = 1L;
-
-			@Override
-			protected void doGet(
-				final HttpServletRequest req, final HttpServletResponse resp)
-				throws ServletException, IOException {
-
-				String requestURI = req.getRequestURI();
-
-				Assert.assertNotNull(requestURI);
-
-				PrintWriter writer = resp.getWriter();
-				writer.write(requestURI);
-			}
-		};
-
-		Dictionary<String, Object> props = new Hashtable<String, Object>();
-		props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "Bug497510");
-		props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/Bug497510/*");
-		registrations.add(getBundleContext().registerService(Servlet.class, servlet, props));
-
-		String result = requestAdvisor.request("Bug497510/a%20b%20c");
-
-		Assert.assertEquals("/Bug497510/a%20b%20c", result);
-	}
-
-	@Test
-	public void test_Bug497510_2() throws Exception {
-		Servlet servlet = new HttpServlet() {
-			private static final long serialVersionUID = 1L;
-
-			@Override
-			protected void doGet(
-				final HttpServletRequest req, final HttpServletResponse resp)
-				throws ServletException, IOException {
-
-				String requestURI = req.getRequestURI();
-
-				Assert.assertNotNull(requestURI);
-
-				PrintWriter writer = resp.getWriter();
-				writer.write(requestURI);
-			}
-		};
-
-		Dictionary<String, Object> props = new Hashtable<String, Object>();
-		props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "Bug 497510");
-		props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/Bug 497510/*");
-		registrations.add(getBundleContext().registerService(Servlet.class, servlet, props));
-
-		String result = requestAdvisor.request("Bug%20497510/a%20b%20c");
-
-		Assert.assertEquals("/Bug%20497510/a%20b%20c", result);
-	}
 }
\ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/FilterRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/FilterRegistration.java
index 5e68ec6..27975ca 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/FilterRegistration.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/FilterRegistration.java
@@ -38,7 +38,6 @@
 	private final ContextController contextController;
 	private final boolean initDestoyWithContextController;
 	private final Pattern[] compiledRegexs;
-	private final boolean needDecode;
 
 	public FilterRegistration(
 		ServiceHolder<Filter> filterHolder, FilterDTO filterDTO, int priority,
@@ -71,7 +70,6 @@
 		} else {
 			initDestoyWithContextController = true;
 		}
-		needDecode = MatchableRegistration.patternsRequireDecode(filterDTO.patterns);
 	}
 
 	public int compareTo(FilterRegistration otherFilterRegistration) {
@@ -274,9 +272,4 @@
 		return patterns;
 	}
 
-	@Override
-	public boolean needDecode() {
-		return needDecode;
-	}
-
 }
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java
index 4da830e..9414378 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/MatchableRegistration.java
@@ -11,9 +11,6 @@
 
 package org.eclipse.equinox.http.servlet.internal.registration;
 
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import java.net.URLEncoder;
 import org.eclipse.equinox.http.servlet.internal.servlet.Match;
 import org.eclipse.equinox.http.servlet.internal.util.Const;
 import org.osgi.dto.DTO;
@@ -28,14 +25,12 @@
 		super(t, d);
 	}
 
-	public abstract boolean needDecode();
-
 	public abstract String match(
 		String name, String servletPath, String pathInfo, String extension,
 		Match match);
 
-	private boolean isPathWildcardMatch(
-		String pattern, String servletPath) {
+	protected boolean isPathWildcardMatch(
+		String pattern, String servletPath, String pathInfo) {
 
 		int cpl = pattern.length() - 2;
 
@@ -52,18 +47,11 @@
 		return false;
 	}
 
-	final protected boolean doMatch(
+	protected boolean doMatch(
 			String pattern, String servletPath, String pathInfo,
 			String extension, Match match)
 		throws IllegalArgumentException {
-		if (needDecode()) {
-			try {
-				servletPath = URLDecoder.decode(servletPath, "UTF-8"); //$NON-NLS-1$
-			}
-			catch (UnsupportedEncodingException e) {
-				// do nothing
-			}
-		}
+
 		if (match == Match.EXACT) {
 			return pattern.equals(servletPath);
 		}
@@ -78,7 +66,7 @@
 			}
 
 			if ((match == Match.REGEX) && isPathWildcardMatch(
-					pattern, servletPath)) {
+					pattern, servletPath, pathInfo)) {
 
 				return true;
 			}
@@ -100,18 +88,4 @@
 		return false;
 	}
 
-	static boolean patternsRequireDecode(String[] patterns) {
-		for (String pattern : patterns) {
-			try {
-				String encode = URLEncoder.encode(pattern, "UTF-8"); //$NON-NLS-1$
-				if (!encode.equals(pattern)) {
-					return true;
-				}
-			}
-			catch (UnsupportedEncodingException e) {
-				// do nothing
-			}
-		}
-		return false;
-	}
 }
\ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ResourceRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ResourceRegistration.java
index ff10f1b..fc6ac64 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ResourceRegistration.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ResourceRegistration.java
@@ -29,7 +29,6 @@
 		super(servletHolder, resourceDTO, servletContextHelper, contextController, legacyTCCL);
 
 		name = servletHolder.get().getClass().getName().concat("#").concat(getD().prefix); //$NON-NLS-1$
-		needDecode = MatchableRegistration.patternsRequireDecode(resourceDTO.patterns);
 	}
 
 	@Override
@@ -47,12 +46,6 @@
 		return getD().serviceId;
 	}
 
-	@Override
-	public boolean needDecode() {
-		return needDecode;
-	}
-
-	private final boolean needDecode;
 	private final String name;
 
 }
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java
index be982f4..63267f9 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/registration/ServletRegistration.java
@@ -66,7 +66,6 @@
 		else {
 			multipartSupport = null;
 		}
-		needDecode = MatchableRegistration.patternsRequireDecode(servletDTO.patterns);
 	}
 
 	public ErrorPageDTO getErrorPageDTO() {
@@ -117,12 +116,8 @@
 
 		return multipartSupport.parseRequest(request);
 	}
-	@Override
-	public boolean needDecode() {
-		return needDecode;
-	}
 
-	private final boolean needDecode;
 	private final ErrorPageDTO errorPageDTO;
 	private final MultipartSupport multipartSupport;
+
 }
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java
index 82b21b2..08ec8f1 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java
@@ -62,11 +62,7 @@
 
 		checkRuntime();
 
-		String alias = request.getRequestURI();
-
-		if (request.getDispatcherType() == DispatcherType.INCLUDE) {
-			alias = (String)request.getAttribute(RequestDispatcher.INCLUDE_REQUEST_URI);
-		}
+		String alias = HttpServletRequestWrapperImpl.getDispatchPathInfo(request);
 
 		if (alias == null) {
 			alias = Const.SLASH;