diff --git a/internal/pool/proxy.go b/internal/pool/proxy.go index 160e538..b3b07c9 100644 --- a/internal/pool/proxy.go +++ b/internal/pool/proxy.go @@ -177,13 +177,11 @@ func (p *URLRewriteProxy) updateRequestHeaders(req *http.Request) { req.Header.Set(HeaderXForwardedHost, originalHost) req.Header.Set(HeaderXForwardedFor, originalHost) - hc := p.headerConfig - if hc != nil { + if hc := p.headerConfig; hc != nil { for _, header := range hc.RemoveRequestHeaders { req.Header.Del(header) } - // Add/modify configured request headers for key, value := range hc.RequestHeaders { processedValue := p.processHeaderValue(value, req) req.Header.Set(key, processedValue) @@ -231,14 +229,11 @@ func (p *URLRewriteProxy) updateResponseHeaders(resp *http.Response) { resp.Header.Del(HeaderXPoweredBy) resp.Header.Set(HeaderXProxyBy, DefaultProxyLabel) - hc := p.headerConfig - if hc != nil { - // Remove specified response headers + if hc := p.headerConfig; hc != nil { for _, header := range hc.RemoveResponseHeaders { resp.Header.Del(header) } - // Add/modify configured response headers for key, value := range hc.ResponseHeaders { processedValue := p.processHeaderValue(value, resp.Request) resp.Header.Set(key, processedValue) @@ -274,6 +269,7 @@ func (p *URLRewriteProxy) errorHandler(w http.ResponseWriter, r *http.Request, e } // processHeaderValue replaces placeholder values with actual req values +// if string placeholders in not being used - it returns value back func (p *URLRewriteProxy) processHeaderValue(value string, req *http.Request) string { // Replace placeholders with actual values placeholders := map[string]func(*http.Request) string{