diff options
author | 2015-08-27 10:02:24 -0700 | |
---|---|---|
committer | 2015-08-27 10:04:43 -0700 | |
commit | 4ad400341e624947abbd08dd8ab8f06a6610b7e5 (patch) | |
tree | 58eea172f37ae1b98efdd26cb3b1c377dc9fc45f | |
parent | dde19d835e024aa39a778990b5efffef58b4fb8d (diff) |
Fixed handling of binary metadata values
-rw-r--r-- | src/node/ext/call.cc | 23 | ||||
-rw-r--r-- | src/node/src/metadata.js | 4 |
2 files changed, 15 insertions, 12 deletions
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc index 18858fa334..fddc1e214f 100644 --- a/src/node/ext/call.cc +++ b/src/node/ext/call.cc @@ -111,17 +111,19 @@ bool CreateMetadataArray(Handle<Object> metadata, grpc_metadata_array *array, NanAssignPersistent(*handle, value); resources->handles.push_back(unique_ptr<PersistentHolder>( new PersistentHolder(handle))); - continue; + } else { + return false; } - } - if (value->IsString()) { - Handle<String> string_value = value->ToString(); - NanUtf8String *utf8_value = new NanUtf8String(string_value); - resources->strings.push_back(unique_ptr<NanUtf8String>(utf8_value)); - current->value = **utf8_value; - current->value_length = string_value->Length(); } else { - return false; + if (value->IsString()) { + Handle<String> string_value = value->ToString(); + NanUtf8String *utf8_value = new NanUtf8String(string_value); + resources->strings.push_back(unique_ptr<NanUtf8String>(utf8_value)); + current->value = **utf8_value; + current->value_length = string_value->Length(); + } else { + return false; + } } array->count += 1; } @@ -156,8 +158,7 @@ Handle<Value> ParseMetadata(const grpc_metadata_array *metadata_array) { } if (EndsWith(elem->key, "-bin")) { array->Set(index_map[elem->key], - MakeFastBuffer( - NanNewBufferHandle(elem->value, elem->value_length))); + NanNewBufferHandle(elem->value, elem->value_length)); } else { array->Set(index_map[elem->key], NanNew(elem->value)); } diff --git a/src/node/src/metadata.js b/src/node/src/metadata.js index 65fd91f367..c1da70b197 100644 --- a/src/node/src/metadata.js +++ b/src/node/src/metadata.js @@ -147,7 +147,9 @@ Metadata.prototype.getMap = function() { */ Metadata.prototype.clone = function() { var copy = new Metadata(); - copy._internal_repr = _.cloneDeep(this._internal_repr); + _.forOwn(this._internal_repr, function(value, key) { + copy._internal_repr[key] = _.clone(value); + }); return copy; }; |