Class HeaderRule

java.lang.Object
org.eclipse.jetty.rewrite.handler.Rule
org.eclipse.jetty.rewrite.handler.HeaderRule
Direct Known Subclasses:
ForwardedSchemeHeaderRule

public abstract class HeaderRule extends Rule

Abstract rule that matches against request headers.

  • Constructor Details

    • HeaderRule

      public HeaderRule()
  • Method Details

    • getHeaderName

      public String getHeaderName()
    • setHeaderName

      public void setHeaderName(String header)
    • getHeaderValue

      public String getHeaderValue()
    • setHeaderValue

      public void setHeaderValue(String headerValue)
      Parameters:
      headerValue - the header value to match against. If null, then the presence of the header is enough to match
    • matchAndApply

      public Rule.Handler matchAndApply(Rule.Handler input) throws IOException
      Description copied from class: Rule

      Tests whether the given input Handler (which wraps a Request) matches the rule, and if so returns an output Handler that applies the rule logic.

      If the input does not match, null is returned.

      Specified by:
      matchAndApply in class Rule
      Parameters:
      input - the input Handler that wraps the Request
      Returns:
      an output Handler that wraps the input Handler, or null if the rule does not match
      Throws:
      IOException - if applying the rule fails
    • apply

      protected abstract Rule.Handler apply(Rule.Handler input, String value) throws IOException

      Invoked after the header matched the Request headers to apply the rule's logic.

      Parameters:
      input - the input Request and Handler
      value - the header value
      Returns:
      the possibly wrapped Request and Handler
      Throws:
      IOException - if applying the rule failed
    • toString

      public String toString()
      Overrides:
      toString in class Rule