Skip to content

Commit

Permalink
Require -bin suffix to accept binary grpc metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
sapphire-janrain committed Aug 21, 2023
1 parent f65127c commit 8e049d2
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/modules/k6/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,15 @@ func (c *Client) parseInvokeParams(paramsVal goja.Value) (*invokeParams, error)
// TODO(rogchap): Should we manage a string slice?
strval, ok := kv.(string)
if !ok {
binval, ok := kv.([]byte)
if !ok {
return result, fmt.Errorf("metadata %q value must be a string or []byte", hk)
if strings.HasSuffix(hk, "-bin") {
binval, ok := kv.([]byte)
if !ok {
return result, fmt.Errorf("metadata %q value must be a string or binary", hk)
}
strval = string(binval)
} else {
return result, fmt.Errorf("metadata %q value must be a string", hk)
}
strval = string(binval)
}
result.Metadata[hk] = strval
}
Expand Down

0 comments on commit 8e049d2

Please sign in to comment.