Uploaded image for project: 'Traffic Server'
  1. Traffic Server
  2. TS-4809

[header_rewrite] check to make sure "hook" conditions are first in the rule set

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 7.0.0
    • Plugins
    • None

    Description

      The following configuration

      $ cat etc/trafficserver/remap.config
      map http://example.com http://127.0.0.1:8888 \
          @plugin=header_rewrite.so @pparam=hdrs.config
      
      $ cat etc/trafficserver/hdrs.config
      cond %{TRUE}
      cond %{REMAP_PSEUDO_HOOK}
         set-header Some-Header "some value"
      

      Triggers the following error which does not show what and where the problem is:

      20160901.23h17m13s [header_rewrite] Unknown condition: REMAP_PSEUDO_HOOK
      

      I would like to add a check which will prevent the above error and print another error clarifying where and what the problem is, for instance:

      20160901.23h17m13s [header_rewrite] cond %{REMAP_PSEUDO_HOOK} should come first in the rule set at hdrs.config:2
      

      Attachments

        Issue Links

          Activity

            gancho Gancho Tenev added a comment - - edited

            Provided a patch which would error like this:

            20160901.23h17m13s [header_rewrite] cond %{REMAP_PSEUDO_HOOK} at hdrs.config:2 should be the first hook condition in the rule set and each rule set should contain only one hook condition
            

            In the following 2 use-cases:

            • The hook condition is not the first in the rule set.
              $ sudo cat etc/trafficserver/hdrs.config
              cond %{TRUE}
              cond %{REMAP_PSEUDO_HOOK}
                 set-header Some-Header "some value"
              
            • There are 2 hook conditions in the same rule set.
              $ sudo cat etc/trafficserver/hdrs.config
              cond %{REMAP_PSEUDO_HOOK}
              cond %{TRUE}
              cond %{SEND_RESPONSE_HDR_HOOK}
                 set-header Some-Header "some value"
              

            Also added line numbers to the error messages in RuleSet::add_condition() and RuleSet::add_operator().

            gancho Gancho Tenev added a comment - - edited Provided a patch which would error like this: 20160901.23h17m13s [header_rewrite] cond %{REMAP_PSEUDO_HOOK} at hdrs.config:2 should be the first hook condition in the rule set and each rule set should contain only one hook condition In the following 2 use-cases: The hook condition is not the first in the rule set. $ sudo cat etc/trafficserver/hdrs.config cond %{TRUE} cond %{REMAP_PSEUDO_HOOK} set-header Some-Header "some value" There are 2 hook conditions in the same rule set. $ sudo cat etc/trafficserver/hdrs.config cond %{REMAP_PSEUDO_HOOK} cond %{TRUE} cond %{SEND_RESPONSE_HDR_HOOK} set-header Some-Header "some value" Also added line numbers to the error messages in RuleSet::add_condition() and RuleSet::add_operator() .

            People

              gancho Gancho Tenev
              gancho Gancho Tenev
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1.5h
                  1.5h