Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoakim Erdfelt2015-11-23 11:00:59 -0500
committerJoakim Erdfelt2015-11-24 10:51:22 -0500
commitea9c9d5f8ddcb2bb119d16ae775311c8b95bf356 (patch)
tree0818ade36b22e74e149fc92eff2f18f2f9be4c4b /jetty-rewrite
parent33307730ea783349e0b1a88f5f28de920010c321 (diff)
downloadorg.eclipse.jetty.project-ea9c9d5f8ddcb2bb119d16ae775311c8b95bf356.tar.gz
org.eclipse.jetty.project-ea9c9d5f8ddcb2bb119d16ae775311c8b95bf356.tar.xz
org.eclipse.jetty.project-ea9c9d5f8ddcb2bb119d16ae775311c8b95bf356.zip
482173 - Track original Query string in Rewrite RuleContainer too
Diffstat (limited to 'jetty-rewrite')
-rw-r--r--jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java13
1 files changed, 12 insertions, 1 deletions
diff --git a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java
index e7974964f8..ccad086746 100644
--- a/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java
+++ b/jetty-rewrite/src/main/java/org/eclipse/jetty/rewrite/handler/RuleContainer.java
@@ -35,11 +35,13 @@ import org.eclipse.jetty.util.log.Logger;
*/
public class RuleContainer extends Rule
{
+ public static final String ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX = ".QUERYSTRING";
private static final Logger LOG = Log.getLogger(RuleContainer.class);
protected Rule[] _rules;
protected String _originalPathAttribute;
+ protected String _originalQueryStringAttribute;
protected boolean _rewriteRequestURI=true;
protected boolean _rewritePathInfo=true;
@@ -132,6 +134,7 @@ public class RuleContainer extends Rule
public void setOriginalPathAttribute(String originalPathAttribte)
{
_originalPathAttribute=originalPathAttribte;
+ _originalQueryStringAttribute = originalPathAttribte + ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX;
}
/**
@@ -157,18 +160,26 @@ public class RuleContainer extends Rule
protected String apply(String target, HttpServletRequest request, HttpServletResponse response) throws IOException
{
boolean original_set=_originalPathAttribute==null;
+
+ target = URIUtil.compactPath(target);
for (Rule rule : _rules)
{
String applied=rule.matchAndApply(target,request, response);
if (applied!=null)
- {
+ {
+ applied = URIUtil.compactPath(applied);
+
LOG.debug("applied {}",rule);
LOG.debug("rewrote {} to {}",target,applied);
if (!original_set)
{
original_set=true;
request.setAttribute(_originalPathAttribute, target);
+
+ String query = request.getQueryString();
+ if (query != null)
+ request.setAttribute(_originalQueryStringAttribute,query);
}
if (_rewriteRequestURI)

Back to the top