@cryptotaxi247 / kubo / commits / 4bbf4cc9a

gateway, api: canonicalize headers from user config

License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Jan 4, 2019 at 13:00 UTC 4bbf4cc9a08a55f1e0f69447a06179f2106e48c0
2 files changed +2 -1
core/corehttp/commands.go
+1
@@ -72,6 +72,7 @@ func addHeadersFromConfig(c *cmdsHttp.ServerConfig, nc *config.Config) {
72 // Copy these because the config is shared and this function is called
73 // in multiple places concurrently. Updating these in-place *is* racy.
74 for h, v := range nc.API.HTTPHeaders {
75 + h = http.CanonicalHeaderKey(h)
76 switch h {
77 case cmdsHttp.ACAOrigin, cmdsHttp.ACAMethods, cmdsHttp.ACACredentials:
78 // these are handled by the CORs library.
core/corehttp/gateway.go
+1 -1
@@ -53,7 +53,7 @@ func GatewayOption(writable bool, paths ...string) ServeOption {
53
54 headers := make(map[string][]string, len(cfg.Gateway.HTTPHeaders))
55 for h, v := range cfg.Gateway.HTTPHeaders {
56 - headers[h] = v
56 + headers[http.CanonicalHeaderKey(h)] = v
57 }
58
59 // Hard-coded headers.