[ https://issues.apache.org/jira/browse/TS-2962?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Phil Sorber updated TS-2962: ---------------------------- Fix Version/s: (was: 6.0.0) 6.1.0 > header_rewrite default "exists" matcher not working > --------------------------------------------------- > > Key: TS-2962 > URL: https://issues.apache.org/jira/browse/TS-2962 > Project: Traffic Server > Issue Type: Bug > Components: Plugins > Affects Versions: 5.0.1 > Reporter: Nick Muerdter > Assignee: Leif Hedstrom > Priority: Minor > Fix For: 6.1.0 > > > The > [documentation|https://docs.trafficserver.apache.org/en/latest/reference/plugins/header_rewrite.en.html#operands-to-conditions] > for the header_rewrite plugin indicates that if you don't specify a matcher > on a condition, then the matcher checks if a value exists. However, if I'm > understanding the intended behavior correctly, this is not the behavior I'm > seeing. If I don't specify an explicit matcher on the condition, then the > condition never seems to match (at least for http headers). > Here's a simplified example in a stock 5.0.1 installation that should add a > "{{X-Testing}}" header to the response if the "{{Surrogate-Control}}" header > exists on the response: > {code} > cond %{READ_RESPONSE_HDR_HOOK} > cond %{HEADER:Surrogate-Control} > add-header X-Testing Hello [L] > {code} > {code} > $ curl -I "http://localhost:8081/test" > HTTP/1.1 200 OK > X-Powered-By: Express > Surrogate-Control: max-age=60 > Date: Mon, 28 Jul 2014 06:19:43 GMT > Age: 0 > Connection: keep-alive > Server: ATS/5.0.1 > {code} > But as you can see from this response, no such header is added. > If I change the condition to a regex match for one or more characters, then > the header gets added as I expect: > {code} > cond %{READ_RESPONSE_HDR_HOOK} > cond %{HEADER:Surrogate-Control} /.+/ > add-header X-Testing Hello [L] > {code} > {code} > $ curl -I "http://localhost:8081/test" > HTTP/1.1 200 OK > X-Powered-By: Express > Surrogate-Control: max-age=60 > Date: Mon, 28 Jul 2014 06:19:12 GMT > X-Testing: Hello > Age: 0 > Connection: keep-alive > Server: ATS/5.0.1 > {code} > The regex based approach works fine, but it took me a while to realize what > was going on and figure this out (the primary example in the documentation > also seems to be utilizing this "exists" logic so that also doesn't work for > me). > So if the condition without an explicit matcher should check for a variable's > existence, that doesn't seem to be working. Alternatively, if the current > behavior is working as intended, then I think the documentation and examples > might need to be updated (and if that's the case, I'd be happy to take a stab > at that). -- This message was sent by Atlassian JIRA (v6.3.4#6332)