From 913d517e85dd88c3664b4eb684fdb042fb33fe9f Mon Sep 17 00:00:00 2001 From: Alexander Trost Date: Sat, 14 Sep 2024 23:46:43 +0200 Subject: [PATCH] fix: remove unused grpcws code Signed-off-by: Alexander Trost --- pkg/grpc/grpcws/grpcweb_response.go | 2 +- pkg/grpc/grpcws/header.go | 16 +--------------- pkg/grpc/grpcws/wrapper_test.go | 1 + 3 files changed, 3 insertions(+), 16 deletions(-) diff --git a/pkg/grpc/grpcws/grpcweb_response.go b/pkg/grpc/grpcws/grpcweb_response.go index 97b16e87e..90c6a810a 100644 --- a/pkg/grpc/grpcws/grpcweb_response.go +++ b/pkg/grpc/grpcws/grpcweb_response.go @@ -80,7 +80,7 @@ func (w *grpcWebResponse) prepareHeaders() { responseHeaderKeys := headerKeys(wh) responseHeaderKeys = append(responseHeaderKeys, "grpc-status", "grpc-message") wh.Set( - http.CanonicalHeaderKey("access-control-expose-headers"), + "access-control-expose-headers", strings.Join(responseHeaderKeys, ", "), ) } diff --git a/pkg/grpc/grpcws/header.go b/pkg/grpc/grpcws/header.go index 20d8b18da..ab52a922a 100644 --- a/pkg/grpc/grpcws/header.go +++ b/pkg/grpc/grpcws/header.go @@ -45,7 +45,7 @@ func replaceInVals(key, old, new string) copyOption { opts.replacers = append( opts.replacers, func(k string, vv []string) (string, []string, bool) { - if strings.ToLower(key) == strings.ToLower(k) { + if strings.EqualFold(key, k) { vv2 := make([]string, 0, len(vv)) for _, v := range vv { vv2 = append( @@ -91,20 +91,6 @@ func keyCase(fn func(string) string) copyOption { } } -// keyTrim returns an option to unconditionally trim the keys of the -// destination header with function fn. Typically fn can be -// strings.Trim, strings.TrimLeft/TrimRight, strings.TrimPrefix/TrimSuffix -func keyTrim(fn func(string, string) string, cut string) copyOption { - return func(opts *copyOptions) { - opts.replacers = append( - opts.replacers, - func(k string, vv []string) (string, []string, bool) { - return fn(k, cut), vv, true - }, - ) - } -} - // copyHeader copies src to dst header. This function does not uses http.Header // methods internally, so header keys are copied as is. If any key normalization // is required, use keyCase option. diff --git a/pkg/grpc/grpcws/wrapper_test.go b/pkg/grpc/grpcws/wrapper_test.go index bfc655dad..b43527b8c 100644 --- a/pkg/grpc/grpcws/wrapper_test.go +++ b/pkg/grpc/grpcws/wrapper_test.go @@ -392,6 +392,7 @@ func (s *GrpcWebWrapperTestSuite) TestPingStream_NormalGrpcWorks() { bidiClient.Send(&testproto.PingRequest{Value: "one"}) bidiClient.Send(&testproto.PingRequest{Value: "two"}) resp, err := bidiClient.CloseAndRecv() + assert.NoError(s.T(), err, "no error during execution") assert.Equal(s.T(), "one,two", resp.GetValue(), "expected concatenated value must be received") recvHeaders, err := bidiClient.Header() require.NoError(s.T(), err, "no error during execution")