From defb94d257a2d43bf112fbd3088f29b96f8672a8 Mon Sep 17 00:00:00 2001 From: Josh Robson Chase Date: Tue, 31 Oct 2023 12:17:03 -0400 Subject: [PATCH] canonicalize header keys --- config/http_headers.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config/http_headers.go b/config/http_headers.go index 3f8d207..6d323ee 100644 --- a/config/http_headers.go +++ b/config/http_headers.go @@ -2,6 +2,7 @@ package config import ( "fmt" + "net/http" "golang.ngrok.com/ngrok/internal/pb" ) @@ -77,27 +78,27 @@ func WithHostHeaderRewrite(rewrite bool) HTTPEndpointOption { // WithRequestHeader adds a header to all requests to this edge. func WithRequestHeader(name, value string) HTTPEndpointOption { return requestHeaders(headers{ - Added: map[string]string{name: value}, + Added: map[string]string{http.CanonicalHeaderKey(name): value}, }) } // WithRequestHeader adds a header to all responses coming from this edge. func WithResponseHeader(name, value string) HTTPEndpointOption { return responseHeaders(headers{ - Added: map[string]string{name: value}, + Added: map[string]string{http.CanonicalHeaderKey(name): value}, }) } // WithRemoveRequestHeader removes a header from requests to this edge. func WithRemoveRequestHeader(name string) HTTPEndpointOption { return requestHeaders(headers{ - Removed: []string{name}, + Removed: []string{http.CanonicalHeaderKey(name)}, }) } // WithRemoveResponseHeader removes a header from responses from this edge. func WithRemoveResponseHeader(name string) HTTPEndpointOption { return responseHeaders(headers{ - Removed: []string{name}, + Removed: []string{http.CanonicalHeaderKey(name)}, }) }