Skip to content

Commit

Permalink
canonicalize header keys
Browse files Browse the repository at this point in the history
  • Loading branch information
jrobsonchase committed Oct 31, 2023
1 parent c0631f8 commit defb94d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions config/http_headers.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package config

import (
"fmt"
"net/http"

"golang.ngrok.com/ngrok/internal/pb"
)
Expand Down Expand Up @@ -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)},
})
}

0 comments on commit defb94d

Please sign in to comment.