Class HeaderRegexRule
java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.RegexRule
org.eclipse.jetty.rewrite.handler.HeaderRegexRule
Rule to add a header based on a Regex match
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.rewrite.handler.Rule
Rule.ApplyURI
-
Field Summary
Fields inherited from class org.eclipse.jetty.rewrite.handler.Rule
_handling, _terminating
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
apply
(String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Matcher matcher) Apply this rule to the request/response pair.getName()
Returns the header name.getValue()
Returns the header value.boolean
isAdd()
void
setAdd
(boolean add) Sets the Add flag.void
Sets the header name.void
Sets the header value.toString()
Returns the regular expression string.Methods inherited from class org.eclipse.jetty.rewrite.handler.RegexRule
getRegex, matchAndApply, setRegex
Methods inherited from class org.eclipse.jetty.rewrite.handler.Rule
isHandling, isTerminating, setHandling, setTerminating
-
Constructor Details
-
HeaderRegexRule
public HeaderRegexRule() -
HeaderRegexRule
-
-
Method Details
-
setName
Sets the header name.- Parameters:
name
- name of the header field
-
setValue
Sets the header value. The value can be either aString
orint
value.- Parameters:
value
- of the header field
-
setAdd
public void setAdd(boolean add) Sets the Add flag.- Parameters:
add
- If true, the header is added to the response, otherwise the header it is set on the response.
-
apply
protected String apply(String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, Matcher matcher) throws IOException Description copied from class:RegexRule
Apply this rule to the request/response pair. Called byRegexRule.matchAndApply(String, HttpServletRequest, HttpServletResponse)
if the regex matches.- Specified by:
apply
in classRegexRule
- Parameters:
target
- field to attempt matchrequest
- request objectresponse
- response objectmatcher
- The Regex matcher that matched the request (with capture groups available for replacement).- Returns:
- The target (possible updated).
- Throws:
IOException
- exceptions dealing with operating on request or response objects
-
getName
Returns the header name.- Returns:
- the header name.
-
getValue
Returns the header value.- Returns:
- the header value.
-
isAdd
public boolean isAdd()- Returns:
- the add flag value.
-
toString
Description copied from class:RegexRule
Returns the regular expression string.
-