Skip to content

Commit

Permalink
BUG/MINOR: fix header value handling in request-set-header and respon…
Browse files Browse the repository at this point in the history
…se-set-header
  • Loading branch information
ivanmatmati authored and oktalz committed Jul 12, 2021
1 parent 2383028 commit 8f549c4
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions controller/frontend-annotations.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,15 +404,18 @@ func (c *HAProxyController) handleRequestSetHdr(ingress *store.Ingress) {
}
// Configure annotation
for _, param := range strings.Split(annReqSetHdr.Value, "\n") {
parts := strings.Fields(param)
if len(parts) != 2 {
if param == "" {
continue
}
indexSpace := strings.IndexByte(param, ' ')
if indexSpace == -1 {
logger.Errorf("incorrect value '%s' in request-set-header annotation", param)
continue
}
logger.Tracef("Ingress %s/%s: Configuring request set '%s' header ", ingress.Namespace, ingress.Name, param)
reqSetHdr := rules.SetHdr{
HdrName: parts[0],
HdrFormat: parts[1],
HdrName: param[:indexSpace],
HdrFormat: "\"" + param[indexSpace+1:] + "\"",
}
logger.Error(c.Cfg.HAProxyRules.AddRule(reqSetHdr, ingress.Namespace+"-"+ingress.Name, c.Cfg.FrontHTTP, c.Cfg.FrontHTTPS))
}
Expand Down Expand Up @@ -441,7 +444,7 @@ func (c *HAProxyController) handleResponseSetHdr(ingress *store.Ingress) {
logger.Tracef("Ingress %s/%s: Configuring response set '%s' header ", ingress.Namespace, ingress.Name, param)
resSetHdr := rules.SetHdr{
HdrName: param[:indexSpace],
HdrFormat: param[indexSpace+1:],
HdrFormat: "\"" + param[indexSpace+1:] + "\"",
Response: true,
}
logger.Error(c.Cfg.HAProxyRules.AddRule(resSetHdr, ingress.Namespace+"-"+ingress.Name, c.Cfg.FrontHTTP, c.Cfg.FrontHTTPS))
Expand Down

0 comments on commit 8f549c4

Please sign in to comment.