Fixed issues with binary metadata type checking

pull/3099/head
murgatroid99 9 years ago
parent 9b701e9f58
commit f20d7db554
  1. 5
      src/node/ext/call.cc
  2. 5
      src/node/src/metadata.js

@ -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…
Cancel
Save