mirror of
https://github.com/grpc/grpc-node.git
synced 2025-12-08 18:23:54 +00:00
Fixed issues with binary metadata type checking
This commit is contained in:
parent
eecd1f524b
commit
9b0fbb4cf0
@ -168,8 +168,9 @@ Local<Value> ParseMetadata(const grpc_metadata_array *metadata_array) {
|
||||
}
|
||||
if (EndsWith(elem->key, "-bin")) {
|
||||
Nan::Set(array, index_map[elem->key],
|
||||
Nan::CopyBuffer(elem->value,
|
||||
elem->value_length).ToLocalChecked());
|
||||
MakeFastBuffer(
|
||||
Nan::CopyBuffer(elem->value,
|
||||
elem->value_length).ToLocalChecked()));
|
||||
} else {
|
||||
Nan::Set(array, index_map[elem->key],
|
||||
Nan::New(elem->value).ToLocalChecked());
|
||||
|
||||
@ -59,6 +59,7 @@ function normalizeKey(key) {
|
||||
function validate(key, value) {
|
||||
if (_.endsWith(key, '-bin')) {
|
||||
if (!(value instanceof Buffer)) {
|
||||
console.log(value.constructor.toString());
|
||||
throw new Error('keys that end with \'-bin\' must have Buffer values');
|
||||
}
|
||||
} else {
|
||||
@ -173,7 +174,9 @@ Metadata.prototype._getCoreRepresentation = function() {
|
||||
Metadata._fromCoreRepresentation = function(metadata) {
|
||||
var newMetadata = new Metadata();
|
||||
if (metadata) {
|
||||
newMetadata._internal_repr = _.cloneDeep(metadata);
|
||||
_.forOwn(metadata, function(value, key) {
|
||||
newMetadata._internal_repr[key] = _.clone(value);
|
||||
});
|
||||
}
|
||||
return newMetadata;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user