aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Makarand Dharmapurikar <makarandd@google.com>2017-04-13 12:45:18 -0700
committerGravatar Makarand Dharmapurikar <makarandd@google.com>2017-04-13 12:45:18 -0700
commit63ed60f0483523522067d098abb6044ab6b99e27 (patch)
tree6b9c89843233ecb3480254864b5a1b917b98e8d1
parent7fb4036a172f23f6d2bf6b451c1052f9495c880d (diff)
using grpc_base64_decode_with_len to simplify code
-rw-r--r--src/core/lib/channel/http_server_filter.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c
index 45dcc26f9a..ebcde5315f 100644
--- a/src/core/lib/channel/http_server_filter.c
+++ b/src/core/lib/channel/http_server_filter.c
@@ -228,8 +228,6 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
if (offset < path_length) {
grpc_slice query_slice =
grpc_slice_sub(path_slice, offset + 1, path_length);
- /* add a trailing '\0' before decoding */
- const char *b64_data = grpc_slice_to_c_string(query_slice);
/* substitute path metadata with just the path (not query) */
grpc_mdelem mdelem_path_without_query = grpc_mdelem_from_slices(
@@ -240,12 +238,14 @@ static grpc_error *server_filter_incoming_metadata(grpc_exec_ctx *exec_ctx,
/* decode payload from query and add to the slice buffer to be returned */
const int k_url_safe = 1;
- grpc_slice_buffer_add(&calld->read_slice_buffer,
- grpc_base64_decode(exec_ctx, b64_data, k_url_safe));
+ grpc_slice_buffer_add(
+ &calld->read_slice_buffer,
+ grpc_base64_decode_with_len(
+ exec_ctx, (const char *)GRPC_SLICE_START_PTR(query_slice),
+ GRPC_SLICE_LENGTH(query_slice), k_url_safe));
grpc_slice_buffer_stream_init(&calld->read_stream,
&calld->read_slice_buffer, 0);
calld->seen_path_with_query = true;
- gpr_free((void *)b64_data);
grpc_slice_unref_internal(exec_ctx, query_slice);
} else {
gpr_log(GPR_ERROR, "GET request without QUERY");