Fixes rewrite.mod Jetty module to work with jetty-home. (#8111)
Updated Javadocs. Removed obsolete msie.mod Jetty module. Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
This commit is contained in:
parent
6139b37fb6
commit
8e964b337c
|
@ -3,8 +3,7 @@
|
|||
<Configure id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RuleContainer">
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.CompactPathRule"/>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.CompactPathRule" />
|
||||
</Arg>
|
||||
</Call>
|
||||
</Configure>
|
||||
|
|
@ -1,19 +1,13 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
|
||||
<Configure id="httpConfig" class="org.eclipse.jetty.server.HttpConfiguration">
|
||||
<!-- =========================================================== -->
|
||||
<!-- configure rewrite rule container as a customizer -->
|
||||
<!-- =========================================================== -->
|
||||
<!-- TODO no longer needed?
|
||||
<Call name="addCustomizer">
|
||||
<Arg>
|
||||
<New id="Rewrite" class="org.eclipse.jetty.rewrite.RewriteCustomizer">
|
||||
<Set name="rewriteRequestURI" property="jetty.rewrite.rewriteRequestURI"/>
|
||||
<Set name="rewritePathInfo" property="jetty.rewrite.rewritePathInfo"/>
|
||||
<Set name="originalPathAttribute"><Property name="jetty.rewrite.originalPathAttribute" default="requestedPath"/></Set>
|
||||
<Set name="originalPathAttribute">
|
||||
<Property name="jetty.rewrite.originalPathAttribute" default="jetty.rewrite.originalRequestPath" />
|
||||
</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
-->
|
||||
</Call>
|
||||
</Configure>
|
||||
|
||||
|
|
|
@ -1,30 +1,14 @@
|
|||
<?xml version="1.0"?><!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
|
||||
|
||||
<Configure id="Server" class="org.eclipse.jetty.server.Server">
|
||||
|
||||
<!-- =========================================================== -->
|
||||
<!-- configure rewrite handler -->
|
||||
<!-- =========================================================== -->
|
||||
<Call name="insertHandler">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
|
||||
<!-- TODO
|
||||
<Set name="rewriteRequestURI" property="jetty.rewrite.rewriteRequestURI"/>
|
||||
<Set name="rewritePathInfo" property="jetty.rewrite.rewritePathInfo"/>
|
||||
-->
|
||||
<Set name="originalPathAttribute"><Property name="jetty.rewrite.originalPathAttribute" default="requestedPath"/></Set>
|
||||
|
||||
<!-- Set DispatcherTypes -->
|
||||
<!-- TODO
|
||||
<Set name="dispatcherTypes">
|
||||
<Array type="jakarta.servlet.DispatcherType">
|
||||
<Item><Call class="jakarta.servlet.DispatcherType" name="valueOf"><Arg>REQUEST</Arg></Call></Item>
|
||||
<Item><Call class="jakarta.servlet.DispatcherType" name="valueOf"><Arg>ASYNC</Arg></Call></Item>
|
||||
</Array>
|
||||
</Set>
|
||||
<Set name="originalPathAttribute">
|
||||
<Property name="jetty.rewrite.originalPathAttribute" default="jetty.rewrite.originalRequestPath" />
|
||||
</Set>
|
||||
<Get id="Rewrite" name="ruleContainer" />
|
||||
-->
|
||||
<!-- see rewrite-rules.xml in $JETTY_BASE for how to add a rule(s) -->
|
||||
<!-- see jetty-rewrite-rules.xml in $JETTY_BASE for how to add a rule(s) -->
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
# DO NOT EDIT - See: https://www.eclipse.org/jetty/documentation/current/startup-modules.html
|
||||
|
||||
[description]
|
||||
Enables the MSIE rewrite rule for MSIE 5 and 6 known bugs.
|
||||
|
||||
[depend]
|
||||
rewrite
|
||||
|
||||
[files]
|
||||
basehome:modules/rewrite/rewrite-msie.xml|etc/rewrite-msie.xml
|
||||
|
||||
[xml]
|
||||
etc/rewrite-msie.xml
|
|
@ -8,9 +8,4 @@ Double slashes in the path are treated as a single slash.
|
|||
rewrite
|
||||
|
||||
[xml]
|
||||
etc/rewrite-compactpath.xml
|
||||
|
||||
[ini-template]
|
||||
## Requires either rewrite or rewrite-customizer module
|
||||
## with rewritePathInfo==true
|
||||
jetty.rewrite.rewritePathInfo=true
|
||||
etc/jetty-rewrite-compactpath.xml
|
||||
|
|
|
@ -17,11 +17,5 @@ lib/jetty-rewrite-${jetty.version}.jar
|
|||
etc/jetty-rewrite-customizer.xml
|
||||
|
||||
[ini-template]
|
||||
## Whether to rewrite the request URI
|
||||
# jetty.rewrite.rewriteRequestURI=true
|
||||
|
||||
## Whether to rewrite the path info
|
||||
# jetty.rewrite.rewritePathInfo=true
|
||||
|
||||
## Request attribute key under with the original path is stored
|
||||
# jetty.rewrite.originalPathAttribute=requestedPath
|
||||
## Request attribute name used to store the original request path.
|
||||
# jetty.rewrite.originalPathAttribute=jetty.rewrite.originalRequestPath
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
[description]
|
||||
Enables the jetty-rewrite handler.
|
||||
Specific rewrite rules must be added to either to etc/jetty-rewrite.xml or a custom xml/module.
|
||||
Specific rewrite rules must be added to etc/jetty-rewrite-rules.xml.
|
||||
|
||||
[tags]
|
||||
server
|
||||
|
@ -17,18 +17,12 @@ server
|
|||
lib/jetty-rewrite-${jetty.version}.jar
|
||||
|
||||
[files]
|
||||
basehome:modules/rewrite/rewrite-rules.xml|etc/rewrite-rules.xml
|
||||
basehome:modules/rewrite/jetty-rewrite-rules.xml|etc/jetty-rewrite-rules.xml
|
||||
|
||||
[xml]
|
||||
etc/jetty-rewrite.xml
|
||||
etc/rewrite-rules.xml
|
||||
etc/jetty-rewrite-rules.xml
|
||||
|
||||
[ini-template]
|
||||
## Whether to rewrite the request URI
|
||||
# jetty.rewrite.rewriteRequestURI=true
|
||||
|
||||
## Whether to rewrite the path info
|
||||
# jetty.rewrite.rewritePathInfo=false
|
||||
|
||||
## Request attribute key under with the original path is stored
|
||||
# jetty.rewrite.originalPathAttribute=requestedPath
|
||||
## Request attribute name used to store the original request path.
|
||||
# jetty.rewrite.originalPathAttribute=jetty.rewrite.originalRequestPath
|
||||
|
|
|
@ -2,42 +2,42 @@
|
|||
<!DOCTYPE Configure PUBLIC "-//Jetty//Configure//EN" "https://www.eclipse.org/jetty/configure_10_0.dtd">
|
||||
<Configure id="Rewrite" class="org.eclipse.jetty.rewrite.handler.RuleContainer">
|
||||
|
||||
<!-- protect favicon handling
|
||||
<!-- Protects favicon handling by not processing other rules.
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
|
||||
<Set name="pattern">/favicon.ico</Set>
|
||||
<Set name="name">Cache-Control</Set>
|
||||
<Set name="value">Max-Age=3600,public</Set>
|
||||
<Set name="headerName">Cache-Control</Set>
|
||||
<Set name="headerValue">Max-Age=3600,public</Set>
|
||||
<Set name="terminating">true</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
-->
|
||||
|
||||
<!-- redirect from the welcome page to a specific page
|
||||
<!-- Rewrites from a directory URI to a welcome page URI.
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
|
||||
<Set name="pattern">/test/rewrite/</Set>
|
||||
<Set name="replacement">/test/rewrite/info.html</Set>
|
||||
<Set name="replacement">/test/rewrite/index.html</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
-->
|
||||
|
||||
<!-- replace the entire request URI
|
||||
<!-- Rewrites a URI to another URI.
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
|
||||
<Set name="pattern">/test/some/old/context</Set>
|
||||
<Set name="replacement">/test/rewritten/newcontext</Set>
|
||||
<Set name="replacement">/test/rewritten/new/context</Set>
|
||||
</New>
|
||||
</Arg>
|
||||
</Call>
|
||||
-->
|
||||
|
||||
<!-- replace the beginning of the request URI
|
||||
<!-- Rewrites the beginning of the request URI.
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
|
||||
|
@ -48,7 +48,7 @@
|
|||
</Call>
|
||||
-->
|
||||
|
||||
<!-- reverse the order of the path sections
|
||||
<!-- Rewrites a URI by reversing the order of the path segments.
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
|
||||
|
@ -59,7 +59,7 @@
|
|||
</Call>
|
||||
-->
|
||||
|
||||
<!-- add a cookie to each path visited
|
||||
<!-- Adds a cookie to each path visited.
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.CookiePatternRule">
|
||||
|
@ -71,7 +71,7 @@
|
|||
</Call>
|
||||
-->
|
||||
|
||||
<!-- actual redirect, instead of internal rewrite
|
||||
<!-- Redirects (instead of rewriting) to a different URI.
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
|
||||
|
@ -82,7 +82,7 @@
|
|||
</Call>
|
||||
-->
|
||||
|
||||
<!-- add a response rule
|
||||
<!-- A response rule.
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.ResponsePatternRule">
|
||||
|
@ -94,13 +94,4 @@
|
|||
</Call>
|
||||
-->
|
||||
|
||||
<!-- Add rule to protect against IE ssl bug (see msie module and rewrite-msie.xml)
|
||||
<Call name="addRule">
|
||||
<Arg>
|
||||
<New class="org.eclipse.jetty.rewrite.handler.MsieRule"/>
|
||||
</Arg>
|
||||
</Call>
|
||||
-->
|
||||
|
||||
</Configure>
|
||||
|
|
@ -21,6 +21,12 @@ import org.eclipse.jetty.rewrite.handler.RuleContainer;
|
|||
import org.eclipse.jetty.server.HttpConfiguration.Customizer;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
|
||||
/**
|
||||
* <p>A {@link RuleContainer} that is an {@link org.eclipse.jetty.server.HttpConfiguration.Customizer},
|
||||
* so that its rules are processed at request customization time.</p>
|
||||
*
|
||||
* @see org.eclipse.jetty.server.HttpConfiguration#addCustomizer(Customizer)
|
||||
*/
|
||||
public class RewriteCustomizer extends RuleContainer implements Customizer
|
||||
{
|
||||
@Override
|
||||
|
|
|
@ -19,138 +19,21 @@ import org.eclipse.jetty.server.Handler;
|
|||
import org.eclipse.jetty.server.Request;
|
||||
|
||||
/**
|
||||
* <p> Rewrite handler is responsible for managing the rules. Its capabilities
|
||||
* is not only limited for URL rewrites such as RewritePatternRule or RewriteRegexRule.
|
||||
* There is also handling for cookies, headers, redirection, setting status or error codes
|
||||
* whenever the rule finds a match.
|
||||
*
|
||||
* <p> The rules can be matched by the either: pattern matching of @{@link org.eclipse.jetty.http.pathmap.ServletPathSpec}
|
||||
* (eg {@link PatternRule}), regular expressions (eg {@link RegexRule}) or custom logic.
|
||||
*
|
||||
* <p> The rules can be grouped into rule containers (class {@link RuleContainer}), and will only
|
||||
* be applied if the request matches the conditions for their container
|
||||
* (e.g., by virtual host name)
|
||||
*
|
||||
* <p>The list of predefined rules is:
|
||||
* <ul>
|
||||
* <li> {@link CookiePatternRule} - adds a new cookie in response. </li>
|
||||
* <li> {@link HeaderPatternRule} - adds/modifies the HTTP headers in response. </li>
|
||||
* <li> {@link RedirectPatternRule} - sets the redirect location. </li>
|
||||
* <li> {@link ResponsePatternRule} - sets the status/error codes. </li>
|
||||
* <li> {@link RewritePatternRule} - rewrites the requested URI. </li>
|
||||
* <li> {@link RewriteRegexRule} - rewrites the requested URI using regular expression for pattern matching. </li>
|
||||
* <li> {@link ForwardedSchemeHeaderRule} - set the scheme according to the headers present. </li>
|
||||
* <li> {@link VirtualHostRuleContainer} - checks whether the request matches one of a set of virtual host names.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* Here is a typical jetty.xml configuration would be: <pre>
|
||||
*
|
||||
* <New id="RewriteHandler" class="org.eclipse.jetty.rewrite.handler.RewriteHandler">
|
||||
* <Set name="rules">
|
||||
* <Array type="org.eclipse.jetty.rewrite.handler.Rule">
|
||||
*
|
||||
* <Item>
|
||||
* <New id="rewrite" class="org.eclipse.jetty.rewrite.handler.RewritePatternRule">
|
||||
* <Set name="pattern">/*</Set>
|
||||
* <Set name="replacement">/test</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
* <Item>
|
||||
* <New id="response" class="org.eclipse.jetty.rewrite.handler.ResponsePatternRule">
|
||||
* <Set name="pattern">/session/</Set>
|
||||
* <Set name="code">400</Set>
|
||||
* <Set name="reason">Setting error code 400</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
* <Item>
|
||||
* <New id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
|
||||
* <Set name="pattern">*.jsp</Set>
|
||||
* <Set name="name">server</Set>
|
||||
* <Set name="value">dexter webserver</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
* <Item>
|
||||
* <New id="header" class="org.eclipse.jetty.rewrite.handler.HeaderPatternRule">
|
||||
* <Set name="pattern">*.jsp</Set>
|
||||
* <Set name="name">title</Set>
|
||||
* <Set name="value">driven header purpose</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
* <Item>
|
||||
* <New id="redirect" class="org.eclipse.jetty.rewrite.handler.RedirectPatternRule">
|
||||
* <Set name="pattern">/test/dispatch</Set>
|
||||
* <Set name="location">http://jetty.eclipse.org</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
* <Item>
|
||||
* <New id="regexRewrite" class="org.eclipse.jetty.rewrite.handler.RewriteRegexRule">
|
||||
* <Set name="regex">/test-jaas/$</Set>
|
||||
* <Set name="replacement">/demo</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
* <Item>
|
||||
* <New id="forwardedHttps" class="org.eclipse.jetty.rewrite.handler.ForwardedSchemeHeaderRule">
|
||||
* <Set name="header">X-Forwarded-Scheme</Set>
|
||||
* <Set name="headerValue">https</Set>
|
||||
* <Set name="scheme">https</Set>
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
* <Item>
|
||||
* <New id="virtualHost" class="org.eclipse.jetty.rewrite.handler.VirtualHostRuleContainer">
|
||||
*
|
||||
* <Set name="virtualHosts">
|
||||
* <Array type="java.lang.String">
|
||||
* <Item>eclipse.com</Item>
|
||||
* <Item>www.eclipse.com</Item>
|
||||
* <Item>eclipse.org</Item>
|
||||
* <Item>www.eclipse.org</Item>
|
||||
* </Array>
|
||||
* </Set>
|
||||
*
|
||||
* <Call name="addRule">
|
||||
* <Arg>
|
||||
* <New class="org.eclipse.jetty.rewrite.handler.CookiePatternRule">
|
||||
* <Set name="pattern">/*</Set>
|
||||
* <Set name="name">CookiePatternRule</Set>
|
||||
* <Set name="value">1</Set>
|
||||
* </New>
|
||||
* </Arg>
|
||||
* </Call>
|
||||
*
|
||||
* </New>
|
||||
* </Item>
|
||||
*
|
||||
* </Array>
|
||||
* </Set>
|
||||
* </New>
|
||||
*
|
||||
* <Set name="handler">
|
||||
* <Ref id="RewriteHandler"/>
|
||||
* <Set name="handler">
|
||||
* <New id="Handlers" class="org.eclipse.jetty.server.handler.HandlerCollection">
|
||||
* <Set name="handlers">
|
||||
* <Array type="org.eclipse.jetty.server.Handler">
|
||||
* <Item>
|
||||
* <New id="Contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"/>
|
||||
* </Item>
|
||||
* <Item>
|
||||
* <New id="DefaultHandler" class="org.eclipse.jetty.server.handler.DefaultHandler"/>
|
||||
* </Item>
|
||||
* </Array>
|
||||
* </Set>
|
||||
* </New>
|
||||
* </Set>
|
||||
* </Ref>
|
||||
* </Set>
|
||||
* </pre>
|
||||
* <p>{@code RewriteHandler} rewrites incoming requests through a set of {@link Rule}s.</p>
|
||||
* <p>{@code RewriteHandler} can rewrite the request URI, but also HTTP cookies and HTTP headers.
|
||||
* When a rule matches, {@code RewriteHandler} can perform actions such as redirect to a
|
||||
* different URI or directly produce a response with a configurable HTTP status code.</p>
|
||||
* <p>Rules can be grouped into a {@link RuleContainer}, which is itself a {@code Rule}.
|
||||
* If the container rule matches (for example, virtual host name when using
|
||||
* {@link VirtualHostRuleContainer}), then the contained rules will be applied.</p>
|
||||
* <p>Rules are applied in the same sequence they are added to the container.
|
||||
* If a rule matches, it applies some logic (typically wrapping the request),
|
||||
* and the next rule is invoked (with the wrapped request), until a
|
||||
* {@link Rule#isTerminating() terminating rule} is found, or all the rules have
|
||||
* been processed.</p>
|
||||
* <p>Request URI matching is performed either via Servlet pattern matching (using
|
||||
* {@link PatternRule} subclasses), via regular expression matching (using
|
||||
* {@link RegexRule} subclasses), or by a custom implementation of {@code Rule}.</p>
|
||||
*/
|
||||
public class RewriteHandler extends Handler.Wrapper
|
||||
{
|
||||
|
@ -168,9 +51,15 @@ public class RewriteHandler extends Handler.Wrapper
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns the list of rules.
|
||||
*
|
||||
* @return an array of {@link Rule}.
|
||||
* @return the {@link RuleContainer} used by this handler
|
||||
*/
|
||||
public RuleContainer getRuleContainer()
|
||||
{
|
||||
return _rules;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the list of {@link Rule}s.
|
||||
*/
|
||||
public List<Rule> getRules()
|
||||
{
|
||||
|
@ -178,9 +67,9 @@ public class RewriteHandler extends Handler.Wrapper
|
|||
}
|
||||
|
||||
/**
|
||||
* Assigns the rules to process.
|
||||
* <p>Sets the list of rules, discarding the previous ones.</p>
|
||||
*
|
||||
* @param rules an array of {@link Rule}.
|
||||
* @param rules the list of {@link Rule}s to set
|
||||
*/
|
||||
public void setRules(List<Rule> rules)
|
||||
{
|
||||
|
@ -188,9 +77,9 @@ public class RewriteHandler extends Handler.Wrapper
|
|||
}
|
||||
|
||||
/**
|
||||
* Add a Rule
|
||||
* <p>Adds a {@link Rule} to the existing ones.</p>
|
||||
*
|
||||
* @param rule The rule to add to the end of the rules array
|
||||
* @param rule the rule to add to the rules list
|
||||
*/
|
||||
public void addRule(Rule rule)
|
||||
{
|
||||
|
@ -198,8 +87,7 @@ public class RewriteHandler extends Handler.Wrapper
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the originalPathAttribute. If non null, this string will be used
|
||||
* as the attribute name to store the original request path.
|
||||
* @see RuleContainer#getOriginalPathAttribute()
|
||||
*/
|
||||
public String getOriginalPathAttribute()
|
||||
{
|
||||
|
@ -207,8 +95,7 @@ public class RewriteHandler extends Handler.Wrapper
|
|||
}
|
||||
|
||||
/**
|
||||
* @param originalPathAttribute If non null, this string will be used
|
||||
* as the attribute name to store the original request path.
|
||||
* @see RuleContainer#setOriginalPathAttribute(String)
|
||||
*/
|
||||
public void setOriginalPathAttribute(String originalPathAttribute)
|
||||
{
|
||||
|
|
|
@ -25,8 +25,8 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Base container to group rules. Can be extended so that the contained rules
|
||||
* will only be applied under certain conditions
|
||||
* <p>A container that groups {@link Rule}s and is itself a {@code Rule}.</p>
|
||||
* <p>The contained rules will be applied only if the container rule matches.</p>
|
||||
*/
|
||||
public class RuleContainer extends Rule implements Iterable<Rule>, Dumpable
|
||||
{
|
||||
|
@ -43,7 +43,7 @@ public class RuleContainer extends Rule implements Iterable<Rule>, Dumpable
|
|||
*/
|
||||
public List<Rule> getRules()
|
||||
{
|
||||
return _rules;
|
||||
return List.copyOf(_rules);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,9 +62,9 @@ public class RuleContainer extends Rule implements Iterable<Rule>, Dumpable
|
|||
}
|
||||
|
||||
/**
|
||||
* Add a Rule
|
||||
* <p>Adds a {@link Rule} to the existing ones.</p>
|
||||
*
|
||||
* @param rule The rule to add to the end of the rules array
|
||||
* @param rule the rule to add to the rules list
|
||||
*/
|
||||
public void addRule(Rule rule)
|
||||
{
|
||||
|
@ -72,8 +72,8 @@ public class RuleContainer extends Rule implements Iterable<Rule>, Dumpable
|
|||
}
|
||||
|
||||
/**
|
||||
* @return the originalPathAttribte. If non null, this string will be used
|
||||
* as the attribute name to store the original request path.
|
||||
* @return the request attribute name used to store the request original path
|
||||
* @see #setOriginalPathAttribute(String)
|
||||
*/
|
||||
public String getOriginalPathAttribute()
|
||||
{
|
||||
|
@ -81,8 +81,14 @@ public class RuleContainer extends Rule implements Iterable<Rule>, Dumpable
|
|||
}
|
||||
|
||||
/**
|
||||
* @param originalPathAttribute If non null, this string will be used
|
||||
* as the attribute name to store the original request path.
|
||||
* <p>Sets a request attribute name that will be used to store the request original path.</p>
|
||||
* <p>A request attribute name that stores the request original query is derived from this
|
||||
* attribute name by adding {@link #ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX}, as in:</p>
|
||||
* <pre>
|
||||
* String originalQueryAttribute = ruleContainer.getOriginalPathAttribute() + ORIGINAL_QUERYSTRING_ATTRIBUTE_SUFFIX;
|
||||
* </pre>
|
||||
*
|
||||
* @param originalPathAttribute the request attribute name used to store the request original path
|
||||
*/
|
||||
public void setOriginalPathAttribute(String originalPathAttribute)
|
||||
{
|
||||
|
@ -100,12 +106,14 @@ public class RuleContainer extends Rule implements Iterable<Rule>, Dumpable
|
|||
@Override
|
||||
public Request.WrapperProcessor matchAndApply(Request.WrapperProcessor input) throws IOException
|
||||
{
|
||||
if (_originalPathAttribute != null)
|
||||
String originalPathAttribute = getOriginalPathAttribute();
|
||||
if (originalPathAttribute != null)
|
||||
{
|
||||
HttpURI httpURI = input.getHttpURI();
|
||||
input.setAttribute(_originalPathAttribute, httpURI.getPath());
|
||||
if (_originalQueryStringAttribute != null)
|
||||
input.setAttribute(_originalQueryStringAttribute, httpURI.getQuery());
|
||||
input.setAttribute(originalPathAttribute, httpURI.getPath());
|
||||
String originalQueryStringAttribute = _originalQueryStringAttribute;
|
||||
if (originalQueryStringAttribute != null)
|
||||
input.setAttribute(originalQueryStringAttribute, httpURI.getQuery());
|
||||
}
|
||||
|
||||
boolean match = false;
|
||||
|
|
Loading…
Reference in New Issue