@@ -404,15 +404,18 @@ func (c *HAProxyController) handleRequestSetHdr(ingress *store.Ingress) {
404404 }
405405 // Configure annotation
406406 for _ , param := range strings .Split (annReqSetHdr .Value , "\n " ) {
407- parts := strings .Fields (param )
408- if len (parts ) != 2 {
407+ if param == "" {
408+ continue
409+ }
410+ indexSpace := strings .IndexByte (param , ' ' )
411+ if indexSpace == - 1 {
409412 logger .Errorf ("incorrect value '%s' in request-set-header annotation" , param )
410413 continue
411414 }
412415 logger .Tracef ("Ingress %s/%s: Configuring request set '%s' header " , ingress .Namespace , ingress .Name , param )
413416 reqSetHdr := rules.SetHdr {
414- HdrName : parts [ 0 ],
415- HdrFormat : parts [ 1 ] ,
417+ HdrName : param [: indexSpace ],
418+ HdrFormat : " \" " + param [ indexSpace + 1 :] + " \" " ,
416419 }
417420 logger .Error (c .Cfg .HAProxyRules .AddRule (reqSetHdr , ingress .Namespace + "-" + ingress .Name , c .Cfg .FrontHTTP , c .Cfg .FrontHTTPS ))
418421 }
@@ -441,7 +444,7 @@ func (c *HAProxyController) handleResponseSetHdr(ingress *store.Ingress) {
441444 logger .Tracef ("Ingress %s/%s: Configuring response set '%s' header " , ingress .Namespace , ingress .Name , param )
442445 resSetHdr := rules.SetHdr {
443446 HdrName : param [:indexSpace ],
444- HdrFormat : param [indexSpace + 1 :],
447+ HdrFormat : " \" " + param [indexSpace + 1 :] + " \" " ,
445448 Response : true ,
446449 }
447450 logger .Error (c .Cfg .HAProxyRules .AddRule (resSetHdr , ingress .Namespace + "-" + ingress .Name , c .Cfg .FrontHTTP , c .Cfg .FrontHTTPS ))
0 commit comments