aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/node/ext/call.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/node/ext/call.cc')
-rw-r--r--src/node/ext/call.cc10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/node/ext/call.cc b/src/node/ext/call.cc
index c6e10bc1ff..da312886ce 100644
--- a/src/node/ext/call.cc
+++ b/src/node/ext/call.cc
@@ -1,6 +1,6 @@
/*
*
- * Copyright 2015, Google Inc.
+ * Copyright 2015-2016, Google Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -95,10 +95,6 @@ Local<Value> nanErrorWithCode(const char *msg, grpc_call_error code) {
return scope.Escape(err);
}
-bool EndsWith(const char *str, const char *substr) {
- return strcmp(str+strlen(str)-strlen(substr), substr) == 0;
-}
-
bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array,
shared_ptr<Resources> resources) {
HandleScope scope;
@@ -126,7 +122,7 @@ bool CreateMetadataArray(Local<Object> metadata, grpc_metadata_array *array,
grpc_metadata *current = &array->metadata[array->count];
current->key = **utf8_key;
// Only allow binary headers for "-bin" keys
- if (EndsWith(current->key, "-bin")) {
+ if (grpc_is_binary_header(current->key, strlen(current->key))) {
if (::node::Buffer::HasInstance(value)) {
current->value = ::node::Buffer::Data(value);
current->value_length = ::node::Buffer::Length(value);
@@ -180,7 +176,7 @@ Local<Value> ParseMetadata(const grpc_metadata_array *metadata_array) {
} else {
array = Local<Array>::Cast(maybe_array.ToLocalChecked());
}
- if (EndsWith(elem->key, "-bin")) {
+ if (grpc_is_binary_header(elem->key, strlen(elem->key))) {
Nan::Set(array, index_map[elem->key],
MakeFastBuffer(
Nan::CopyBuffer(elem->value,