From 0648d0953d11532f0de31d717eefe2506d538d34 Mon Sep 17 00:00:00 2001 From: Noah Dietz Date: Wed, 10 Jul 2019 17:40:45 -0700 Subject: [PATCH] Fix capital auth header (#5) * set auth header to lower-case to appease gRPC * release v0.1.3 --- release.sh | 2 +- server/server.go | 3 ++- server/util.go | 2 +- server/util_test.go | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/release.sh b/release.sh index 1e19609..ce105fb 100755 --- a/release.sh +++ b/release.sh @@ -16,7 +16,7 @@ set -e -VERSION=0.1.2 +VERSION=0.1.3 GO111MODULE=on GOPROXY=https://proxy.golang.org diff --git a/server/server.go b/server/server.go index 66ff5c2..204bf69 100644 --- a/server/server.go +++ b/server/server.go @@ -128,7 +128,7 @@ func (f *FallbackServer) handler(w http.ResponseWriter, r *http.Request) { b, _ = proto.Marshal(st.Proto()) } - log.Println(err) + log.Println("Error handling request:", r.RequestURI, "-", err) w.WriteHeader(code) w.Write(b) } @@ -152,6 +152,7 @@ func (f *FallbackServer) dial() (connection, error) { // options is a handler for the OPTIONS call that precedes CORS-enabled calls. func (f *FallbackServer) options(w http.ResponseWriter, r *http.Request) { + log.Println("Incoming OPTIONS for request:", r.RequestURI) w.Header().Add("access-control-allow-credentials", "true") w.Header().Add("access-control-allow-headers", "*") w.Header().Add("access-control-allow-methods", http.MethodPost) diff --git a/server/util.go b/server/util.go index 3c334bb..b281ff7 100644 --- a/server/util.go +++ b/server/util.go @@ -81,7 +81,7 @@ func prepareHeaders(ctx context.Context, hdr http.Header) context.Context { // copy Authorization header if auth := hdr.Get("Authorization"); auth != "" { - out["Authorization"] = append([]string{}, auth) + out.Set("authorization", auth) } // keep x-goog-* headers diff --git a/server/util_test.go b/server/util_test.go index 5478c0b..4f29c6b 100644 --- a/server/util_test.go +++ b/server/util_test.go @@ -60,7 +60,7 @@ func Test_prepareHeaders(t *testing.T) { hdr.Add("x-goog-api-key", "bar") want := map[string][]string{ - "Authorization": []string{"Bearer foo"}, + "authorization": []string{"Bearer foo"}, "x-goog-api-key": []string{"bar"}, }