You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2013/05/27 10:30:23 UTC
[2/2] git commit: WICKET-5203 Base url is incorrect for error
dispatched pages
WICKET-5203 Base url is incorrect for error dispatched pages
Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/2293764f
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/2293764f
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/2293764f
Branch: refs/heads/master
Commit: 2293764f6a3abdf3492c97c9299f7e8fc043ebcf
Parents: ae7ce56
Author: Martin Tzvetanov Grigorov <mg...@apache.org>
Authored: Mon May 27 11:19:41 2013 +0300
Committer: Martin Tzvetanov Grigorov <mg...@apache.org>
Committed: Mon May 27 11:30:13 2013 +0300
----------------------------------------------------------------------
.../protocol/http/servlet/ServletWebRequest.java | 15 +-------
.../http/servlet/ServletWebRequestTest.java | 29 ++++++++++++++-
2 files changed, 28 insertions(+), 16 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/wicket/blob/2293764f/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
index 83df540..24947bb 100644
--- a/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
+++ b/wicket-core/src/main/java/org/apache/wicket/protocol/http/servlet/ServletWebRequest.java
@@ -102,20 +102,7 @@ public class ServletWebRequest extends WebRequest
forwardAttributes = ForwardAttributes.of(httpServletRequest, filterPrefix);
- if (forwardAttributes != null || errorAttributes != null)
- {
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Setting filterPrefix('{}') to '' because there is either an error or a forward. {}, {}",
- new Object[] {filterPrefix, forwardAttributes, errorAttributes});
- }
- // the filter prefix is not needed when the current request is internal
- // see WICKET-4387
- this.filterPrefix = "";
- } else
- {
- this.filterPrefix = filterPrefix;
- }
+ this.filterPrefix = filterPrefix;
if (url != null)
{
http://git-wip-us.apache.org/repos/asf/wicket/blob/2293764f/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
index 8e3cfe1..f974a06 100644
--- a/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
+++ b/wicket-core/src/test/java/org/apache/wicket/protocol/http/servlet/ServletWebRequestTest.java
@@ -59,7 +59,7 @@ public class ServletWebRequestTest extends Assert
// simulates a request that has errors metadata
httpRequest.setAttribute("javax.servlet.error.request_uri",
httpRequest.getContextPath() + "/any/source/of/error");
- ServletWebRequest errorWebRequest = new ServletWebRequest(httpRequest, "/");
+ ServletWebRequest errorWebRequest = new ServletWebRequest(httpRequest, "");
Url errorClientUrl = errorWebRequest.getClientUrl();
assertEquals("any/source/of/error", errorClientUrl.toString());
@@ -83,7 +83,6 @@ public class ServletWebRequestTest extends Assert
Url errorClientUrl = errorWebRequest.getClientUrl();
assertEquals("any/source/of/error", errorClientUrl.toString());
-
}
/**
@@ -166,6 +165,32 @@ public class ServletWebRequestTest extends Assert
}
}
+ /**
+ * Tests that {@link ServletWebRequest#getClientUrl()} returns the current url + the query
+ * string when this is not forward dispatched request. When the request is error dispatched it
+ * returns just the request uri to the error page without the query string
+ */
+ @Test
+ public void wicket5203()
+ {
+ String filterPath = "filterPath";
+ MockHttpServletRequest httpRequest = new MockHttpServletRequest(null, null, null);
+ httpRequest.setURL(httpRequest.getContextPath() + '/' + filterPath + "/request/Path");
+ httpRequest.setParameter("some", "parameter");
+
+ ServletWebRequest webRequest = new ServletWebRequest(httpRequest, filterPath);
+ Url clientUrl = webRequest.getClientUrl();
+ assertEquals("request/Path?some=parameter", clientUrl.toString());
+
+ // simulates a request that has errors metadata
+ httpRequest.setAttribute("javax.servlet.error.request_uri",
+ httpRequest.getContextPath() + '/' + filterPath + "/any/source/of/error");
+ ServletWebRequest errorWebRequest = new ServletWebRequest(httpRequest, filterPath);
+ Url errorClientUrl = errorWebRequest.getClientUrl();
+
+ assertEquals("any/source/of/error", errorClientUrl.toString());
+ }
+
private static class CustomRequestPage extends WebPage implements IMarkupResourceStreamProvider
{
private static final long serialVersionUID = 1L;