Skip to content

Commit

Permalink
fix: remove unused grpcws code
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Trost <[email protected]>
  • Loading branch information
galexrt committed Sep 14, 2024
1 parent 17e1cae commit 913d517
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pkg/grpc/grpcws/grpcweb_response.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ", "),
)
}
Expand Down
16 changes: 1 addition & 15 deletions pkg/grpc/grpcws/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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.
Expand Down
1 change: 1 addition & 0 deletions pkg/grpc/grpcws/wrapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit 913d517

Please sign in to comment.