diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/census/grpc_filter.c | 2 | ||||
-rw-r--r-- | src/core/channel/compress_filter.c | 10 | ||||
-rw-r--r-- | src/core/channel/http_client_filter.c | 4 | ||||
-rw-r--r-- | src/core/channel/http_server_filter.c | 6 | ||||
-rw-r--r-- | src/core/security/client_auth_filter.c | 10 | ||||
-rw-r--r-- | src/core/surface/call.c | 6 | ||||
-rw-r--r-- | src/core/surface/channel.c | 25 | ||||
-rw-r--r-- | src/core/surface/server.c | 9 | ||||
-rw-r--r-- | src/core/transport/chttp2/stream_encoder.c | 4 | ||||
-rw-r--r-- | src/core/transport/chttp2_transport.c | 2 | ||||
-rw-r--r-- | src/core/transport/metadata.c | 44 | ||||
-rw-r--r-- | src/core/transport/metadata.h | 6 |
12 files changed, 45 insertions, 83 deletions
diff --git a/src/core/census/grpc_filter.c b/src/core/census/grpc_filter.c index 1830af3feb..3545307b66 100644 --- a/src/core/census/grpc_filter.c +++ b/src/core/census/grpc_filter.c @@ -168,7 +168,7 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, int is_first, int is_last) { channel_data *chand = elem->channel_data; GPR_ASSERT(chand != NULL); - chand->path_str = grpc_mdstr_from_string(mdctx, ":path", 0); + chand->path_str = grpc_mdstr_from_string(mdctx, ":path"); } static void destroy_channel_elem(grpc_exec_ctx *exec_ctx, diff --git a/src/core/channel/compress_filter.c b/src/core/channel/compress_filter.c index f8dbe8c817..2aa826fcd8 100644 --- a/src/core/channel/compress_filter.c +++ b/src/core/channel/compress_filter.c @@ -331,13 +331,13 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, channeld->default_compression_algorithm; channeld->mdstr_request_compression_algorithm_key = - grpc_mdstr_from_string(mdctx, GRPC_COMPRESS_REQUEST_ALGORITHM_KEY, 0); + grpc_mdstr_from_string(mdctx, GRPC_COMPRESS_REQUEST_ALGORITHM_KEY); channeld->mdstr_outgoing_compression_algorithm_key = - grpc_mdstr_from_string(mdctx, "grpc-encoding", 0); + grpc_mdstr_from_string(mdctx, "grpc-encoding"); channeld->mdstr_compression_capabilities_key = - grpc_mdstr_from_string(mdctx, "grpc-accept-encoding", 0); + grpc_mdstr_from_string(mdctx, "grpc-accept-encoding"); for (algo_idx = 0; algo_idx < GRPC_COMPRESS_ALGORITHMS_COUNT; ++algo_idx) { char *algorithm_name; @@ -351,7 +351,7 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, grpc_mdelem_from_metadata_strings( mdctx, GRPC_MDSTR_REF(channeld->mdstr_outgoing_compression_algorithm_key), - grpc_mdstr_from_string(mdctx, algorithm_name, 0)); + grpc_mdstr_from_string(mdctx, algorithm_name)); if (algo_idx > 0) { supported_algorithms_names[supported_algorithms_idx++] = algorithm_name; } @@ -365,7 +365,7 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, channeld->mdelem_accept_encoding = grpc_mdelem_from_metadata_strings( mdctx, GRPC_MDSTR_REF(channeld->mdstr_compression_capabilities_key), - grpc_mdstr_from_string(mdctx, accept_encoding_str, 0)); + grpc_mdstr_from_string(mdctx, accept_encoding_str)); gpr_free(accept_encoding_str); GPR_ASSERT(!is_last); diff --git a/src/core/channel/http_client_filter.c b/src/core/channel/http_client_filter.c index da33c956f7..d67dc37ad2 100644 --- a/src/core/channel/http_client_filter.c +++ b/src/core/channel/http_client_filter.c @@ -239,7 +239,7 @@ static grpc_mdstr *user_agent_from_args(grpc_mdctx *mdctx, tmp = gpr_strvec_flatten(&v, NULL); gpr_strvec_destroy(&v); - result = grpc_mdstr_from_string(mdctx, tmp, 0); + result = grpc_mdstr_from_string(mdctx, tmp); gpr_free(tmp); return result; @@ -267,7 +267,7 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, grpc_mdelem_from_strings(mdctx, "content-type", "application/grpc"); channeld->status = grpc_mdelem_from_strings(mdctx, ":status", "200"); channeld->user_agent = grpc_mdelem_from_metadata_strings( - mdctx, grpc_mdstr_from_string(mdctx, "user-agent", 0), + mdctx, grpc_mdstr_from_string(mdctx, "user-agent"), user_agent_from_args(mdctx, channel_args)); } diff --git a/src/core/channel/http_server_filter.c b/src/core/channel/http_server_filter.c index 549c1da580..5e6d684a52 100644 --- a/src/core/channel/http_server_filter.c +++ b/src/core/channel/http_server_filter.c @@ -273,9 +273,9 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, channeld->http_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "http"); channeld->https_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "https"); channeld->grpc_scheme = grpc_mdelem_from_strings(mdctx, ":scheme", "grpc"); - channeld->path_key = grpc_mdstr_from_string(mdctx, ":path", 0); - channeld->authority_key = grpc_mdstr_from_string(mdctx, ":authority", 0); - channeld->host_key = grpc_mdstr_from_string(mdctx, "host", 0); + channeld->path_key = grpc_mdstr_from_string(mdctx, ":path"); + channeld->authority_key = grpc_mdstr_from_string(mdctx, ":authority"); + channeld->host_key = grpc_mdstr_from_string(mdctx, "host"); channeld->content_type = grpc_mdelem_from_strings(mdctx, "content-type", "application/grpc"); diff --git a/src/core/security/client_auth_filter.c b/src/core/security/client_auth_filter.c index c152a06498..3f4c084ffc 100644 --- a/src/core/security/client_auth_filter.c +++ b/src/core/security/client_auth_filter.c @@ -326,12 +326,10 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, (grpc_channel_security_connector *)GRPC_SECURITY_CONNECTOR_REF( sc, "client_auth_filter"); chand->md_ctx = metadata_context; - chand->authority_string = - grpc_mdstr_from_string(chand->md_ctx, ":authority", 0); - chand->path_string = grpc_mdstr_from_string(chand->md_ctx, ":path", 0); - chand->error_msg_key = - grpc_mdstr_from_string(chand->md_ctx, "grpc-message", 0); - chand->status_key = grpc_mdstr_from_string(chand->md_ctx, "grpc-status", 0); + chand->authority_string = grpc_mdstr_from_string(chand->md_ctx, ":authority"); + chand->path_string = grpc_mdstr_from_string(chand->md_ctx, ":path"); + chand->error_msg_key = grpc_mdstr_from_string(chand->md_ctx, "grpc-message"); + chand->status_key = grpc_mdstr_from_string(chand->md_ctx, "grpc-status"); } /* Destructor for channel data */ diff --git a/src/core/surface/call.c b/src/core/surface/call.c index 51dcbeb1a1..0b917f1561 100644 --- a/src/core/surface/call.c +++ b/src/core/surface/call.c @@ -1030,7 +1030,7 @@ static int prepare_application_metadata(grpc_call *call, size_t count, GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data)); l->md = grpc_mdelem_from_string_and_buffer(call->metadata_context, md->key, (const gpr_uint8 *)md->value, - md->value_length, 1); + md->value_length); if (!grpc_mdstr_is_legal_header(l->md->key)) { gpr_log(GPR_ERROR, "attempt to send invalid metadata key: %s", grpc_mdstr_as_c_string(l->md->key)); @@ -1330,7 +1330,7 @@ grpc_call_error grpc_call_cancel_with_status(grpc_call *c, static grpc_call_error cancel_with_status(grpc_call *c, grpc_status_code status, const char *description) { grpc_mdstr *details = - description ? grpc_mdstr_from_string(c->metadata_context, description, 0) + description ? grpc_mdstr_from_string(c->metadata_context, description) : NULL; GPR_ASSERT(status != GRPC_STATUS_OK); @@ -1689,7 +1689,7 @@ grpc_call_error grpc_call_start_batch(grpc_call *call, const grpc_op *ops, op->data.send_status_from_server.status_details != NULL ? grpc_mdstr_from_string( call->metadata_context, - op->data.send_status_from_server.status_details, 0) + op->data.send_status_from_server.status_details) : NULL; req = &reqs[out++]; if (out > GRPC_IOREQ_OP_COUNT) { diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index 08d003daca..aed7a79e4e 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -104,22 +104,21 @@ grpc_channel *grpc_channel_create_from_filters( /* decremented by grpc_channel_destroy */ gpr_ref_init(&channel->refs, 1); channel->metadata_context = mdctx; - channel->grpc_status_string = grpc_mdstr_from_string(mdctx, "grpc-status", 0); + channel->grpc_status_string = grpc_mdstr_from_string(mdctx, "grpc-status"); channel->grpc_compression_algorithm_string = - grpc_mdstr_from_string(mdctx, "grpc-encoding", 0); + grpc_mdstr_from_string(mdctx, "grpc-encoding"); channel->grpc_encodings_accepted_by_peer_string = - grpc_mdstr_from_string(mdctx, "grpc-accept-encoding", 0); - channel->grpc_message_string = - grpc_mdstr_from_string(mdctx, "grpc-message", 0); + grpc_mdstr_from_string(mdctx, "grpc-accept-encoding"); + channel->grpc_message_string = grpc_mdstr_from_string(mdctx, "grpc-message"); for (i = 0; i < NUM_CACHED_STATUS_ELEMS; i++) { char buf[GPR_LTOA_MIN_BUFSIZE]; gpr_ltoa((long)i, buf); channel->grpc_status_elem[i] = grpc_mdelem_from_metadata_strings( mdctx, GRPC_MDSTR_REF(channel->grpc_status_string), - grpc_mdstr_from_string(mdctx, buf, 0)); + grpc_mdstr_from_string(mdctx, buf)); } - channel->path_string = grpc_mdstr_from_string(mdctx, ":path", 0); - channel->authority_string = grpc_mdstr_from_string(mdctx, ":authority", 0); + channel->path_string = grpc_mdstr_from_string(mdctx, ":path"); + channel->authority_string = grpc_mdstr_from_string(mdctx, ":authority"); gpr_mu_init(&channel->registered_call_mu); channel->registered_calls = NULL; @@ -219,11 +218,11 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, channel, parent_call, propagation_mask, cq, grpc_mdelem_from_metadata_strings( channel->metadata_context, GRPC_MDSTR_REF(channel->path_string), - grpc_mdstr_from_string(channel->metadata_context, method, 0)), + grpc_mdstr_from_string(channel->metadata_context, method)), host ? grpc_mdelem_from_metadata_strings( channel->metadata_context, GRPC_MDSTR_REF(channel->authority_string), - grpc_mdstr_from_string(channel->metadata_context, host, 0)) + grpc_mdstr_from_string(channel->metadata_context, host)) : NULL, deadline); } @@ -234,12 +233,12 @@ void *grpc_channel_register_call(grpc_channel *channel, const char *method, GPR_ASSERT(!reserved); rc->path = grpc_mdelem_from_metadata_strings( channel->metadata_context, GRPC_MDSTR_REF(channel->path_string), - grpc_mdstr_from_string(channel->metadata_context, method, 0)); + grpc_mdstr_from_string(channel->metadata_context, method)); rc->authority = host ? grpc_mdelem_from_metadata_strings( channel->metadata_context, GRPC_MDSTR_REF(channel->authority_string), - grpc_mdstr_from_string(channel->metadata_context, host, 0)) + grpc_mdstr_from_string(channel->metadata_context, host)) : NULL; gpr_mu_lock(&channel->registered_call_mu); rc->next = channel->registered_calls; @@ -358,7 +357,7 @@ grpc_mdelem *grpc_channel_get_reffed_status_elem(grpc_channel *channel, int i) { gpr_ltoa(i, tmp); return grpc_mdelem_from_metadata_strings( channel->metadata_context, GRPC_MDSTR_REF(channel->grpc_status_string), - grpc_mdstr_from_string(channel->metadata_context, tmp, 0)); + grpc_mdstr_from_string(channel->metadata_context, tmp)); } } diff --git a/src/core/surface/server.c b/src/core/surface/server.c index 27fc0945f9..41191ebf26 100644 --- a/src/core/surface/server.c +++ b/src/core/surface/server.c @@ -729,9 +729,8 @@ static void init_channel_elem(grpc_exec_ctx *exec_ctx, GPR_ASSERT(!is_last); chand->server = NULL; chand->channel = NULL; - chand->path_key = grpc_mdstr_from_string(metadata_context, ":path", 0); - chand->authority_key = - grpc_mdstr_from_string(metadata_context, ":authority", 0); + chand->path_key = grpc_mdstr_from_string(metadata_context, ":path"); + chand->authority_key = grpc_mdstr_from_string(metadata_context, ":authority"); chand->next = chand->prev = chand; chand->registered_methods = NULL; chand->connectivity_state = GRPC_CHANNEL_IDLE; @@ -959,8 +958,8 @@ void grpc_server_setup_transport(grpc_exec_ctx *exec_ctx, grpc_server *s, chand->registered_methods = gpr_malloc(alloc); memset(chand->registered_methods, 0, alloc); for (rm = s->registered_methods; rm; rm = rm->next) { - host = rm->host ? grpc_mdstr_from_string(mdctx, rm->host, 0) : NULL; - method = grpc_mdstr_from_string(mdctx, rm->method, 0); + host = rm->host ? grpc_mdstr_from_string(mdctx, rm->host) : NULL; + method = grpc_mdstr_from_string(mdctx, rm->method); hash = GRPC_MDSTR_KV_HASH(host ? host->hash : 0, method->hash); for (probes = 0; chand->registered_methods[(hash + probes) % slots] .server_registered_method != NULL; diff --git a/src/core/transport/chttp2/stream_encoder.c b/src/core/transport/chttp2/stream_encoder.c index eb02ccdec3..b1f1db05d2 100644 --- a/src/core/transport/chttp2/stream_encoder.c +++ b/src/core/transport/chttp2/stream_encoder.c @@ -466,7 +466,7 @@ static void deadline_enc(grpc_chttp2_hpack_compressor *c, gpr_timespec deadline, gpr_time_sub(deadline, gpr_now(deadline.clock_type)), timeout_str); mdelem = grpc_mdelem_from_metadata_strings( c->mdctx, GRPC_MDSTR_REF(c->timeout_key_str), - grpc_mdstr_from_string(c->mdctx, timeout_str, 0)); + grpc_mdstr_from_string(c->mdctx, timeout_str)); mdelem = hpack_enc(c, mdelem, st); if (mdelem) GRPC_MDELEM_UNREF(mdelem); } @@ -481,7 +481,7 @@ void grpc_chttp2_hpack_compressor_init(grpc_chttp2_hpack_compressor *c, grpc_mdctx *ctx) { memset(c, 0, sizeof(*c)); c->mdctx = ctx; - c->timeout_key_str = grpc_mdstr_from_string(ctx, "grpc-timeout", 0); + c->timeout_key_str = grpc_mdstr_from_string(ctx, "grpc-timeout"); } void grpc_chttp2_hpack_compressor_destroy(grpc_chttp2_hpack_compressor *c) { diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c index 1679e4345d..0202d53abd 100644 --- a/src/core/transport/chttp2_transport.c +++ b/src/core/transport/chttp2_transport.c @@ -243,7 +243,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->global.pings.next = t->global.pings.prev = &t->global.pings; t->parsing.is_client = is_client; t->parsing.str_grpc_timeout = - grpc_mdstr_from_string(t->metadata_context, "grpc-timeout", 0); + grpc_mdstr_from_string(t->metadata_context, "grpc-timeout"); t->parsing.deframe_state = is_client ? GRPC_DTS_FH_0 : GRPC_DTS_CLIENT_PREFIX_0; t->writing.is_client = is_client; diff --git a/src/core/transport/metadata.c b/src/core/transport/metadata.c index 9d135f4356..3dbb9f0b53 100644 --- a/src/core/transport/metadata.c +++ b/src/core/transport/metadata.c @@ -312,38 +312,7 @@ static void slice_unref(void *p) { unlock(ctx); } -grpc_mdstr *grpc_mdstr_from_string(grpc_mdctx *ctx, const char *str, - int canonicalize_key) { - if (canonicalize_key) { - size_t len; - size_t i; - int canonical = 1; - - for (i = 0; str[i]; i++) { - if (str[i] >= 'A' && str[i] <= 'Z') { - canonical = 0; - /* Keep going in loop just to get string length */ - } - } - len = i; - - if (canonical) { - return grpc_mdstr_from_buffer(ctx, (const gpr_uint8 *)str, len); - } else { - char *copy = gpr_malloc(len); - grpc_mdstr *ret; - for (i = 0; i < len; i++) { - if (str[i] >= 'A' && str[i] <= 'Z') { - copy[i] = (char)(str[i] - 'A' + 'a'); - } else { - copy[i] = str[i]; - } - } - ret = grpc_mdstr_from_buffer(ctx, (const gpr_uint8 *)copy, len); - gpr_free(copy); - return ret; - } - } +grpc_mdstr *grpc_mdstr_from_string(grpc_mdctx *ctx, const char *str) { return grpc_mdstr_from_buffer(ctx, (const gpr_uint8 *)str, strlen(str)); } @@ -524,9 +493,9 @@ grpc_mdelem *grpc_mdelem_from_metadata_strings(grpc_mdctx *ctx, grpc_mdelem *grpc_mdelem_from_strings(grpc_mdctx *ctx, const char *key, const char *value) { - return grpc_mdelem_from_metadata_strings( - ctx, grpc_mdstr_from_string(ctx, key, 0), - grpc_mdstr_from_string(ctx, value, 0)); + return grpc_mdelem_from_metadata_strings(ctx, + grpc_mdstr_from_string(ctx, key), + grpc_mdstr_from_string(ctx, value)); } grpc_mdelem *grpc_mdelem_from_slices(grpc_mdctx *ctx, gpr_slice key, @@ -538,10 +507,9 @@ grpc_mdelem *grpc_mdelem_from_slices(grpc_mdctx *ctx, gpr_slice key, grpc_mdelem *grpc_mdelem_from_string_and_buffer(grpc_mdctx *ctx, const char *key, const gpr_uint8 *value, - size_t value_length, - int canonicalize_key) { + size_t value_length) { return grpc_mdelem_from_metadata_strings( - ctx, grpc_mdstr_from_string(ctx, key, canonicalize_key), + ctx, grpc_mdstr_from_string(ctx, key), grpc_mdstr_from_buffer(ctx, value, value_length)); } diff --git a/src/core/transport/metadata.h b/src/core/transport/metadata.h index eb17747be7..136a65f288 100644 --- a/src/core/transport/metadata.h +++ b/src/core/transport/metadata.h @@ -95,8 +95,7 @@ size_t grpc_mdctx_get_mdtab_free_test_only(grpc_mdctx *mdctx); /* Constructors for grpc_mdstr instances; take a variety of data types that clients may have handy */ -grpc_mdstr *grpc_mdstr_from_string(grpc_mdctx *ctx, const char *str, - int perform_key_canonicalization); +grpc_mdstr *grpc_mdstr_from_string(grpc_mdctx *ctx, const char *str); /* Unrefs the slice. */ grpc_mdstr *grpc_mdstr_from_slice(grpc_mdctx *ctx, gpr_slice slice); grpc_mdstr *grpc_mdstr_from_buffer(grpc_mdctx *ctx, const gpr_uint8 *str, @@ -118,8 +117,7 @@ grpc_mdelem *grpc_mdelem_from_slices(grpc_mdctx *ctx, gpr_slice key, grpc_mdelem *grpc_mdelem_from_string_and_buffer(grpc_mdctx *ctx, const char *key, const gpr_uint8 *value, - size_t value_length, - int canonicalize_key); + size_t value_length); /* Mutator and accessor for grpc_mdelem user data. The destructor function is used as a type tag and is checked during user_data fetch. */ |