Skip to content

Commit

Permalink
gateway, api: canonicalize headers from user config
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>


This commit was moved from ipfs/kubo@4bbf4cc
  • Loading branch information
Stebalien committed Jan 4, 2019
1 parent faf068b commit f23457c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions gateway/core/corehttp/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) {
// Copy these because the config is shared and this function is called
// in multiple places concurrently. Updating these in-place *is* racy.
for h, v := range nc.API.HTTPHeaders {
h = http.CanonicalHeaderKey(h)
switch h {
case cmdsHttp.ACAOrigin, cmdsHttp.ACAMethods, cmdsHttp.ACACredentials:
// these are handled by the CORs library.
Expand Down
2 changes: 1 addition & 1 deletion gateway/core/corehttp/gateway.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption {

headers := make(map[string][]string, len(cfg.Gateway.HTTPHeaders))
for h, v := range cfg.Gateway.HTTPHeaders {
headers[h] = v
headers[http.CanonicalHeaderKey(h)] = v
}

// Hard-coded headers.
Expand Down

0 comments on commit f23457c

Please sign in to comment.