Begin moving mdelem to be a value type

reviewable/pr8842/r1
Craig Tiller 8 years ago
parent b2348ba1db
commit 0160de9ae5
  1. 4
      src/core/ext/lb_policy/grpclb/grpclb.c
  2. 8
      src/core/ext/load_reporting/load_reporting_filter.c
  3. 16
      src/core/ext/transport/chttp2/transport/hpack_encoder.c
  4. 2
      src/core/ext/transport/chttp2/transport/hpack_encoder.h
  5. 12
      src/core/ext/transport/chttp2/transport/hpack_parser.c
  6. 2
      src/core/ext/transport/chttp2/transport/hpack_parser.h
  7. 14
      src/core/ext/transport/chttp2/transport/hpack_table.c
  8. 10
      src/core/ext/transport/chttp2/transport/hpack_table.h
  9. 2
      src/core/ext/transport/chttp2/transport/incoming_metadata.c
  10. 2
      src/core/ext/transport/chttp2/transport/incoming_metadata.h
  11. 6
      src/core/ext/transport/chttp2/transport/parsing.c
  12. 2
      src/core/ext/transport/cronet/transport/cronet_transport.c
  13. 15
      src/core/lib/channel/compress_filter.c
  14. 74
      src/core/lib/channel/http_client_filter.c
  15. 82
      src/core/lib/channel/http_server_filter.c
  16. 2
      src/core/lib/compression/algorithm_metadata.h
  17. 4
      src/core/lib/compression/compression.c
  18. 2
      src/core/lib/security/transport/client_auth_filter.c
  19. 6
      src/core/lib/security/transport/server_auth_filter.c
  20. 86
      src/core/lib/surface/call.c
  21. 2
      src/core/lib/surface/call.h
  22. 14
      src/core/lib/surface/channel.c
  23. 2
      src/core/lib/surface/channel.h
  24. 4
      src/core/lib/surface/server.c
  25. 53
      src/core/lib/transport/metadata.c
  26. 37
      src/core/lib/transport/metadata.h
  27. 18
      src/core/lib/transport/metadata_batch.c
  28. 10
      src/core/lib/transport/metadata_batch.h
  29. 10
      src/core/lib/transport/static_metadata.c
  30. 206
      src/core/lib/transport/static_metadata.h
  31. 2
      src/core/lib/transport/transport_op_string.c
  32. 2
      src/cpp/common/channel_filter.h
  33. 2
      test/core/compression/algorithm_test.c
  34. 2
      test/core/transport/chttp2/hpack_encoder_test.c
  35. 2
      test/core/transport/chttp2/hpack_parser_fuzzer_test.c
  36. 2
      test/core/transport/chttp2/hpack_parser_test.c
  37. 8
      test/core/transport/chttp2/hpack_table_test.c
  38. 18
      test/core/transport/metadata_test.c
  39. 16
      tools/codegen/core/gen_static_metadata.py

@ -135,7 +135,7 @@ int grpc_lb_glb_trace = 0;
* metadata */ * metadata */
static void initial_metadata_add_lb_token( static void initial_metadata_add_lb_token(
grpc_metadata_batch *initial_metadata, grpc_metadata_batch *initial_metadata,
grpc_linked_mdelem *lb_token_mdelem_storage, grpc_mdelem *lb_token) { grpc_linked_mdelem *lb_token_mdelem_storage, grpc_mdelem lb_token) {
GPR_ASSERT(lb_token_mdelem_storage != NULL); GPR_ASSERT(lb_token_mdelem_storage != NULL);
GPR_ASSERT(lb_token != NULL); GPR_ASSERT(lb_token != NULL);
grpc_metadata_batch_add_tail(initial_metadata, lb_token_mdelem_storage, grpc_metadata_batch_add_tail(initial_metadata, lb_token_mdelem_storage,
@ -159,7 +159,7 @@ typedef struct wrapped_rr_closure_arg {
grpc_connected_subchannel **target; grpc_connected_subchannel **target;
/* the LB token associated with the pick */ /* the LB token associated with the pick */
grpc_mdelem *lb_token; grpc_mdelem lb_token;
/* storage for the lb token initial metadata mdelem */ /* storage for the lb token initial metadata mdelem */
grpc_linked_mdelem *lb_token_mdelem_storage; grpc_linked_mdelem *lb_token_mdelem_storage;

@ -72,8 +72,8 @@ typedef struct {
grpc_exec_ctx *exec_ctx; grpc_exec_ctx *exec_ctx;
} recv_md_filter_args; } recv_md_filter_args;
static grpc_mdelem *recv_md_filter(grpc_exec_ctx *exec_ctx, void *user_data, static grpc_mdelem recv_md_filter(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_mdelem *md) { grpc_mdelem md) {
recv_md_filter_args *a = user_data; recv_md_filter_args *a = user_data;
grpc_call_element *elem = a->elem; grpc_call_element *elem = a->elem;
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
@ -196,8 +196,8 @@ static void destroy_channel_elem(grpc_exec_ctx *exec_ctx,
*/ */
} }
static grpc_mdelem *lr_trailing_md_filter(grpc_exec_ctx *exec_ctx, static grpc_mdelem lr_trailing_md_filter(grpc_exec_ctx *exec_ctx,
void *user_data, grpc_mdelem *md) { void *user_data, grpc_mdelem md) {
grpc_call_element *elem = user_data; grpc_call_element *elem = user_data;
call_data *calld = elem->call_data; call_data *calld = elem->call_data;

@ -189,7 +189,7 @@ static void evict_entry(grpc_chttp2_hpack_compressor *c) {
/* add an element to the decoder table */ /* add an element to the decoder table */
static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c, static void add_elem(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem) { grpc_mdelem elem) {
uint32_t key_hash = grpc_slice_hash(elem->key); uint32_t key_hash = grpc_slice_hash(elem->key);
uint32_t value_hash = grpc_slice_hash(elem->value); uint32_t value_hash = grpc_slice_hash(elem->value);
uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash); uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
@ -285,7 +285,7 @@ static void emit_indexed(grpc_chttp2_hpack_compressor *c, uint32_t elem_index,
len); len);
} }
static grpc_slice get_wire_value(grpc_mdelem *elem, uint8_t *huffman_prefix) { static grpc_slice get_wire_value(grpc_mdelem elem, uint8_t *huffman_prefix) {
if (grpc_is_binary_header(elem->key)) { if (grpc_is_binary_header(elem->key)) {
*huffman_prefix = 0x80; *huffman_prefix = 0x80;
return grpc_chttp2_base64_encode_and_huffman_compress(elem->value); return grpc_chttp2_base64_encode_and_huffman_compress(elem->value);
@ -296,7 +296,7 @@ static grpc_slice get_wire_value(grpc_mdelem *elem, uint8_t *huffman_prefix) {
} }
static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c, static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
uint32_t key_index, grpc_mdelem *elem, uint32_t key_index, grpc_mdelem elem,
framer_state *st) { framer_state *st) {
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2); uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
uint8_t huffman_prefix; uint8_t huffman_prefix;
@ -313,7 +313,7 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
} }
static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c, static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
uint32_t key_index, grpc_mdelem *elem, uint32_t key_index, grpc_mdelem elem,
framer_state *st) { framer_state *st) {
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
uint8_t huffman_prefix; uint8_t huffman_prefix;
@ -330,7 +330,7 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
} }
static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c, static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) { grpc_mdelem elem, framer_state *st) {
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem->key); uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem->key);
uint8_t huffman_prefix; uint8_t huffman_prefix;
grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); grpc_slice value_slice = get_wire_value(elem, &huffman_prefix);
@ -349,7 +349,7 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
} }
static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c, static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) { grpc_mdelem elem, framer_state *st) {
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem->key); uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem->key);
uint8_t huffman_prefix; uint8_t huffman_prefix;
grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); grpc_slice value_slice = get_wire_value(elem, &huffman_prefix);
@ -382,7 +382,7 @@ static uint32_t dynidx(grpc_chttp2_hpack_compressor *c, uint32_t elem_index) {
/* encode an mdelem */ /* encode an mdelem */
static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c, static void hpack_enc(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) { grpc_mdelem elem, framer_state *st) {
uint32_t key_hash = grpc_slice_hash(elem->key); uint32_t key_hash = grpc_slice_hash(elem->key);
uint32_t value_hash = grpc_slice_hash(elem->value); uint32_t value_hash = grpc_slice_hash(elem->value);
uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash); uint32_t elem_hash = GRPC_MDSTR_KV_HASH(key_hash, value_hash);
@ -479,7 +479,7 @@ static void deadline_enc(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hpack_compressor *c, gpr_timespec deadline, grpc_chttp2_hpack_compressor *c, gpr_timespec deadline,
framer_state *st) { framer_state *st) {
char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE]; char timeout_str[GRPC_HTTP2_TIMEOUT_ENCODE_MIN_BUFSIZE];
grpc_mdelem *mdelem; grpc_mdelem mdelem;
grpc_http2_encode_timeout( grpc_http2_encode_timeout(
gpr_time_sub(deadline, gpr_now(deadline.clock_type)), timeout_str); gpr_time_sub(deadline, gpr_now(deadline.clock_type)), timeout_str);
mdelem = grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_TIMEOUT, mdelem = grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_TIMEOUT,

@ -75,7 +75,7 @@ typedef struct {
/* entry tables for keys & elems: these tables track values that have been /* entry tables for keys & elems: these tables track values that have been
seen and *may* be in the decompressor table */ seen and *may* be in the decompressor table */
grpc_slice entries_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES]; grpc_slice entries_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
grpc_mdelem *entries_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES]; grpc_mdelem entries_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];
uint32_t indices_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES]; uint32_t indices_keys[GRPC_CHTTP2_HPACKC_NUM_VALUES];
uint32_t indices_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES]; uint32_t indices_elems[GRPC_CHTTP2_HPACKC_NUM_VALUES];

@ -669,7 +669,7 @@ static const uint8_t inverse_base64[256] = {
/* emission helpers */ /* emission helpers */
static grpc_error *on_hdr(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p, static grpc_error *on_hdr(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *p,
grpc_mdelem *md, int add_to_table) { grpc_mdelem md, int add_to_table) {
if (add_to_table) { if (add_to_table) {
grpc_error *err = grpc_chttp2_hptbl_add(exec_ctx, &p->table, md); grpc_error *err = grpc_chttp2_hptbl_add(exec_ctx, &p->table, md);
if (err != GRPC_ERROR_NONE) return err; if (err != GRPC_ERROR_NONE) return err;
@ -772,7 +772,7 @@ static grpc_error *finish_indexed_field(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hpack_parser *p, grpc_chttp2_hpack_parser *p,
const uint8_t *cur, const uint8_t *cur,
const uint8_t *end) { const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index); grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (md == NULL) { if (md == NULL) {
return grpc_error_set_int( return grpc_error_set_int(
grpc_error_set_int(GRPC_ERROR_CREATE("Invalid HPACK index received"), grpc_error_set_int(GRPC_ERROR_CREATE("Invalid HPACK index received"),
@ -814,7 +814,7 @@ static grpc_error *finish_lithdr_incidx(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hpack_parser *p, grpc_chttp2_hpack_parser *p,
const uint8_t *cur, const uint8_t *cur,
const uint8_t *end) { const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index); grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(md != NULL); /* handled in string parsing */ GPR_ASSERT(md != NULL); /* handled in string parsing */
grpc_error *err = grpc_error *err =
on_hdr(exec_ctx, p, on_hdr(exec_ctx, p,
@ -883,7 +883,7 @@ static grpc_error *finish_lithdr_notidx(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hpack_parser *p, grpc_chttp2_hpack_parser *p,
const uint8_t *cur, const uint8_t *cur,
const uint8_t *end) { const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index); grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(md != NULL); /* handled in string parsing */ GPR_ASSERT(md != NULL); /* handled in string parsing */
grpc_error *err = grpc_error *err =
on_hdr(exec_ctx, p, on_hdr(exec_ctx, p,
@ -952,7 +952,7 @@ static grpc_error *finish_lithdr_nvridx(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hpack_parser *p, grpc_chttp2_hpack_parser *p,
const uint8_t *cur, const uint8_t *cur,
const uint8_t *end) { const uint8_t *end) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(&p->table, p->index); grpc_mdelem md = grpc_chttp2_hptbl_lookup(&p->table, p->index);
GPR_ASSERT(md != NULL); /* handled in string parsing */ GPR_ASSERT(md != NULL); /* handled in string parsing */
grpc_error *err = grpc_error *err =
on_hdr(exec_ctx, p, on_hdr(exec_ctx, p,
@ -1500,7 +1500,7 @@ static bool is_binary_literal_header(grpc_chttp2_hpack_parser *p) {
static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p, static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p,
bool *is) { bool *is) {
grpc_mdelem *elem = grpc_chttp2_hptbl_lookup(&p->table, p->index); grpc_mdelem elem = grpc_chttp2_hptbl_lookup(&p->table, p->index);
if (!elem) { if (!elem) {
return grpc_error_set_int( return grpc_error_set_int(
grpc_error_set_int(GRPC_ERROR_CREATE("Invalid HPACK index received"), grpc_error_set_int(GRPC_ERROR_CREATE("Invalid HPACK index received"),

@ -56,7 +56,7 @@ typedef struct {
struct grpc_chttp2_hpack_parser { struct grpc_chttp2_hpack_parser {
/* user specified callback for each header output */ /* user specified callback for each header output */
void (*on_header)(grpc_exec_ctx *exec_ctx, void *user_data, grpc_mdelem *md); void (*on_header)(grpc_exec_ctx *exec_ctx, void *user_data, grpc_mdelem md);
void *on_header_user_data; void *on_header_user_data;
grpc_error *last_error; grpc_error *last_error;

@ -211,7 +211,7 @@ void grpc_chttp2_hptbl_destroy(grpc_exec_ctx *exec_ctx,
gpr_free(tbl->ents); gpr_free(tbl->ents);
} }
grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl, grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
uint32_t tbl_index) { uint32_t tbl_index) {
/* Static table comes first, just return an entry from it */ /* Static table comes first, just return an entry from it */
if (tbl_index <= GRPC_CHTTP2_LAST_STATIC_ENTRY) { if (tbl_index <= GRPC_CHTTP2_LAST_STATIC_ENTRY) {
@ -230,7 +230,7 @@ grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
/* Evict one element from the table */ /* Evict one element from the table */
static void evict1(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) { static void evict1(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
grpc_mdelem *first_ent = tbl->ents[tbl->first_ent]; grpc_mdelem first_ent = tbl->ents[tbl->first_ent];
size_t elem_bytes = GRPC_SLICE_LENGTH(first_ent->key) + size_t elem_bytes = GRPC_SLICE_LENGTH(first_ent->key) +
GRPC_SLICE_LENGTH(first_ent->value) + GRPC_SLICE_LENGTH(first_ent->value) +
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD; GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
@ -242,7 +242,7 @@ static void evict1(grpc_exec_ctx *exec_ctx, grpc_chttp2_hptbl *tbl) {
} }
static void rebuild_ents(grpc_chttp2_hptbl *tbl, uint32_t new_cap) { static void rebuild_ents(grpc_chttp2_hptbl *tbl, uint32_t new_cap) {
grpc_mdelem **ents = gpr_malloc(sizeof(*ents) * new_cap); grpc_mdelem *ents = gpr_malloc(sizeof(*ents) * new_cap);
uint32_t i; uint32_t i;
for (i = 0; i < tbl->num_ents; i++) { for (i = 0; i < tbl->num_ents; i++) {
@ -304,7 +304,7 @@ grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
} }
grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx, grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hptbl *tbl, grpc_mdelem *md) { grpc_chttp2_hptbl *tbl, grpc_mdelem md) {
/* determine how many bytes of buffer this entry represents */ /* determine how many bytes of buffer this entry represents */
size_t elem_bytes = GRPC_SLICE_LENGTH(md->key) + size_t elem_bytes = GRPC_SLICE_LENGTH(md->key) +
GRPC_SLICE_LENGTH(md->value) + GRPC_SLICE_LENGTH(md->value) +
@ -355,13 +355,13 @@ grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
} }
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find( grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
const grpc_chttp2_hptbl *tbl, grpc_mdelem *md) { const grpc_chttp2_hptbl *tbl, grpc_mdelem md) {
grpc_chttp2_hptbl_find_result r = {0, 0}; grpc_chttp2_hptbl_find_result r = {0, 0};
uint32_t i; uint32_t i;
/* See if the string is in the static table */ /* See if the string is in the static table */
for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) { for (i = 0; i < GRPC_CHTTP2_LAST_STATIC_ENTRY; i++) {
grpc_mdelem *ent = tbl->static_ents[i]; grpc_mdelem ent = tbl->static_ents[i];
if (grpc_slice_cmp(md->key, ent->key) != 0) continue; if (grpc_slice_cmp(md->key, ent->key) != 0) continue;
r.index = i + 1u; r.index = i + 1u;
r.has_value = grpc_slice_cmp(md->value, ent->value) == 0; r.has_value = grpc_slice_cmp(md->value, ent->value) == 0;
@ -372,7 +372,7 @@ grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
for (i = 0; i < tbl->num_ents; i++) { for (i = 0; i < tbl->num_ents; i++) {
uint32_t idx = uint32_t idx =
(uint32_t)(tbl->num_ents - i + GRPC_CHTTP2_LAST_STATIC_ENTRY); (uint32_t)(tbl->num_ents - i + GRPC_CHTTP2_LAST_STATIC_ENTRY);
grpc_mdelem *ent = tbl->ents[(tbl->first_ent + i) % tbl->cap_entries]; grpc_mdelem ent = tbl->ents[(tbl->first_ent + i) % tbl->cap_entries];
if (grpc_slice_cmp(md->key, ent->key) != 0) continue; if (grpc_slice_cmp(md->key, ent->key) != 0) continue;
r.index = idx; r.index = idx;
r.has_value = grpc_slice_cmp(md->value, ent->value) == 0; r.has_value = grpc_slice_cmp(md->value, ent->value) == 0;

@ -79,8 +79,8 @@ typedef struct {
/* a circular buffer of headers - this is stored in the opposite order to /* a circular buffer of headers - this is stored in the opposite order to
what hpack specifies, in order to simplify table management a little... what hpack specifies, in order to simplify table management a little...
meaning lookups need to SUBTRACT from the end position */ meaning lookups need to SUBTRACT from the end position */
grpc_mdelem **ents; grpc_mdelem *ents;
grpc_mdelem *static_ents[GRPC_CHTTP2_LAST_STATIC_ENTRY]; grpc_mdelem static_ents[GRPC_CHTTP2_LAST_STATIC_ENTRY];
} grpc_chttp2_hptbl; } grpc_chttp2_hptbl;
/* initialize a hpack table */ /* initialize a hpack table */
@ -94,12 +94,12 @@ grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_exec_ctx *exec_ctx,
uint32_t bytes); uint32_t bytes);
/* lookup a table entry based on its hpack index */ /* lookup a table entry based on its hpack index */
grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl, grpc_mdelem grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
uint32_t index); uint32_t index);
/* add a table entry to the index */ /* add a table entry to the index */
grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx, grpc_error *grpc_chttp2_hptbl_add(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hptbl *tbl, grpc_chttp2_hptbl *tbl,
grpc_mdelem *md) GRPC_MUST_USE_RESULT; grpc_mdelem md) GRPC_MUST_USE_RESULT;
/* Find a key/value pair in the table... returns the index in the table of the /* Find a key/value pair in the table... returns the index in the table of the
most similar entry, or 0 if the value was not found */ most similar entry, or 0 if the value was not found */
typedef struct { typedef struct {
@ -107,6 +107,6 @@ typedef struct {
int has_value; int has_value;
} grpc_chttp2_hptbl_find_result; } grpc_chttp2_hptbl_find_result;
grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find( grpc_chttp2_hptbl_find_result grpc_chttp2_hptbl_find(
const grpc_chttp2_hptbl *tbl, grpc_mdelem *md); const grpc_chttp2_hptbl *tbl, grpc_mdelem md);
#endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H */ #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H */

@ -57,7 +57,7 @@ void grpc_chttp2_incoming_metadata_buffer_destroy(
} }
void grpc_chttp2_incoming_metadata_buffer_add( void grpc_chttp2_incoming_metadata_buffer_add(
grpc_chttp2_incoming_metadata_buffer *buffer, grpc_mdelem *elem) { grpc_chttp2_incoming_metadata_buffer *buffer, grpc_mdelem elem) {
GPR_ASSERT(!buffer->published); GPR_ASSERT(!buffer->published);
if (buffer->capacity == buffer->count) { if (buffer->capacity == buffer->count) {
buffer->capacity = GPR_MAX(8, 2 * buffer->capacity); buffer->capacity = GPR_MAX(8, 2 * buffer->capacity);

@ -54,7 +54,7 @@ void grpc_chttp2_incoming_metadata_buffer_publish(
grpc_chttp2_incoming_metadata_buffer *buffer, grpc_metadata_batch *batch); grpc_chttp2_incoming_metadata_buffer *buffer, grpc_metadata_batch *batch);
void grpc_chttp2_incoming_metadata_buffer_add( void grpc_chttp2_incoming_metadata_buffer_add(
grpc_chttp2_incoming_metadata_buffer *buffer, grpc_mdelem *elem); grpc_chttp2_incoming_metadata_buffer *buffer, grpc_mdelem elem);
void grpc_chttp2_incoming_metadata_buffer_set_deadline( void grpc_chttp2_incoming_metadata_buffer_set_deadline(
grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline); grpc_chttp2_incoming_metadata_buffer *buffer, gpr_timespec deadline);

@ -336,7 +336,7 @@ static grpc_error *skip_parser(grpc_exec_ctx *exec_ctx, void *parser,
return GRPC_ERROR_NONE; return GRPC_ERROR_NONE;
} }
static void skip_header(grpc_exec_ctx *exec_ctx, void *tp, grpc_mdelem *md) { static void skip_header(grpc_exec_ctx *exec_ctx, void *tp, grpc_mdelem md) {
GRPC_MDELEM_UNREF(exec_ctx, md); GRPC_MDELEM_UNREF(exec_ctx, md);
} }
@ -444,7 +444,7 @@ error_handler:
static void free_timeout(void *p) { gpr_free(p); } static void free_timeout(void *p) { gpr_free(p); }
static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp, static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
grpc_mdelem *md) { grpc_mdelem md) {
grpc_chttp2_transport *t = tp; grpc_chttp2_transport *t = tp;
grpc_chttp2_stream *s = t->incoming_stream; grpc_chttp2_stream *s = t->incoming_stream;
@ -514,7 +514,7 @@ static void on_initial_header(grpc_exec_ctx *exec_ctx, void *tp,
} }
static void on_trailing_header(grpc_exec_ctx *exec_ctx, void *tp, static void on_trailing_header(grpc_exec_ctx *exec_ctx, void *tp,
grpc_mdelem *md) { grpc_mdelem md) {
grpc_chttp2_transport *t = tp; grpc_chttp2_transport *t = tp;
grpc_chttp2_stream *s = t->incoming_stream; grpc_chttp2_stream *s = t->incoming_stream;

@ -567,7 +567,7 @@ static void convert_metadata_to_cronet_headers(
curr = head; curr = head;
size_t num_headers = 0; size_t num_headers = 0;
while (num_headers < num_headers_available) { while (num_headers < num_headers_available) {
grpc_mdelem *mdelem = curr->md; grpc_mdelem mdelem = curr->md;
curr = curr->next; curr = curr->next;
const char *key = grpc_mdstr_as_c_string(mdelem->key); const char *key = grpc_mdstr_as_c_string(mdelem->key);
const char *value = grpc_mdstr_as_c_string(mdelem->value); const char *value = grpc_mdstr_as_c_string(mdelem->value);

@ -84,16 +84,17 @@ typedef struct channel_data {
/** For each \a md element from the incoming metadata, filter out the entry for /** For each \a md element from the incoming metadata, filter out the entry for
* "grpc-encoding", using its value to populate the call data's * "grpc-encoding", using its value to populate the call data's
* compression_algorithm field. */ * compression_algorithm field. */
static grpc_mdelem *compression_md_filter(grpc_exec_ctx *exec_ctx, static grpc_mdelem compression_md_filter(grpc_exec_ctx *exec_ctx,
void *user_data, grpc_mdelem *md) { void *user_data, grpc_mdelem md) {
grpc_call_element *elem = user_data; grpc_call_element *elem = user_data;
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
channel_data *channeld = elem->channel_data; channel_data *channeld = elem->channel_data;
if (grpc_slice_cmp(md->key, GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST) == 0) { if (grpc_slice_cmp(GRPC_MDKEY(md),
if (!grpc_compression_algorithm_parse(md->value, GRPC_MDSTR_GRPC_INTERNAL_ENCODING_REQUEST) == 0) {
if (!grpc_compression_algorithm_parse(GRPC_MDVALUE(md),
&calld->compression_algorithm)) { &calld->compression_algorithm)) {
char *val = grpc_dump_slice(md->value, GPR_DUMP_ASCII); char *val = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"Invalid compression algorithm: '%s' (unknown). Ignoring.", val); "Invalid compression algorithm: '%s' (unknown). Ignoring.", val);
gpr_free(val); gpr_free(val);
@ -101,7 +102,7 @@ static grpc_mdelem *compression_md_filter(grpc_exec_ctx *exec_ctx,
} }
if (!GPR_BITGET(channeld->enabled_algorithms_bitset, if (!GPR_BITGET(channeld->enabled_algorithms_bitset,
calld->compression_algorithm)) { calld->compression_algorithm)) {
char *val = grpc_dump_slice(md->value, GPR_DUMP_ASCII); char *val = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"Invalid compression algorithm: '%s' (previously disabled). " "Invalid compression algorithm: '%s' (previously disabled). "
"Ignoring.", "Ignoring.",
@ -110,7 +111,7 @@ static grpc_mdelem *compression_md_filter(grpc_exec_ctx *exec_ctx,
calld->compression_algorithm = GRPC_COMPRESS_NONE; calld->compression_algorithm = GRPC_COMPRESS_NONE;
} }
calld->has_compression_algorithm = 1; calld->has_compression_algorithm = 1;
return NULL; return GRPC_MDNULL;
} }
return md; return md;

@ -89,43 +89,45 @@ typedef struct call_data {
} call_data; } call_data;
typedef struct channel_data { typedef struct channel_data {
grpc_mdelem *static_scheme; grpc_mdelem static_scheme;
grpc_mdelem *user_agent; grpc_mdelem user_agent;
size_t max_payload_size_for_get; size_t max_payload_size_for_get;
} channel_data; } channel_data;
static grpc_mdelem *client_recv_filter(grpc_exec_ctx *exec_ctx, void *user_data, static grpc_mdelem client_recv_filter(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_mdelem *md) { grpc_mdelem md) {
grpc_call_element *elem = user_data; grpc_call_element *elem = user_data;
if (md == GRPC_MDELEM_STATUS_200) { if (grpc_mdelem_eq(md, GRPC_MDELEM_STATUS_200)) {
return NULL; return GRPC_MDNULL;
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_STATUS) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_STATUS) == 0) {
char *message_string; char *message_string;
char *val = grpc_dump_slice(md->value, GPR_DUMP_ASCII); char *val = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_ASCII);
gpr_asprintf(&message_string, "Received http2 header with status: %s", val); gpr_asprintf(&message_string, "Received http2 header with status: %s", val);
grpc_slice message = grpc_slice_from_copied_string(message_string); grpc_slice message = grpc_slice_from_copied_string(message_string);
gpr_free(message_string); gpr_free(message_string);
gpr_free(val); gpr_free(val);
grpc_call_element_send_close_with_message(exec_ctx, elem, grpc_call_element_send_close_with_message(exec_ctx, elem,
GRPC_STATUS_CANCELLED, &message); GRPC_STATUS_CANCELLED, &message);
return NULL; return GRPC_MDNULL;
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_GRPC_MESSAGE) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_MESSAGE) == 0) {
grpc_slice pct_decoded_msg = grpc_slice pct_decoded_msg =
grpc_permissive_percent_decode_slice(md->value); grpc_permissive_percent_decode_slice(GRPC_MDVALUE(md));
if (grpc_slice_is_equivalent(pct_decoded_msg, md->value)) { if (grpc_slice_is_equivalent(pct_decoded_msg, GRPC_MDVALUE(md))) {
grpc_slice_unref(pct_decoded_msg); grpc_slice_unref(pct_decoded_msg);
return md; return md;
} else { } else {
return grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_MESSAGE, return grpc_mdelem_from_slices(exec_ctx, GRPC_MDSTR_GRPC_MESSAGE,
pct_decoded_msg); pct_decoded_msg);
} }
} else if (md == GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC) { } else if (grpc_mdelem_eq(md,
return NULL; GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)) {
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_CONTENT_TYPE) == 0) { return GRPC_MDNULL;
if (grpc_slice_buf_start_eq(md->value, EXPECTED_CONTENT_TYPE, } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_CONTENT_TYPE) == 0) {
if (grpc_slice_buf_start_eq(GRPC_MDVALUE(md), EXPECTED_CONTENT_TYPE,
EXPECTED_CONTENT_TYPE_LENGTH) && EXPECTED_CONTENT_TYPE_LENGTH) &&
(GRPC_SLICE_START_PTR(md->value)[EXPECTED_CONTENT_TYPE_LENGTH] == '+' || (GRPC_SLICE_START_PTR(GRPC_MDVALUE(md))[EXPECTED_CONTENT_TYPE_LENGTH] ==
GRPC_SLICE_START_PTR(md->value)[EXPECTED_CONTENT_TYPE_LENGTH] == '+' ||
GRPC_SLICE_START_PTR(GRPC_MDVALUE(md))[EXPECTED_CONTENT_TYPE_LENGTH] ==
';')) { ';')) {
/* Although the C implementation doesn't (currently) generate them, /* Although the C implementation doesn't (currently) generate them,
any custom +-suffix is explicitly valid. */ any custom +-suffix is explicitly valid. */
@ -135,11 +137,11 @@ static grpc_mdelem *client_recv_filter(grpc_exec_ctx *exec_ctx, void *user_data,
} else { } else {
/* TODO(klempner): We're currently allowing this, but we shouldn't /* TODO(klempner): We're currently allowing this, but we shouldn't
see it without a proxy so log for now. */ see it without a proxy so log for now. */
char *val = grpc_dump_slice(md->value, GPR_DUMP_ASCII); char *val = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "Unexpected content-type '%s'", val); gpr_log(GPR_INFO, "Unexpected content-type '%s'", val);
gpr_free(val); gpr_free(val);
} }
return NULL; return GRPC_MDNULL;
} }
return md; return md;
} }
@ -182,14 +184,18 @@ static void send_done(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) {
calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error); calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error);
} }
static grpc_mdelem *client_strip_filter(grpc_exec_ctx *exec_ctx, static grpc_mdelem client_strip_filter(grpc_exec_ctx *exec_ctx, void *user_data,
void *user_data, grpc_mdelem *md) { grpc_mdelem md) {
/* eat the things we'd like to set ourselves */ /* eat the things we'd like to set ourselves */
if (grpc_slice_cmp(md->key, GRPC_MDSTR_METHOD) == 0) return NULL; if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_METHOD) == 0)
if (grpc_slice_cmp(md->key, GRPC_MDSTR_SCHEME) == 0) return NULL; return GRPC_MDNULL;
if (grpc_slice_cmp(md->key, GRPC_MDSTR_TE) == 0) return NULL; if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_SCHEME) == 0)
if (grpc_slice_cmp(md->key, GRPC_MDSTR_CONTENT_TYPE) == 0) return NULL; return GRPC_MDNULL;
if (grpc_slice_cmp(md->key, GRPC_MDSTR_USER_AGENT) == 0) return NULL; if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_TE) == 0) return GRPC_MDNULL;
if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_CONTENT_TYPE) == 0)
return GRPC_MDNULL;
if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_USER_AGENT) == 0)
return GRPC_MDNULL;
return md; return md;
} }
@ -240,7 +246,7 @@ static void hc_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
cacheable, and the operation contains both initial metadata and send cacheable, and the operation contains both initial metadata and send
message, and the payload is below the size threshold, and all the data message, and the payload is below the size threshold, and all the data
for this request is immediately available. */ for this request is immediately available. */
grpc_mdelem *method = GRPC_MDELEM_METHOD_POST; grpc_mdelem method = GRPC_MDELEM_METHOD_POST;
calld->send_message_blocked = false; calld->send_message_blocked = false;
if ((op->send_initial_metadata_flags & if ((op->send_initial_metadata_flags &
GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) && GRPC_INITIAL_METADATA_CACHEABLE_REQUEST) &&
@ -254,7 +260,7 @@ static void hc_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
} }
/* Attempt to read the data from send_message and create a header field. */ /* Attempt to read the data from send_message and create a header field. */
if (method == GRPC_MDELEM_METHOD_GET) { if (grpc_mdelem_eq(method, GRPC_MDELEM_METHOD_GET)) {
/* allocate memory to hold the entire payload */ /* allocate memory to hold the entire payload */
calld->payload_bytes = gpr_malloc(op->send_message->length); calld->payload_bytes = gpr_malloc(op->send_message->length);
@ -267,7 +273,7 @@ static void hc_mutate_op(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
if (calld->send_message_blocked == false) { if (calld->send_message_blocked == false) {
/* when all the send_message data is available, then create a MDELEM and /* when all the send_message data is available, then create a MDELEM and
append to headers */ append to headers */
grpc_mdelem *payload_bin = grpc_mdelem_from_slices( grpc_mdelem payload_bin = grpc_mdelem_from_slices(
exec_ctx, GRPC_MDSTR_GRPC_PAYLOAD_BIN, exec_ctx, GRPC_MDSTR_GRPC_PAYLOAD_BIN,
grpc_slice_from_copied_buffer((const char *)calld->payload_bytes, grpc_slice_from_copied_buffer((const char *)calld->payload_bytes,
op->send_message->length)); op->send_message->length));
@ -362,17 +368,17 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices); grpc_slice_buffer_destroy_internal(exec_ctx, &calld->slices);
} }
static grpc_mdelem *scheme_from_args(const grpc_channel_args *args) { static grpc_mdelem scheme_from_args(const grpc_channel_args *args) {
unsigned i; unsigned i;
size_t j; size_t j;
grpc_mdelem *valid_schemes[] = {GRPC_MDELEM_SCHEME_HTTP, grpc_mdelem valid_schemes[] = {GRPC_MDELEM_SCHEME_HTTP,
GRPC_MDELEM_SCHEME_HTTPS}; GRPC_MDELEM_SCHEME_HTTPS};
if (args != NULL) { if (args != NULL) {
for (i = 0; i < args->num_args; ++i) { for (i = 0; i < args->num_args; ++i) {
if (args->args[i].type == GRPC_ARG_STRING && if (args->args[i].type == GRPC_ARG_STRING &&
strcmp(args->args[i].key, GRPC_ARG_HTTP2_SCHEME) == 0) { strcmp(args->args[i].key, GRPC_ARG_HTTP2_SCHEME) == 0) {
for (j = 0; j < GPR_ARRAY_SIZE(valid_schemes); j++) { for (j = 0; j < GPR_ARRAY_SIZE(valid_schemes); j++) {
if (0 == grpc_slice_str_cmp(valid_schemes[j]->value, if (0 == grpc_slice_str_cmp(GRPC_MDVALUE(valid_schemes[j]),
args->args[i].value.string)) { args->args[i].value.string)) {
return valid_schemes[j]; return valid_schemes[j];
} }

@ -84,13 +84,13 @@ typedef struct call_data {
typedef struct channel_data { uint8_t unused; } channel_data; typedef struct channel_data { uint8_t unused; } channel_data;
static grpc_mdelem *server_filter_outgoing_metadata(grpc_exec_ctx *exec_ctx, static grpc_mdelem server_filter_outgoing_metadata(grpc_exec_ctx *exec_ctx,
void *user_data, void *user_data,
grpc_mdelem *md) { grpc_mdelem md) {
if (grpc_slice_cmp(md->key, GRPC_MDSTR_GRPC_MESSAGE) == 0) { if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_MESSAGE) == 0) {
grpc_slice pct_encoded_msg = grpc_percent_encode_slice( grpc_slice pct_encoded_msg = grpc_percent_encode_slice(
md->value, grpc_compatible_percent_encoding_unreserved_bytes); GRPC_MDVALUE(md), grpc_compatible_percent_encoding_unreserved_bytes);
if (grpc_slice_is_equivalent(pct_encoded_msg, md->value)) { if (grpc_slice_is_equivalent(pct_encoded_msg, GRPC_MDVALUE(md))) {
grpc_slice_unref_internal(exec_ctx, pct_encoded_msg); grpc_slice_unref_internal(exec_ctx, pct_encoded_msg);
return md; return md;
} else { } else {
@ -102,40 +102,44 @@ static grpc_mdelem *server_filter_outgoing_metadata(grpc_exec_ctx *exec_ctx,
} }
} }
static grpc_mdelem *server_filter(grpc_exec_ctx *exec_ctx, void *user_data, static grpc_mdelem server_filter(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_mdelem *md) { grpc_mdelem md) {
grpc_call_element *elem = user_data; grpc_call_element *elem = user_data;
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
/* Check if it is one of the headers we care about. */ /* Check if it is one of the headers we care about. */
if (md == GRPC_MDELEM_TE_TRAILERS || md == GRPC_MDELEM_METHOD_POST || if (grpc_mdelem_eq(md, GRPC_MDELEM_TE_TRAILERS) ||
md == GRPC_MDELEM_METHOD_PUT || md == GRPC_MDELEM_METHOD_GET || grpc_mdelem_eq(md, GRPC_MDELEM_METHOD_POST) ||
md == GRPC_MDELEM_SCHEME_HTTP || md == GRPC_MDELEM_SCHEME_HTTPS || grpc_mdelem_eq(md, GRPC_MDELEM_METHOD_PUT) ||
md == GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC) { grpc_mdelem_eq(md, GRPC_MDELEM_METHOD_GET) ||
grpc_mdelem_eq(md, GRPC_MDELEM_SCHEME_HTTP) ||
grpc_mdelem_eq(md, GRPC_MDELEM_SCHEME_HTTPS) ||
grpc_mdelem_eq(md, GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC)) {
/* swallow it */ /* swallow it */
if (md == GRPC_MDELEM_METHOD_POST) { if (grpc_mdelem_eq(md, GRPC_MDELEM_METHOD_POST)) {
calld->seen_method = 1; calld->seen_method = 1;
*calld->recv_idempotent_request = false; *calld->recv_idempotent_request = false;
*calld->recv_cacheable_request = false; *calld->recv_cacheable_request = false;
} else if (md == GRPC_MDELEM_METHOD_PUT) { } else if (grpc_mdelem_eq(md, GRPC_MDELEM_METHOD_PUT)) {
calld->seen_method = 1; calld->seen_method = 1;
*calld->recv_idempotent_request = true; *calld->recv_idempotent_request = true;
} else if (md == GRPC_MDELEM_METHOD_GET) { } else if (grpc_mdelem_eq(md, GRPC_MDELEM_METHOD_GET)) {
calld->seen_method = 1; calld->seen_method = 1;
*calld->recv_cacheable_request = true; *calld->recv_cacheable_request = true;
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_SCHEME)) { } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_SCHEME)) {
calld->seen_scheme = 1; calld->seen_scheme = 1;
} else if (md == GRPC_MDELEM_TE_TRAILERS) { } else if (grpc_mdelem_eq(md, GRPC_MDELEM_TE_TRAILERS)) {
calld->seen_te_trailers = 1; calld->seen_te_trailers = 1;
} }
/* TODO(klempner): Track that we've seen all the headers we should /* TODO(klempner): Track that we've seen all the headers we should
require */ require */
return NULL; return GRPC_MDNULL;
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_CONTENT_TYPE) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_CONTENT_TYPE) == 0) {
if (grpc_slice_buf_start_eq(md->value, EXPECTED_CONTENT_TYPE, if (grpc_slice_buf_start_eq(GRPC_MDVALUE(md), EXPECTED_CONTENT_TYPE,
EXPECTED_CONTENT_TYPE_LENGTH) && EXPECTED_CONTENT_TYPE_LENGTH) &&
(GRPC_SLICE_START_PTR(md->value)[EXPECTED_CONTENT_TYPE_LENGTH] == '+' || (GRPC_SLICE_START_PTR(GRPC_MDVALUE(md))[EXPECTED_CONTENT_TYPE_LENGTH] ==
GRPC_SLICE_START_PTR(md->value)[EXPECTED_CONTENT_TYPE_LENGTH] == '+' ||
GRPC_SLICE_START_PTR(GRPC_MDVALUE(md))[EXPECTED_CONTENT_TYPE_LENGTH] ==
';')) { ';')) {
/* Although the C implementation doesn't (currently) generate them, /* Although the C implementation doesn't (currently) generate them,
any custom +-suffix is explicitly valid. */ any custom +-suffix is explicitly valid. */
@ -145,16 +149,16 @@ static grpc_mdelem *server_filter(grpc_exec_ctx *exec_ctx, void *user_data,
} else { } else {
/* TODO(klempner): We're currently allowing this, but we shouldn't /* TODO(klempner): We're currently allowing this, but we shouldn't
see it without a proxy so log for now. */ see it without a proxy so log for now. */
char *val = grpc_dump_slice(md->value, GPR_DUMP_ASCII); char *val = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_ASCII);
gpr_log(GPR_INFO, "Unexpected content-type '%s'", val); gpr_log(GPR_INFO, "Unexpected content-type '%s'", val);
gpr_free(val); gpr_free(val);
} }
return NULL; return GRPC_MDNULL;
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_TE) == 0 || } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_TE) == 0 ||
grpc_slice_cmp(md->key, GRPC_MDSTR_METHOD) == 0 || grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_METHOD) == 0 ||
grpc_slice_cmp(md->key, GRPC_MDSTR_SCHEME) == 0) { grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_SCHEME) == 0) {
char *key = grpc_dump_slice(md->key, GPR_DUMP_ASCII); char *key = grpc_dump_slice(GRPC_MDKEY(md), GPR_DUMP_ASCII);
char *value = grpc_dump_slice(md->value, GPR_DUMP_ASCII); char *value = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "Invalid %s: header: '%s'", key, value); gpr_log(GPR_ERROR, "Invalid %s: header: '%s'", key, value);
/* swallow it and error everything out. */ /* swallow it and error everything out. */
/* TODO(klempner): We ought to generate more descriptive error messages /* TODO(klempner): We ought to generate more descriptive error messages
@ -162,33 +166,33 @@ static grpc_mdelem *server_filter(grpc_exec_ctx *exec_ctx, void *user_data,
gpr_free(key); gpr_free(key);
gpr_free(value); gpr_free(value);
grpc_call_element_send_cancel(exec_ctx, elem); grpc_call_element_send_cancel(exec_ctx, elem);
return NULL; return GRPC_MDNULL;
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_PATH) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_PATH) == 0) {
if (calld->seen_path) { if (calld->seen_path) {
gpr_log(GPR_ERROR, "Received :path twice"); gpr_log(GPR_ERROR, "Received :path twice");
return NULL; return GRPC_MDNULL;
} }
calld->seen_path = 1; calld->seen_path = 1;
return md; return md;
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_AUTHORITY) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_AUTHORITY) == 0) {
calld->seen_authority = 1; calld->seen_authority = 1;
return md; return md;
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_HOST) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_HOST) == 0) {
/* translate host to :authority since :authority may be /* translate host to :authority since :authority may be
omitted */ omitted */
grpc_mdelem *authority = grpc_mdelem_from_slices( grpc_mdelem authority = grpc_mdelem_from_slices(
exec_ctx, GRPC_MDSTR_AUTHORITY, grpc_slice_ref(md->value)); exec_ctx, GRPC_MDSTR_AUTHORITY, grpc_slice_ref(GRPC_MDVALUE(md)));
calld->seen_authority = 1; calld->seen_authority = 1;
return authority; return authority;
} else if (grpc_slice_cmp(md->key, GRPC_MDSTR_GRPC_PAYLOAD_BIN) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(md), GRPC_MDSTR_GRPC_PAYLOAD_BIN) == 0) {
/* Retrieve the payload from the value of the 'grpc-internal-payload-bin' /* Retrieve the payload from the value of the 'grpc-internal-payload-bin'
header field */ header field */
calld->seen_payload_bin = 1; calld->seen_payload_bin = 1;
grpc_slice_buffer_add(&calld->read_slice_buffer, grpc_slice_buffer_add(&calld->read_slice_buffer,
grpc_slice_ref_internal(md->value)); grpc_slice_ref_internal(GRPC_MDVALUE(md)));
grpc_slice_buffer_stream_init(&calld->read_stream, grpc_slice_buffer_stream_init(&calld->read_stream,
&calld->read_slice_buffer, 0); &calld->read_slice_buffer, 0);
return NULL; return GRPC_MDNULL;
} else { } else {
return md; return md;
} }

@ -42,7 +42,7 @@ grpc_slice grpc_compression_algorithm_slice(
grpc_compression_algorithm algorithm); grpc_compression_algorithm algorithm);
/** Return compression algorithm based metadata element (grpc-encoding: xxx) */ /** Return compression algorithm based metadata element (grpc-encoding: xxx) */
grpc_mdelem *grpc_compression_encoding_mdelem( grpc_mdelem grpc_compression_encoding_mdelem(
grpc_compression_algorithm algorithm); grpc_compression_algorithm algorithm);
/** Find compression algorithm based on passed in mdstr - returns /** Find compression algorithm based on passed in mdstr - returns

@ -105,7 +105,7 @@ grpc_slice grpc_compression_algorithm_slice(
return grpc_empty_slice(); return grpc_empty_slice();
} }
grpc_mdelem *grpc_compression_encoding_mdelem( grpc_mdelem grpc_compression_encoding_mdelem(
grpc_compression_algorithm algorithm) { grpc_compression_algorithm algorithm) {
switch (algorithm) { switch (algorithm) {
case GRPC_COMPRESS_NONE: case GRPC_COMPRESS_NONE:
@ -117,7 +117,7 @@ grpc_mdelem *grpc_compression_encoding_mdelem(
default: default:
break; break;
} }
return NULL; return GRPC_MDNULL;
} }
void grpc_compression_options_init(grpc_compression_options *opts) { void grpc_compression_options_init(grpc_compression_options *opts) {

@ -253,7 +253,7 @@ static void auth_start_transport_op(grpc_exec_ctx *exec_ctx,
if (op->send_initial_metadata != NULL) { if (op->send_initial_metadata != NULL) {
for (l = op->send_initial_metadata->list.head; l != NULL; l = l->next) { for (l = op->send_initial_metadata->list.head; l != NULL; l = l->next) {
grpc_mdelem *md = l->md; grpc_mdelem md = l->md;
/* Pointer comparison is OK for md_elems created from the same context. /* Pointer comparison is OK for md_elems created from the same context.
*/ */
if (grpc_slice_cmp(md->key, GRPC_MDSTR_AUTHORITY) == 0) { if (grpc_slice_cmp(md->key, GRPC_MDSTR_AUTHORITY) == 0) {

@ -68,7 +68,7 @@ static grpc_metadata_array metadata_batch_to_md_array(
grpc_metadata_array_init(&result); grpc_metadata_array_init(&result);
for (l = batch->list.head; l != NULL; l = l->next) { for (l = batch->list.head; l != NULL; l = l->next) {
grpc_metadata *usr_md = NULL; grpc_metadata *usr_md = NULL;
grpc_mdelem *md = l->md; grpc_mdelem md = l->md;
grpc_slice key = md->key; grpc_slice key = md->key;
grpc_slice value = md->value; grpc_slice value = md->value;
if (result.count == result.capacity) { if (result.count == result.capacity) {
@ -83,8 +83,8 @@ static grpc_metadata_array metadata_batch_to_md_array(
return result; return result;
} }
static grpc_mdelem *remove_consumed_md(grpc_exec_ctx *exec_ctx, void *user_data, static grpc_mdelem remove_consumed_md(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_mdelem *md) { grpc_mdelem md) {
grpc_call_element *elem = user_data; grpc_call_element *elem = user_data;
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
size_t i; size_t i;

@ -252,9 +252,10 @@ grpc_error *grpc_call_create(grpc_exec_ctx *exec_ctx,
MAX_SEND_EXTRA_METADATA_COUNT); MAX_SEND_EXTRA_METADATA_COUNT);
for (i = 0; i < args->add_initial_metadata_count; i++) { for (i = 0; i < args->add_initial_metadata_count; i++) {
call->send_extra_metadata[i].md = args->add_initial_metadata[i]; call->send_extra_metadata[i].md = args->add_initial_metadata[i];
if (grpc_slice_cmp(args->add_initial_metadata[i]->key, GRPC_MDSTR_PATH) == if (grpc_slice_cmp(GRPC_MDKEY(args->add_initial_metadata[i]),
0) { GRPC_MDSTR_PATH) == 0) {
path = grpc_slice_ref_internal(args->add_initial_metadata[i]->value); path = grpc_slice_ref_internal(
GRPC_MDVALUE(args->add_initial_metadata[i]));
} }
} }
call->send_extra_metadata_count = (int)args->add_initial_metadata_count; call->send_extra_metadata_count = (int)args->add_initial_metadata_count;
@ -499,7 +500,7 @@ uint32_t grpc_call_test_only_get_message_flags(grpc_call *call) {
static void destroy_encodings_accepted_by_peer(void *p) { return; } static void destroy_encodings_accepted_by_peer(void *p) { return; }
static void set_encodings_accepted_by_peer(grpc_exec_ctx *exec_ctx, static void set_encodings_accepted_by_peer(grpc_exec_ctx *exec_ctx,
grpc_call *call, grpc_mdelem *mdel) { grpc_call *call, grpc_mdelem mdel) {
size_t i; size_t i;
grpc_compression_algorithm algorithm; grpc_compression_algorithm algorithm;
grpc_slice_buffer accept_encoding_parts; grpc_slice_buffer accept_encoding_parts;
@ -514,7 +515,7 @@ static void set_encodings_accepted_by_peer(grpc_exec_ctx *exec_ctx,
return; return;
} }
accept_encoding_slice = mdel->value; accept_encoding_slice = GRPC_MDVALUE(mdel);
grpc_slice_buffer_init(&accept_encoding_parts); grpc_slice_buffer_init(&accept_encoding_parts);
grpc_slice_split(accept_encoding_slice, ",", &accept_encoding_parts); grpc_slice_split(accept_encoding_slice, ",", &accept_encoding_parts);
@ -596,13 +597,13 @@ static int prepare_application_metadata(
grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data; grpc_linked_mdelem *l = (grpc_linked_mdelem *)&md->internal_data;
GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data)); GPR_ASSERT(sizeof(grpc_linked_mdelem) == sizeof(md->internal_data));
l->md = grpc_mdelem_from_slices(exec_ctx, md->key, md->value); l->md = grpc_mdelem_from_slices(exec_ctx, md->key, md->value);
if (!grpc_header_key_is_legal(l->md->key)) { if (!grpc_header_key_is_legal(GRPC_MDKEY(l->md))) {
char *str = grpc_dump_slice(md->key, GPR_DUMP_ASCII); char *str = grpc_dump_slice(md->key, GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "attempt to send invalid metadata key: %s", str); gpr_log(GPR_ERROR, "attempt to send invalid metadata key: %s", str);
gpr_free(str); gpr_free(str);
break; break;
} else if (!grpc_is_binary_header(l->md->key) && } else if (!grpc_is_binary_header(GRPC_MDKEY(l->md)) &&
!grpc_header_nonbin_value_is_legal(l->md->value)) { !grpc_header_nonbin_value_is_legal(GRPC_MDVALUE(l->md))) {
char *str = grpc_dump_slice(md->value, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *str = grpc_dump_slice(md->value, GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, "attempt to send invalid metadata value: %s", str); gpr_log(GPR_ERROR, "attempt to send invalid metadata value: %s", str);
gpr_free(str); gpr_free(str);
@ -879,17 +880,17 @@ grpc_call *grpc_call_from_top_element(grpc_call_element *elem) {
#define STATUS_OFFSET 1 #define STATUS_OFFSET 1
static void destroy_status(void *ignored) {} static void destroy_status(void *ignored) {}
static uint32_t decode_status(grpc_mdelem *md) { static uint32_t decode_status(grpc_mdelem md) {
uint32_t status; uint32_t status;
void *user_data; void *user_data;
if (md == GRPC_MDELEM_GRPC_STATUS_0) return 0; if (grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_0)) return 0;
if (md == GRPC_MDELEM_GRPC_STATUS_1) return 1; if (grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_1)) return 1;
if (md == GRPC_MDELEM_GRPC_STATUS_2) return 2; if (grpc_mdelem_eq(md, GRPC_MDELEM_GRPC_STATUS_2)) return 2;
user_data = grpc_mdelem_get_user_data(md, destroy_status); user_data = grpc_mdelem_get_user_data(md, destroy_status);
if (user_data != NULL) { if (user_data != NULL) {
status = ((uint32_t)(intptr_t)user_data) - STATUS_OFFSET; status = ((uint32_t)(intptr_t)user_data) - STATUS_OFFSET;
} else { } else {
if (!grpc_parse_slice_to_uint32(md->value, &status)) { if (!grpc_parse_slice_to_uint32(GRPC_MDVALUE(md), &status)) {
status = GRPC_STATUS_UNKNOWN; /* could not parse status code */ status = GRPC_STATUS_UNKNOWN; /* could not parse status code */
} }
grpc_mdelem_set_user_data(md, destroy_status, grpc_mdelem_set_user_data(md, destroy_status,
@ -898,11 +899,11 @@ static uint32_t decode_status(grpc_mdelem *md) {
return status; return status;
} }
static grpc_compression_algorithm decode_compression(grpc_mdelem *md) { static grpc_compression_algorithm decode_compression(grpc_mdelem md) {
grpc_compression_algorithm algorithm = grpc_compression_algorithm algorithm =
grpc_compression_algorithm_from_slice(md->value); grpc_compression_algorithm_from_slice(GRPC_MDVALUE(md));
if (algorithm == GRPC_COMPRESS_ALGORITHMS_COUNT) { if (algorithm == GRPC_COMPRESS_ALGORITHMS_COUNT) {
char *md_c_str = grpc_dump_slice(md->value, GPR_DUMP_ASCII); char *md_c_str = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_ASCII);
gpr_log(GPR_ERROR, gpr_log(GPR_ERROR,
"Invalid incoming compression algorithm: '%s'. Interpreting " "Invalid incoming compression algorithm: '%s'. Interpreting "
"incoming data as uncompressed.", "incoming data as uncompressed.",
@ -913,25 +914,25 @@ static grpc_compression_algorithm decode_compression(grpc_mdelem *md) {
return algorithm; return algorithm;
} }
static grpc_mdelem *recv_common_filter(grpc_exec_ctx *exec_ctx, grpc_call *call, static grpc_mdelem recv_common_filter(grpc_exec_ctx *exec_ctx, grpc_call *call,
grpc_mdelem *elem) { grpc_mdelem elem) {
if (grpc_slice_cmp(elem->key, GRPC_MDSTR_GRPC_STATUS) == 0) { if (grpc_slice_cmp(GRPC_MDKEY(elem), GRPC_MDSTR_GRPC_STATUS) == 0) {
GPR_TIMER_BEGIN("status", 0); GPR_TIMER_BEGIN("status", 0);
set_status_code(call, STATUS_FROM_WIRE, decode_status(elem)); set_status_code(call, STATUS_FROM_WIRE, decode_status(elem));
GPR_TIMER_END("status", 0); GPR_TIMER_END("status", 0);
return NULL; return GRPC_MDNULL;
} else if (grpc_slice_cmp(elem->key, GRPC_MDSTR_GRPC_MESSAGE) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(elem), GRPC_MDSTR_GRPC_MESSAGE) == 0) {
GPR_TIMER_BEGIN("status-details", 0); GPR_TIMER_BEGIN("status-details", 0);
set_status_details(exec_ctx, call, STATUS_FROM_WIRE, set_status_details(exec_ctx, call, STATUS_FROM_WIRE,
grpc_slice_ref_internal(elem->value)); grpc_slice_ref_internal(GRPC_MDVALUE(elem)));
GPR_TIMER_END("status-details", 0); GPR_TIMER_END("status-details", 0);
return NULL; return GRPC_MDNULL;
} }
return elem; return elem;
} }
static grpc_mdelem *publish_app_metadata(grpc_call *call, grpc_mdelem *elem, static grpc_mdelem publish_app_metadata(grpc_call *call, grpc_mdelem elem,
int is_trailing) { int is_trailing) {
grpc_metadata_array *dest; grpc_metadata_array *dest;
grpc_metadata *mdusr; grpc_metadata *mdusr;
GPR_TIMER_BEGIN("publish_app_metadata", 0); GPR_TIMER_BEGIN("publish_app_metadata", 0);
@ -942,39 +943,40 @@ static grpc_mdelem *publish_app_metadata(grpc_call *call, grpc_mdelem *elem,
gpr_realloc(dest->metadata, sizeof(grpc_metadata) * dest->capacity); gpr_realloc(dest->metadata, sizeof(grpc_metadata) * dest->capacity);
} }
mdusr = &dest->metadata[dest->count++]; mdusr = &dest->metadata[dest->count++];
mdusr->key = grpc_slice_ref(elem->key); mdusr->key = grpc_slice_ref(GRPC_MDKEY(elem));
mdusr->value = grpc_slice_ref(elem->value); mdusr->value = grpc_slice_ref(GRPC_MDVALUE(elem));
GPR_TIMER_END("publish_app_metadata", 0); GPR_TIMER_END("publish_app_metadata", 0);
return elem; return elem;
} }
static grpc_mdelem *recv_initial_filter(grpc_exec_ctx *exec_ctx, void *args, static grpc_mdelem recv_initial_filter(grpc_exec_ctx *exec_ctx, void *args,
grpc_mdelem *elem) { grpc_mdelem elem) {
grpc_call *call = args; grpc_call *call = args;
elem = recv_common_filter(exec_ctx, call, elem); elem = recv_common_filter(exec_ctx, call, elem);
if (elem == NULL) { if (GRPC_MDISNULL(elem)) {
return NULL; return GRPC_MDNULL;
} else if (grpc_slice_cmp(elem->key, GRPC_MDSTR_GRPC_ENCODING) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(elem), GRPC_MDSTR_GRPC_ENCODING) == 0) {
GPR_TIMER_BEGIN("incoming_compression_algorithm", 0); GPR_TIMER_BEGIN("incoming_compression_algorithm", 0);
set_incoming_compression_algorithm(call, decode_compression(elem)); set_incoming_compression_algorithm(call, decode_compression(elem));
GPR_TIMER_END("incoming_compression_algorithm", 0); GPR_TIMER_END("incoming_compression_algorithm", 0);
return NULL; return GRPC_MDNULL;
} else if (grpc_slice_cmp(elem->key, GRPC_MDSTR_GRPC_ACCEPT_ENCODING) == 0) { } else if (grpc_slice_cmp(GRPC_MDKEY(elem),
GRPC_MDSTR_GRPC_ACCEPT_ENCODING) == 0) {
GPR_TIMER_BEGIN("encodings_accepted_by_peer", 0); GPR_TIMER_BEGIN("encodings_accepted_by_peer", 0);
set_encodings_accepted_by_peer(exec_ctx, call, elem); set_encodings_accepted_by_peer(exec_ctx, call, elem);
GPR_TIMER_END("encodings_accepted_by_peer", 0); GPR_TIMER_END("encodings_accepted_by_peer", 0);
return NULL; return GRPC_MDNULL;
} else { } else {
return publish_app_metadata(call, elem, 0); return publish_app_metadata(call, elem, 0);
} }
} }
static grpc_mdelem *recv_trailing_filter(grpc_exec_ctx *exec_ctx, void *args, static grpc_mdelem recv_trailing_filter(grpc_exec_ctx *exec_ctx, void *args,
grpc_mdelem *elem) { grpc_mdelem elem) {
grpc_call *call = args; grpc_call *call = args;
elem = recv_common_filter(exec_ctx, call, elem); elem = recv_common_filter(exec_ctx, call, elem);
if (elem == NULL) { if (GRPC_MDISNULL(elem)) {
return NULL; return GRPC_MDNULL;
} else { } else {
return publish_app_metadata(call, elem, 1); return publish_app_metadata(call, elem, 1);
} }
@ -1508,9 +1510,9 @@ static grpc_call_error call_start_batch(grpc_exec_ctx *exec_ctx,
grpc_slice_ref_internal( grpc_slice_ref_internal(
*op->data.send_status_from_server.status_details)); *op->data.send_status_from_server.status_details));
call->send_extra_metadata_count++; call->send_extra_metadata_count++;
set_status_details( set_status_details(exec_ctx, call, STATUS_FROM_API_OVERRIDE,
exec_ctx, call, STATUS_FROM_API_OVERRIDE, grpc_slice_ref_internal(GRPC_MDVALUE(
grpc_slice_ref_internal(call->send_extra_metadata[1].md->value)); call->send_extra_metadata[1].md)));
} }
if (op->data.send_status_from_server.status != GRPC_STATUS_OK) { if (op->data.send_status_from_server.status != GRPC_STATUS_OK) {
set_status_code(call, STATUS_FROM_API_OVERRIDE, set_status_code(call, STATUS_FROM_API_OVERRIDE,

@ -61,7 +61,7 @@ typedef struct grpc_call_create_args {
const void *server_transport_data; const void *server_transport_data;
grpc_mdelem **add_initial_metadata; grpc_mdelem *add_initial_metadata;
size_t add_initial_metadata_count; size_t add_initial_metadata_count;
gpr_timespec send_deadline; gpr_timespec send_deadline;

@ -57,15 +57,15 @@
#define NUM_CACHED_STATUS_ELEMS 3 #define NUM_CACHED_STATUS_ELEMS 3
typedef struct registered_call { typedef struct registered_call {
grpc_mdelem *path; grpc_mdelem path;
grpc_mdelem *authority; grpc_mdelem authority;
struct registered_call *next; struct registered_call *next;
} registered_call; } registered_call;
struct grpc_channel { struct grpc_channel {
int is_client; int is_client;
grpc_compression_options compression_options; grpc_compression_options compression_options;
grpc_mdelem *default_authority; grpc_mdelem default_authority;
gpr_mu registered_call_mu; gpr_mu registered_call_mu;
registered_call *registered_calls; registered_call *registered_calls;
@ -190,9 +190,9 @@ void grpc_channel_get_info(grpc_channel *channel,
static grpc_call *grpc_channel_create_call_internal( static grpc_call *grpc_channel_create_call_internal(
grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call, grpc_exec_ctx *exec_ctx, grpc_channel *channel, grpc_call *parent_call,
uint32_t propagation_mask, grpc_completion_queue *cq, uint32_t propagation_mask, grpc_completion_queue *cq,
grpc_pollset_set *pollset_set_alternative, grpc_mdelem *path_mdelem, grpc_pollset_set *pollset_set_alternative, grpc_mdelem path_mdelem,
grpc_mdelem *authority_mdelem, gpr_timespec deadline) { grpc_mdelem authority_mdelem, gpr_timespec deadline) {
grpc_mdelem *send_metadata[2]; grpc_mdelem send_metadata[2];
size_t num_metadata = 0; size_t num_metadata = 0;
GPR_ASSERT(channel->is_client); GPR_ASSERT(channel->is_client);
@ -367,7 +367,7 @@ grpc_compression_options grpc_channel_compression_options(
return channel->compression_options; return channel->compression_options;
} }
grpc_mdelem *grpc_channel_get_reffed_status_elem(grpc_exec_ctx *exec_ctx, grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_exec_ctx *exec_ctx,
grpc_channel *channel, int i) { grpc_channel *channel, int i) {
char tmp[GPR_LTOA_MIN_BUFSIZE]; char tmp[GPR_LTOA_MIN_BUFSIZE];
switch (i) { switch (i) {

@ -62,7 +62,7 @@ grpc_channel_stack *grpc_channel_get_channel_stack(grpc_channel *channel);
status_code. status_code.
The returned elem is owned by the caller. */ The returned elem is owned by the caller. */
grpc_mdelem *grpc_channel_get_reffed_status_elem(grpc_exec_ctx *exec_ctx, grpc_mdelem grpc_channel_get_reffed_status_elem(grpc_exec_ctx *exec_ctx,
grpc_channel *channel, grpc_channel *channel,
int status_code); int status_code);

@ -735,8 +735,8 @@ static void maybe_finish_shutdown(grpc_exec_ctx *exec_ctx,
} }
} }
static grpc_mdelem *server_filter(grpc_exec_ctx *exec_ctx, void *user_data, static grpc_mdelem server_filter(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_mdelem *md) { grpc_mdelem md) {
grpc_call_element *elem = user_data; grpc_call_element *elem = user_data;
call_data *calld = elem->call_data; call_data *calld = elem->call_data;
if (grpc_slice_cmp(md->key, GRPC_MDSTR_PATH) == 0) { if (grpc_slice_cmp(md->key, GRPC_MDSTR_PATH) == 0) {

@ -80,7 +80,7 @@
typedef void (*destroy_user_data_func)(void *user_data); typedef void (*destroy_user_data_func)(void *user_data);
/* Shadow structure for grpc_mdelem for non-static elements */ /* Shadow structure for grpc_mdelem_data for non-static elements */
typedef struct internal_metadata { typedef struct internal_metadata {
/* must be byte compatible with grpc_mdelem */ /* must be byte compatible with grpc_mdelem */
grpc_slice key; grpc_slice key;
@ -141,9 +141,9 @@ void grpc_mdctx_global_shutdown(grpc_exec_ctx *exec_ctx) {
} }
} }
static int is_mdelem_static(grpc_mdelem *e) { static int is_mdelem_static(grpc_mdelem e) {
return e >= &grpc_static_mdelem_table[0] && return e.payload >= &grpc_static_mdelem_table[0] &&
e < &grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; e.payload < &grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
} }
static void ref_md_locked(mdtab_shard *shard, static void ref_md_locked(mdtab_shard *shard,
@ -233,14 +233,14 @@ static void rehash_mdtab(grpc_exec_ctx *exec_ctx, mdtab_shard *shard) {
} }
} }
grpc_mdelem *grpc_mdelem_from_slices(grpc_exec_ctx *exec_ctx, grpc_slice key, grpc_mdelem grpc_mdelem_from_slices(grpc_exec_ctx *exec_ctx, grpc_slice key,
grpc_slice value) { grpc_slice value) {
grpc_slice_static_intern(&key); grpc_slice_static_intern(&key);
grpc_slice_static_intern(&value); grpc_slice_static_intern(&value);
grpc_mdelem *static_elem = grpc_static_mdelem_for_static_strings( grpc_mdelem static_elem = grpc_static_mdelem_for_static_strings(
grpc_static_metadata_index(key), grpc_static_metadata_index(value)); grpc_static_metadata_index(key), grpc_static_metadata_index(value));
if (static_elem != NULL) { if (!GRPC_MDISNULL(static_elem)) {
return static_elem; return static_elem;
} }
@ -264,7 +264,7 @@ grpc_mdelem *grpc_mdelem_from_slices(grpc_exec_ctx *exec_ctx, grpc_slice key,
grpc_slice_unref_internal(exec_ctx, key); grpc_slice_unref_internal(exec_ctx, key);
grpc_slice_unref_internal(exec_ctx, value); grpc_slice_unref_internal(exec_ctx, value);
GPR_TIMER_END("grpc_mdelem_from_metadata_strings", 0); GPR_TIMER_END("grpc_mdelem_from_metadata_strings", 0);
return (grpc_mdelem *)md; return (grpc_mdelem){(grpc_mdelem_data *)md};
} }
} }
@ -294,7 +294,7 @@ grpc_mdelem *grpc_mdelem_from_slices(grpc_exec_ctx *exec_ctx, grpc_slice key,
GPR_TIMER_END("grpc_mdelem_from_metadata_strings", 0); GPR_TIMER_END("grpc_mdelem_from_metadata_strings", 0);
return (grpc_mdelem *)md; return (grpc_mdelem){(grpc_mdelem_data *)md};
} }
static size_t get_base64_encoded_size(size_t raw_length) { static size_t get_base64_encoded_size(size_t raw_length) {
@ -302,18 +302,18 @@ static size_t get_base64_encoded_size(size_t raw_length) {
return raw_length / 3 * 4 + tail_xtra[raw_length % 3]; return raw_length / 3 * 4 + tail_xtra[raw_length % 3];
} }
size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem *elem) { size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem) {
size_t overhead_and_key = 32 + GRPC_SLICE_LENGTH(elem->key); size_t overhead_and_key = 32 + GRPC_SLICE_LENGTH(GRPC_MDKEY(elem));
size_t value_len = GRPC_SLICE_LENGTH(elem->value); size_t value_len = GRPC_SLICE_LENGTH(GRPC_MDVALUE(elem));
if (grpc_is_binary_header(elem->key)) { if (grpc_is_binary_header(GRPC_MDKEY(elem))) {
return overhead_and_key + get_base64_encoded_size(value_len); return overhead_and_key + get_base64_encoded_size(value_len);
} else { } else {
return overhead_and_key + value_len; return overhead_and_key + value_len;
} }
} }
grpc_mdelem *grpc_mdelem_ref(grpc_mdelem *gmd DEBUG_ARGS) { grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) {
internal_metadata *md = (internal_metadata *)gmd; internal_metadata *md = (internal_metadata *)gmd.payload;
if (is_mdelem_static(gmd)) return gmd; if (is_mdelem_static(gmd)) return gmd;
#ifdef GRPC_METADATA_REFCOUNT_DEBUG #ifdef GRPC_METADATA_REFCOUNT_DEBUG
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
@ -332,8 +332,8 @@ grpc_mdelem *grpc_mdelem_ref(grpc_mdelem *gmd DEBUG_ARGS) {
return gmd; return gmd;
} }
void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem *gmd DEBUG_ARGS) { void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
internal_metadata *md = (internal_metadata *)gmd; internal_metadata *md = (internal_metadata *)gmd.payload;
if (!md) return; if (!md) return;
if (is_mdelem_static(gmd)) return; if (is_mdelem_static(gmd)) return;
#ifdef GRPC_METADATA_REFCOUNT_DEBUG #ifdef GRPC_METADATA_REFCOUNT_DEBUG
@ -356,11 +356,12 @@ void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem *gmd DEBUG_ARGS) {
} }
} }
void *grpc_mdelem_get_user_data(grpc_mdelem *md, void (*destroy_func)(void *)) { void *grpc_mdelem_get_user_data(grpc_mdelem md, void (*destroy_func)(void *)) {
internal_metadata *im = (internal_metadata *)md; internal_metadata *im = (internal_metadata *)md.payload;
void *result; void *result;
if (is_mdelem_static(md)) { if (is_mdelem_static(md)) {
return (void *)grpc_static_mdelem_user_data[md - grpc_static_mdelem_table]; return (void *)
grpc_static_mdelem_user_data[md.payload - grpc_static_mdelem_table];
} }
if (gpr_atm_acq_load(&im->destroy_user_data) == (gpr_atm)destroy_func) { if (gpr_atm_acq_load(&im->destroy_user_data) == (gpr_atm)destroy_func) {
return (void *)gpr_atm_no_barrier_load(&im->user_data); return (void *)gpr_atm_no_barrier_load(&im->user_data);
@ -370,9 +371,9 @@ void *grpc_mdelem_get_user_data(grpc_mdelem *md, void (*destroy_func)(void *)) {
return result; return result;
} }
void *grpc_mdelem_set_user_data(grpc_mdelem *md, void (*destroy_func)(void *), void *grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void *),
void *user_data) { void *user_data) {
internal_metadata *im = (internal_metadata *)md; internal_metadata *im = (internal_metadata *)md.payload;
GPR_ASSERT(!is_mdelem_static(md)); GPR_ASSERT(!is_mdelem_static(md));
GPR_ASSERT((user_data == NULL) == (destroy_func == NULL)); GPR_ASSERT((user_data == NULL) == (destroy_func == NULL));
gpr_mu_lock(&im->mu_user_data); gpr_mu_lock(&im->mu_user_data);
@ -389,3 +390,9 @@ void *grpc_mdelem_set_user_data(grpc_mdelem *md, void (*destroy_func)(void *),
gpr_mu_unlock(&im->mu_user_data); gpr_mu_unlock(&im->mu_user_data);
return user_data; return user_data;
} }
bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b) {
if (a.payload == b.payload) return true;
return 0 == grpc_slice_cmp(GRPC_MDKEY(a), GRPC_MDKEY(b)) &&
0 == grpc_slice_cmp(GRPC_MDVALUE(a), GRPC_MDVALUE(b));
}

@ -78,23 +78,29 @@ typedef struct grpc_mdelem grpc_mdelem;
/* if changing this, make identical changes in internal_metadata in /* if changing this, make identical changes in internal_metadata in
metadata.c */ metadata.c */
struct grpc_mdelem { typedef struct grpc_mdelem_data {
const grpc_slice key; const grpc_slice key;
const grpc_slice value; const grpc_slice value;
/* there is a private part to this in metadata.c */ /* there is a private part to this in metadata.c */
} grpc_mdelem_data;
struct grpc_mdelem {
grpc_mdelem_data *payload;
}; };
/* Unrefs the slices. */ /* Unrefs the slices. */
grpc_mdelem *grpc_mdelem_from_slices(grpc_exec_ctx *exec_ctx, grpc_slice key, grpc_mdelem grpc_mdelem_from_slices(grpc_exec_ctx *exec_ctx, grpc_slice key,
grpc_slice value); grpc_slice value);
size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem *elem); bool grpc_mdelem_eq(grpc_mdelem a, grpc_mdelem b);
size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem elem);
/* Mutator and accessor for grpc_mdelem user data. The destructor function /* Mutator and accessor for grpc_mdelem user data. The destructor function
is used as a type tag and is checked during user_data fetch. */ is used as a type tag and is checked during user_data fetch. */
void *grpc_mdelem_get_user_data(grpc_mdelem *md, void *grpc_mdelem_get_user_data(grpc_mdelem md,
void (*if_destroy_func)(void *)); void (*if_destroy_func)(void *));
void *grpc_mdelem_set_user_data(grpc_mdelem *md, void (*destroy_func)(void *), void *grpc_mdelem_set_user_data(grpc_mdelem md, void (*destroy_func)(void *),
void *user_data); void *user_data);
/* Reference counting */ /* Reference counting */
@ -103,19 +109,26 @@ void *grpc_mdelem_set_user_data(grpc_mdelem *md, void (*destroy_func)(void *),
#define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s), __FILE__, __LINE__) #define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s), __FILE__, __LINE__)
#define GRPC_MDELEM_UNREF(exec_ctx, s) \ #define GRPC_MDELEM_UNREF(exec_ctx, s) \
grpc_mdelem_unref((exec_ctx), (s), __FILE__, __LINE__) grpc_mdelem_unref((exec_ctx), (s), __FILE__, __LINE__)
grpc_mdelem *grpc_mdelem_ref(grpc_mdelem *md, const char *file, int line); grpc_mdelem grpc_mdelem_ref(grpc_mdelem md, const char *file, int line);
void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem *md, void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem md,
const char *file, int line); const char *file, int line);
#else #else
#define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s)) #define GRPC_MDELEM_REF(s) grpc_mdelem_ref((s))
#define GRPC_MDELEM_UNREF(exec_ctx, s) grpc_mdelem_unref((exec_ctx), (s)) #define GRPC_MDELEM_UNREF(exec_ctx, s) grpc_mdelem_unref((exec_ctx), (s))
grpc_mdelem *grpc_mdelem_ref(grpc_mdelem *md); grpc_mdelem grpc_mdelem_ref(grpc_mdelem md);
void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem *md); void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem md);
#endif #endif
#define GRPC_MDKEY(md) ((md).payload->key)
#define GRPC_MDVALUE(md) ((md).payload->value)
#define GRPC_MDNULL ((grpc_mdelem){NULL})
#define GRPC_MDISNULL(md) ((md).payload == NULL)
/* We add 32 bytes of padding as per RFC-7540 section 6.5.2. */ /* We add 32 bytes of padding as per RFC-7540 section 6.5.2. */
#define GRPC_MDELEM_LENGTH(e) \ #define GRPC_MDELEM_LENGTH(e) \
(GRPC_SLICE_LENGTH((e)->key) + GRPC_SLICE_LENGTH((e)->value) + 32) (GRPC_SLICE_LENGTH(GRPC_MDKEY((e))) + GRPC_SLICE_LENGTH(MRPC_MDVALUE((e))) + \
32)
#define GRPC_MDSTR_KV_HASH(k_hash, v_hash) (GPR_ROTL((k_hash), 2) ^ (v_hash)) #define GRPC_MDSTR_KV_HASH(k_hash, v_hash) (GPR_ROTL((k_hash), 2) ^ (v_hash))

@ -82,7 +82,7 @@ void grpc_metadata_batch_destroy(grpc_exec_ctx *exec_ctx,
void grpc_metadata_batch_add_head(grpc_metadata_batch *batch, void grpc_metadata_batch_add_head(grpc_metadata_batch *batch,
grpc_linked_mdelem *storage, grpc_linked_mdelem *storage,
grpc_mdelem *elem_to_add) { grpc_mdelem elem_to_add) {
GPR_ASSERT(elem_to_add); GPR_ASSERT(elem_to_add);
storage->md = elem_to_add; storage->md = elem_to_add;
grpc_metadata_batch_link_head(batch, storage); grpc_metadata_batch_link_head(batch, storage);
@ -109,7 +109,7 @@ void grpc_metadata_batch_link_head(grpc_metadata_batch *batch,
void grpc_metadata_batch_add_tail(grpc_metadata_batch *batch, void grpc_metadata_batch_add_tail(grpc_metadata_batch *batch,
grpc_linked_mdelem *storage, grpc_linked_mdelem *storage,
grpc_mdelem *elem_to_add) { grpc_mdelem elem_to_add) {
GPR_ASSERT(elem_to_add); GPR_ASSERT(elem_to_add);
storage->md = elem_to_add; storage->md = elem_to_add;
grpc_metadata_batch_link_tail(batch, storage); grpc_metadata_batch_link_tail(batch, storage);
@ -143,9 +143,9 @@ void grpc_metadata_batch_move(grpc_metadata_batch *dst,
void grpc_metadata_batch_filter(grpc_exec_ctx *exec_ctx, void grpc_metadata_batch_filter(grpc_exec_ctx *exec_ctx,
grpc_metadata_batch *batch, grpc_metadata_batch *batch,
grpc_mdelem *(*filter)(grpc_exec_ctx *exec_ctx, grpc_mdelem (*filter)(grpc_exec_ctx *exec_ctx,
void *user_data, void *user_data,
grpc_mdelem *elem), grpc_mdelem elem),
void *user_data) { void *user_data) {
grpc_linked_mdelem *l; grpc_linked_mdelem *l;
grpc_linked_mdelem *next; grpc_linked_mdelem *next;
@ -154,8 +154,8 @@ void grpc_metadata_batch_filter(grpc_exec_ctx *exec_ctx,
assert_valid_list(&batch->list); assert_valid_list(&batch->list);
for (l = batch->list.head; l; l = next) { for (l = batch->list.head; l; l = next) {
grpc_mdelem *orig = l->md; grpc_mdelem orig = l->md;
grpc_mdelem *filt = filter(exec_ctx, user_data, orig); grpc_mdelem filt = filter(exec_ctx, user_data, orig);
next = l->next; next = l->next;
if (filt == NULL) { if (filt == NULL) {
if (l->prev) { if (l->prev) {
@ -182,8 +182,8 @@ void grpc_metadata_batch_filter(grpc_exec_ctx *exec_ctx,
GPR_TIMER_END("grpc_metadata_batch_filter", 0); GPR_TIMER_END("grpc_metadata_batch_filter", 0);
} }
static grpc_mdelem *no_metadata_for_you(grpc_exec_ctx *exec_ctx, static grpc_mdelem no_metadata_for_you(grpc_exec_ctx *exec_ctx, void *user_data,
void *user_data, grpc_mdelem *elem) { grpc_mdelem elem) {
return NULL; return NULL;
} }

@ -47,7 +47,7 @@ extern "C" {
#endif #endif
typedef struct grpc_linked_mdelem { typedef struct grpc_linked_mdelem {
grpc_mdelem *md; grpc_mdelem md;
struct grpc_linked_mdelem *next; struct grpc_linked_mdelem *next;
struct grpc_linked_mdelem *prev; struct grpc_linked_mdelem *prev;
void *reserved; void *reserved;
@ -105,7 +105,7 @@ void grpc_metadata_batch_link_tail(grpc_metadata_batch *batch,
Takes ownership of \a elem_to_add */ Takes ownership of \a elem_to_add */
void grpc_metadata_batch_add_head(grpc_metadata_batch *batch, void grpc_metadata_batch_add_head(grpc_metadata_batch *batch,
grpc_linked_mdelem *storage, grpc_linked_mdelem *storage,
grpc_mdelem *elem_to_add); grpc_mdelem elem_to_add);
/** Add \a elem_to_add as the last element in \a batch, using /** Add \a elem_to_add as the last element in \a batch, using
\a storage as backing storage for the linked list element. \a storage as backing storage for the linked list element.
\a storage is owned by the caller and must survive for the \a storage is owned by the caller and must survive for the
@ -114,7 +114,7 @@ void grpc_metadata_batch_add_head(grpc_metadata_batch *batch,
Takes ownership of \a elem_to_add */ Takes ownership of \a elem_to_add */
void grpc_metadata_batch_add_tail(grpc_metadata_batch *batch, void grpc_metadata_batch_add_tail(grpc_metadata_batch *batch,
grpc_linked_mdelem *storage, grpc_linked_mdelem *storage,
grpc_mdelem *elem_to_add); grpc_mdelem elem_to_add);
/** For each element in \a batch, execute \a filter. /** For each element in \a batch, execute \a filter.
The return value from \a filter will be substituted for the The return value from \a filter will be substituted for the
@ -122,9 +122,9 @@ void grpc_metadata_batch_add_tail(grpc_metadata_batch *batch,
the element will be moved to the garbage list. */ the element will be moved to the garbage list. */
void grpc_metadata_batch_filter(grpc_exec_ctx *exec_ctx, void grpc_metadata_batch_filter(grpc_exec_ctx *exec_ctx,
grpc_metadata_batch *batch, grpc_metadata_batch *batch,
grpc_mdelem *(*filter)(grpc_exec_ctx *exec_ctx, grpc_mdelem (*filter)(grpc_exec_ctx *exec_ctx,
void *user_data, void *user_data,
grpc_mdelem *elem), grpc_mdelem elem),
void *user_data); void *user_data);
#ifndef NDEBUG #ifndef NDEBUG

@ -454,14 +454,16 @@ static const uint8_t elem_idxs[] = {
45, 22, 57, 47, 76, 80, 61, 42, 59, 2, 0, 8, 6, 50, 35, 12, 36, 45, 22, 57, 47, 76, 80, 61, 42, 59, 2, 0, 8, 6, 50, 35, 12, 36,
53, 14, 49, 29, 10, 38, 17, 18, 1, 32, 3, 9, 65}; 53, 14, 49, 29, 10, 38, 17, 18, 1, 32, 3, 9, 65};
grpc_mdelem *grpc_static_mdelem_for_static_strings(int a, int b) { grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) {
if (a == -1 || b == -1) return NULL; if (a == -1 || b == -1) return GRPC_MDNULL;
uint32_t k = (uint32_t)(a * 98 + b); uint32_t k = (uint32_t)(a * 98 + b);
uint32_t h = elems_phash(k); uint32_t h = elems_phash(k);
return elem_keys[h] == k ? &grpc_static_mdelem_table[elem_idxs[h]] : NULL; return elem_keys[h] == k
? (grpc_mdelem){&grpc_static_mdelem_table[elem_idxs[h]]}
: GRPC_MDNULL;
} }
grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = { grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {
{{.refcount = &g_refcnt, {{.refcount = &g_refcnt,
.data.refcounted = {.bytes = g_raw_bytes + 30, .length = 14}}, .data.refcounted = {.bytes = g_raw_bytes + 30, .length = 14}},
{.refcount = &g_refcnt, {.refcount = &g_refcnt,

@ -251,182 +251,220 @@ bool grpc_is_static_metadata_string(grpc_slice slice);
int grpc_static_metadata_index(grpc_slice slice); int grpc_static_metadata_index(grpc_slice slice);
#define GRPC_STATIC_MDELEM_COUNT 81 #define GRPC_STATIC_MDELEM_COUNT 81
extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT]; extern grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];
extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT]; extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];
/* "accept-charset": "" */ /* "accept-charset": "" */
#define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY (&grpc_static_mdelem_table[0]) #define GRPC_MDELEM_ACCEPT_CHARSET_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[0]})
/* "accept": "" */ /* "accept": "" */
#define GRPC_MDELEM_ACCEPT_EMPTY (&grpc_static_mdelem_table[1]) #define GRPC_MDELEM_ACCEPT_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[1]})
/* "accept-encoding": "" */ /* "accept-encoding": "" */
#define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY (&grpc_static_mdelem_table[2]) #define GRPC_MDELEM_ACCEPT_ENCODING_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[2]})
/* "accept-encoding": "gzip, deflate" */ /* "accept-encoding": "gzip, deflate" */
#define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \ #define GRPC_MDELEM_ACCEPT_ENCODING_GZIP_COMMA_DEFLATE \
(&grpc_static_mdelem_table[3]) ((grpc_mdelem){&grpc_static_mdelem_table[3]})
/* "accept-language": "" */ /* "accept-language": "" */
#define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY (&grpc_static_mdelem_table[4]) #define GRPC_MDELEM_ACCEPT_LANGUAGE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[4]})
/* "accept-ranges": "" */ /* "accept-ranges": "" */
#define GRPC_MDELEM_ACCEPT_RANGES_EMPTY (&grpc_static_mdelem_table[5]) #define GRPC_MDELEM_ACCEPT_RANGES_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[5]})
/* "access-control-allow-origin": "" */ /* "access-control-allow-origin": "" */
#define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \ #define GRPC_MDELEM_ACCESS_CONTROL_ALLOW_ORIGIN_EMPTY \
(&grpc_static_mdelem_table[6]) ((grpc_mdelem){&grpc_static_mdelem_table[6]})
/* "age": "" */ /* "age": "" */
#define GRPC_MDELEM_AGE_EMPTY (&grpc_static_mdelem_table[7]) #define GRPC_MDELEM_AGE_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[7]})
/* "allow": "" */ /* "allow": "" */
#define GRPC_MDELEM_ALLOW_EMPTY (&grpc_static_mdelem_table[8]) #define GRPC_MDELEM_ALLOW_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[8]})
/* ":authority": "" */ /* ":authority": "" */
#define GRPC_MDELEM_AUTHORITY_EMPTY (&grpc_static_mdelem_table[9]) #define GRPC_MDELEM_AUTHORITY_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[9]})
/* "authorization": "" */ /* "authorization": "" */
#define GRPC_MDELEM_AUTHORIZATION_EMPTY (&grpc_static_mdelem_table[10]) #define GRPC_MDELEM_AUTHORIZATION_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[10]})
/* "cache-control": "" */ /* "cache-control": "" */
#define GRPC_MDELEM_CACHE_CONTROL_EMPTY (&grpc_static_mdelem_table[11]) #define GRPC_MDELEM_CACHE_CONTROL_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[11]})
/* "content-disposition": "" */ /* "content-disposition": "" */
#define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY (&grpc_static_mdelem_table[12]) #define GRPC_MDELEM_CONTENT_DISPOSITION_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[12]})
/* "content-encoding": "" */ /* "content-encoding": "" */
#define GRPC_MDELEM_CONTENT_ENCODING_EMPTY (&grpc_static_mdelem_table[13]) #define GRPC_MDELEM_CONTENT_ENCODING_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[13]})
/* "content-language": "" */ /* "content-language": "" */
#define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY (&grpc_static_mdelem_table[14]) #define GRPC_MDELEM_CONTENT_LANGUAGE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[14]})
/* "content-length": "" */ /* "content-length": "" */
#define GRPC_MDELEM_CONTENT_LENGTH_EMPTY (&grpc_static_mdelem_table[15]) #define GRPC_MDELEM_CONTENT_LENGTH_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[15]})
/* "content-location": "" */ /* "content-location": "" */
#define GRPC_MDELEM_CONTENT_LOCATION_EMPTY (&grpc_static_mdelem_table[16]) #define GRPC_MDELEM_CONTENT_LOCATION_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[16]})
/* "content-range": "" */ /* "content-range": "" */
#define GRPC_MDELEM_CONTENT_RANGE_EMPTY (&grpc_static_mdelem_table[17]) #define GRPC_MDELEM_CONTENT_RANGE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[17]})
/* "content-type": "application/grpc" */ /* "content-type": "application/grpc" */
#define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \ #define GRPC_MDELEM_CONTENT_TYPE_APPLICATION_SLASH_GRPC \
(&grpc_static_mdelem_table[18]) ((grpc_mdelem){&grpc_static_mdelem_table[18]})
/* "content-type": "" */ /* "content-type": "" */
#define GRPC_MDELEM_CONTENT_TYPE_EMPTY (&grpc_static_mdelem_table[19]) #define GRPC_MDELEM_CONTENT_TYPE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[19]})
/* "cookie": "" */ /* "cookie": "" */
#define GRPC_MDELEM_COOKIE_EMPTY (&grpc_static_mdelem_table[20]) #define GRPC_MDELEM_COOKIE_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[20]})
/* "date": "" */ /* "date": "" */
#define GRPC_MDELEM_DATE_EMPTY (&grpc_static_mdelem_table[21]) #define GRPC_MDELEM_DATE_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[21]})
/* "etag": "" */ /* "etag": "" */
#define GRPC_MDELEM_ETAG_EMPTY (&grpc_static_mdelem_table[22]) #define GRPC_MDELEM_ETAG_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[22]})
/* "expect": "" */ /* "expect": "" */
#define GRPC_MDELEM_EXPECT_EMPTY (&grpc_static_mdelem_table[23]) #define GRPC_MDELEM_EXPECT_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[23]})
/* "expires": "" */ /* "expires": "" */
#define GRPC_MDELEM_EXPIRES_EMPTY (&grpc_static_mdelem_table[24]) #define GRPC_MDELEM_EXPIRES_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[24]})
/* "from": "" */ /* "from": "" */
#define GRPC_MDELEM_FROM_EMPTY (&grpc_static_mdelem_table[25]) #define GRPC_MDELEM_FROM_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[25]})
/* "grpc-accept-encoding": "deflate" */ /* "grpc-accept-encoding": "deflate" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE (&grpc_static_mdelem_table[26]) #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE \
((grpc_mdelem){&grpc_static_mdelem_table[26]})
/* "grpc-accept-encoding": "deflate,gzip" */ /* "grpc-accept-encoding": "deflate,gzip" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_DEFLATE_COMMA_GZIP \
(&grpc_static_mdelem_table[27]) ((grpc_mdelem){&grpc_static_mdelem_table[27]})
/* "grpc-accept-encoding": "gzip" */ /* "grpc-accept-encoding": "gzip" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP (&grpc_static_mdelem_table[28]) #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_GZIP \
((grpc_mdelem){&grpc_static_mdelem_table[28]})
/* "grpc-accept-encoding": "identity" */ /* "grpc-accept-encoding": "identity" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY \
(&grpc_static_mdelem_table[29]) ((grpc_mdelem){&grpc_static_mdelem_table[29]})
/* "grpc-accept-encoding": "identity,deflate" */ /* "grpc-accept-encoding": "identity,deflate" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE \
(&grpc_static_mdelem_table[30]) ((grpc_mdelem){&grpc_static_mdelem_table[30]})
/* "grpc-accept-encoding": "identity,deflate,gzip" */ /* "grpc-accept-encoding": "identity,deflate,gzip" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_DEFLATE_COMMA_GZIP \
(&grpc_static_mdelem_table[31]) ((grpc_mdelem){&grpc_static_mdelem_table[31]})
/* "grpc-accept-encoding": "identity,gzip" */ /* "grpc-accept-encoding": "identity,gzip" */
#define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \ #define GRPC_MDELEM_GRPC_ACCEPT_ENCODING_IDENTITY_COMMA_GZIP \
(&grpc_static_mdelem_table[32]) ((grpc_mdelem){&grpc_static_mdelem_table[32]})
/* "grpc-encoding": "deflate" */ /* "grpc-encoding": "deflate" */
#define GRPC_MDELEM_GRPC_ENCODING_DEFLATE (&grpc_static_mdelem_table[33]) #define GRPC_MDELEM_GRPC_ENCODING_DEFLATE \
((grpc_mdelem){&grpc_static_mdelem_table[33]})
/* "grpc-encoding": "gzip" */ /* "grpc-encoding": "gzip" */
#define GRPC_MDELEM_GRPC_ENCODING_GZIP (&grpc_static_mdelem_table[34]) #define GRPC_MDELEM_GRPC_ENCODING_GZIP \
((grpc_mdelem){&grpc_static_mdelem_table[34]})
/* "grpc-encoding": "identity" */ /* "grpc-encoding": "identity" */
#define GRPC_MDELEM_GRPC_ENCODING_IDENTITY (&grpc_static_mdelem_table[35]) #define GRPC_MDELEM_GRPC_ENCODING_IDENTITY \
((grpc_mdelem){&grpc_static_mdelem_table[35]})
/* "grpc-status": "0" */ /* "grpc-status": "0" */
#define GRPC_MDELEM_GRPC_STATUS_0 (&grpc_static_mdelem_table[36]) #define GRPC_MDELEM_GRPC_STATUS_0 ((grpc_mdelem){&grpc_static_mdelem_table[36]})
/* "grpc-status": "1" */ /* "grpc-status": "1" */
#define GRPC_MDELEM_GRPC_STATUS_1 (&grpc_static_mdelem_table[37]) #define GRPC_MDELEM_GRPC_STATUS_1 ((grpc_mdelem){&grpc_static_mdelem_table[37]})
/* "grpc-status": "2" */ /* "grpc-status": "2" */
#define GRPC_MDELEM_GRPC_STATUS_2 (&grpc_static_mdelem_table[38]) #define GRPC_MDELEM_GRPC_STATUS_2 ((grpc_mdelem){&grpc_static_mdelem_table[38]})
/* "host": "" */ /* "host": "" */
#define GRPC_MDELEM_HOST_EMPTY (&grpc_static_mdelem_table[39]) #define GRPC_MDELEM_HOST_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[39]})
/* "if-match": "" */ /* "if-match": "" */
#define GRPC_MDELEM_IF_MATCH_EMPTY (&grpc_static_mdelem_table[40]) #define GRPC_MDELEM_IF_MATCH_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[40]})
/* "if-modified-since": "" */ /* "if-modified-since": "" */
#define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY (&grpc_static_mdelem_table[41]) #define GRPC_MDELEM_IF_MODIFIED_SINCE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[41]})
/* "if-none-match": "" */ /* "if-none-match": "" */
#define GRPC_MDELEM_IF_NONE_MATCH_EMPTY (&grpc_static_mdelem_table[42]) #define GRPC_MDELEM_IF_NONE_MATCH_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[42]})
/* "if-range": "" */ /* "if-range": "" */
#define GRPC_MDELEM_IF_RANGE_EMPTY (&grpc_static_mdelem_table[43]) #define GRPC_MDELEM_IF_RANGE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[43]})
/* "if-unmodified-since": "" */ /* "if-unmodified-since": "" */
#define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY (&grpc_static_mdelem_table[44]) #define GRPC_MDELEM_IF_UNMODIFIED_SINCE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[44]})
/* "last-modified": "" */ /* "last-modified": "" */
#define GRPC_MDELEM_LAST_MODIFIED_EMPTY (&grpc_static_mdelem_table[45]) #define GRPC_MDELEM_LAST_MODIFIED_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[45]})
/* "lb-cost-bin": "" */ /* "lb-cost-bin": "" */
#define GRPC_MDELEM_LB_COST_BIN_EMPTY (&grpc_static_mdelem_table[46]) #define GRPC_MDELEM_LB_COST_BIN_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[46]})
/* "lb-token": "" */ /* "lb-token": "" */
#define GRPC_MDELEM_LB_TOKEN_EMPTY (&grpc_static_mdelem_table[47]) #define GRPC_MDELEM_LB_TOKEN_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[47]})
/* "link": "" */ /* "link": "" */
#define GRPC_MDELEM_LINK_EMPTY (&grpc_static_mdelem_table[48]) #define GRPC_MDELEM_LINK_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[48]})
/* "location": "" */ /* "location": "" */
#define GRPC_MDELEM_LOCATION_EMPTY (&grpc_static_mdelem_table[49]) #define GRPC_MDELEM_LOCATION_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[49]})
/* "max-forwards": "" */ /* "max-forwards": "" */
#define GRPC_MDELEM_MAX_FORWARDS_EMPTY (&grpc_static_mdelem_table[50]) #define GRPC_MDELEM_MAX_FORWARDS_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[50]})
/* ":method": "GET" */ /* ":method": "GET" */
#define GRPC_MDELEM_METHOD_GET (&grpc_static_mdelem_table[51]) #define GRPC_MDELEM_METHOD_GET ((grpc_mdelem){&grpc_static_mdelem_table[51]})
/* ":method": "POST" */ /* ":method": "POST" */
#define GRPC_MDELEM_METHOD_POST (&grpc_static_mdelem_table[52]) #define GRPC_MDELEM_METHOD_POST ((grpc_mdelem){&grpc_static_mdelem_table[52]})
/* ":method": "PUT" */ /* ":method": "PUT" */
#define GRPC_MDELEM_METHOD_PUT (&grpc_static_mdelem_table[53]) #define GRPC_MDELEM_METHOD_PUT ((grpc_mdelem){&grpc_static_mdelem_table[53]})
/* ":path": "/" */ /* ":path": "/" */
#define GRPC_MDELEM_PATH_SLASH (&grpc_static_mdelem_table[54]) #define GRPC_MDELEM_PATH_SLASH ((grpc_mdelem){&grpc_static_mdelem_table[54]})
/* ":path": "/index.html" */ /* ":path": "/index.html" */
#define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML (&grpc_static_mdelem_table[55]) #define GRPC_MDELEM_PATH_SLASH_INDEX_DOT_HTML \
((grpc_mdelem){&grpc_static_mdelem_table[55]})
/* "proxy-authenticate": "" */ /* "proxy-authenticate": "" */
#define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY (&grpc_static_mdelem_table[56]) #define GRPC_MDELEM_PROXY_AUTHENTICATE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[56]})
/* "proxy-authorization": "" */ /* "proxy-authorization": "" */
#define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY (&grpc_static_mdelem_table[57]) #define GRPC_MDELEM_PROXY_AUTHORIZATION_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[57]})
/* "range": "" */ /* "range": "" */
#define GRPC_MDELEM_RANGE_EMPTY (&grpc_static_mdelem_table[58]) #define GRPC_MDELEM_RANGE_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[58]})
/* "referer": "" */ /* "referer": "" */
#define GRPC_MDELEM_REFERER_EMPTY (&grpc_static_mdelem_table[59]) #define GRPC_MDELEM_REFERER_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[59]})
/* "refresh": "" */ /* "refresh": "" */
#define GRPC_MDELEM_REFRESH_EMPTY (&grpc_static_mdelem_table[60]) #define GRPC_MDELEM_REFRESH_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[60]})
/* "retry-after": "" */ /* "retry-after": "" */
#define GRPC_MDELEM_RETRY_AFTER_EMPTY (&grpc_static_mdelem_table[61]) #define GRPC_MDELEM_RETRY_AFTER_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[61]})
/* ":scheme": "grpc" */ /* ":scheme": "grpc" */
#define GRPC_MDELEM_SCHEME_GRPC (&grpc_static_mdelem_table[62]) #define GRPC_MDELEM_SCHEME_GRPC ((grpc_mdelem){&grpc_static_mdelem_table[62]})
/* ":scheme": "http" */ /* ":scheme": "http" */
#define GRPC_MDELEM_SCHEME_HTTP (&grpc_static_mdelem_table[63]) #define GRPC_MDELEM_SCHEME_HTTP ((grpc_mdelem){&grpc_static_mdelem_table[63]})
/* ":scheme": "https" */ /* ":scheme": "https" */
#define GRPC_MDELEM_SCHEME_HTTPS (&grpc_static_mdelem_table[64]) #define GRPC_MDELEM_SCHEME_HTTPS ((grpc_mdelem){&grpc_static_mdelem_table[64]})
/* "server": "" */ /* "server": "" */
#define GRPC_MDELEM_SERVER_EMPTY (&grpc_static_mdelem_table[65]) #define GRPC_MDELEM_SERVER_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[65]})
/* "set-cookie": "" */ /* "set-cookie": "" */
#define GRPC_MDELEM_SET_COOKIE_EMPTY (&grpc_static_mdelem_table[66]) #define GRPC_MDELEM_SET_COOKIE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[66]})
/* ":status": "200" */ /* ":status": "200" */
#define GRPC_MDELEM_STATUS_200 (&grpc_static_mdelem_table[67]) #define GRPC_MDELEM_STATUS_200 ((grpc_mdelem){&grpc_static_mdelem_table[67]})
/* ":status": "204" */ /* ":status": "204" */
#define GRPC_MDELEM_STATUS_204 (&grpc_static_mdelem_table[68]) #define GRPC_MDELEM_STATUS_204 ((grpc_mdelem){&grpc_static_mdelem_table[68]})
/* ":status": "206" */ /* ":status": "206" */
#define GRPC_MDELEM_STATUS_206 (&grpc_static_mdelem_table[69]) #define GRPC_MDELEM_STATUS_206 ((grpc_mdelem){&grpc_static_mdelem_table[69]})
/* ":status": "304" */ /* ":status": "304" */
#define GRPC_MDELEM_STATUS_304 (&grpc_static_mdelem_table[70]) #define GRPC_MDELEM_STATUS_304 ((grpc_mdelem){&grpc_static_mdelem_table[70]})
/* ":status": "400" */ /* ":status": "400" */
#define GRPC_MDELEM_STATUS_400 (&grpc_static_mdelem_table[71]) #define GRPC_MDELEM_STATUS_400 ((grpc_mdelem){&grpc_static_mdelem_table[71]})
/* ":status": "404" */ /* ":status": "404" */
#define GRPC_MDELEM_STATUS_404 (&grpc_static_mdelem_table[72]) #define GRPC_MDELEM_STATUS_404 ((grpc_mdelem){&grpc_static_mdelem_table[72]})
/* ":status": "500" */ /* ":status": "500" */
#define GRPC_MDELEM_STATUS_500 (&grpc_static_mdelem_table[73]) #define GRPC_MDELEM_STATUS_500 ((grpc_mdelem){&grpc_static_mdelem_table[73]})
/* "strict-transport-security": "" */ /* "strict-transport-security": "" */
#define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \ #define GRPC_MDELEM_STRICT_TRANSPORT_SECURITY_EMPTY \
(&grpc_static_mdelem_table[74]) ((grpc_mdelem){&grpc_static_mdelem_table[74]})
/* "te": "trailers" */ /* "te": "trailers" */
#define GRPC_MDELEM_TE_TRAILERS (&grpc_static_mdelem_table[75]) #define GRPC_MDELEM_TE_TRAILERS ((grpc_mdelem){&grpc_static_mdelem_table[75]})
/* "transfer-encoding": "" */ /* "transfer-encoding": "" */
#define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY (&grpc_static_mdelem_table[76]) #define GRPC_MDELEM_TRANSFER_ENCODING_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[76]})
/* "user-agent": "" */ /* "user-agent": "" */
#define GRPC_MDELEM_USER_AGENT_EMPTY (&grpc_static_mdelem_table[77]) #define GRPC_MDELEM_USER_AGENT_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[77]})
/* "vary": "" */ /* "vary": "" */
#define GRPC_MDELEM_VARY_EMPTY (&grpc_static_mdelem_table[78]) #define GRPC_MDELEM_VARY_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[78]})
/* "via": "" */ /* "via": "" */
#define GRPC_MDELEM_VIA_EMPTY (&grpc_static_mdelem_table[79]) #define GRPC_MDELEM_VIA_EMPTY ((grpc_mdelem){&grpc_static_mdelem_table[79]})
/* "www-authenticate": "" */ /* "www-authenticate": "" */
#define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY (&grpc_static_mdelem_table[80]) #define GRPC_MDELEM_WWW_AUTHENTICATE_EMPTY \
((grpc_mdelem){&grpc_static_mdelem_table[80]})
grpc_mdelem *grpc_static_mdelem_for_static_strings(int a, int b); grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b);
extern const uint8_t grpc_static_accept_encoding_metadata[8]; extern const uint8_t grpc_static_accept_encoding_metadata[8];
#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \ #define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) \
(&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]]) ((grpc_mdelem){&grpc_static_mdelem_table \
[grpc_static_accept_encoding_metadata[(algs)]]})
#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */ #endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */

@ -47,7 +47,7 @@
/* These routines are here to facilitate debugging - they produce string /* These routines are here to facilitate debugging - they produce string
representations of various transport data structures */ representations of various transport data structures */
static void put_metadata(gpr_strvec *b, grpc_mdelem *md) { static void put_metadata(gpr_strvec *b, grpc_mdelem md) {
gpr_strvec_add(b, gpr_strdup("key=")); gpr_strvec_add(b, gpr_strdup("key="));
gpr_strvec_add(b, grpc_dump_slice(md->key, GPR_DUMP_HEX | GPR_DUMP_ASCII)); gpr_strvec_add(b, grpc_dump_slice(md->key, GPR_DUMP_HEX | GPR_DUMP_ASCII));

@ -77,7 +77,7 @@ class MetadataBatch {
const grpc_mdelem> { const grpc_mdelem> {
public: public:
const grpc_mdelem &operator*() const { return *elem_->md; } const grpc_mdelem &operator*() const { return *elem_->md; }
const grpc_mdelem *operator->() const { return elem_->md; } const grpc_mdelem operator->() const { return elem_->md; }
const_iterator &operator++() { const_iterator &operator++() {
elem_ = elem_->next; elem_ = elem_->next;

@ -53,7 +53,7 @@ static void test_algorithm_mesh(void) {
char *name; char *name;
grpc_compression_algorithm parsed; grpc_compression_algorithm parsed;
grpc_slice mdstr; grpc_slice mdstr;
grpc_mdelem *mdelem; grpc_mdelem mdelem;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_ASSERT( GPR_ASSERT(
grpc_compression_algorithm_name((grpc_compression_algorithm)i, &name)); grpc_compression_algorithm_name((grpc_compression_algorithm)i, &name));

@ -195,7 +195,7 @@ static void verify_table_size_change_match_elem_size(grpc_exec_ctx *exec_ctx,
const char *key, const char *key,
const char *value) { const char *value) {
grpc_slice_buffer output; grpc_slice_buffer output;
grpc_mdelem *elem = grpc_mdelem elem =
grpc_mdelem_from_slices(exec_ctx, grpc_slice_from_copied_string(key), grpc_mdelem_from_slices(exec_ctx, grpc_slice_from_copied_string(key),
grpc_slice_from_copied_string(value)); grpc_slice_from_copied_string(value));
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem); size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);

@ -44,7 +44,7 @@
bool squelch = true; bool squelch = true;
bool leak_check = true; bool leak_check = true;
static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem *md) { static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem md) {
GRPC_MDELEM_UNREF(exec_ctx, md); GRPC_MDELEM_UNREF(exec_ctx, md);
} }
static void dont_log(gpr_log_func_args *args) {} static void dont_log(gpr_log_func_args *args) {}

@ -45,7 +45,7 @@
typedef struct { va_list args; } test_checker; typedef struct { va_list args; } test_checker;
static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem *md) { static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem md) {
const char *ekey, *evalue; const char *ekey, *evalue;
test_checker *chk = ud; test_checker *chk = ud;
ekey = va_arg(chk->args, char *); ekey = va_arg(chk->args, char *);

@ -53,7 +53,7 @@ static void assert_str(const grpc_chttp2_hptbl *tbl, grpc_slice mdstr,
static void assert_index(const grpc_chttp2_hptbl *tbl, uint32_t idx, static void assert_index(const grpc_chttp2_hptbl *tbl, uint32_t idx,
const char *key, const char *value) { const char *key, const char *value) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(tbl, idx); grpc_mdelem md = grpc_chttp2_hptbl_lookup(tbl, idx);
assert_str(tbl, md->key, key); assert_str(tbl, md->key, key);
assert_str(tbl, md->value, value); assert_str(tbl, md->value, value);
} }
@ -143,7 +143,7 @@ static void test_many_additions(void) {
grpc_chttp2_hptbl_init(&exec_ctx, &tbl); grpc_chttp2_hptbl_init(&exec_ctx, &tbl);
for (i = 0; i < 100000; i++) { for (i = 0; i < 100000; i++) {
grpc_mdelem *elem; grpc_mdelem elem;
gpr_asprintf(&key, "K:%d", i); gpr_asprintf(&key, "K:%d", i);
gpr_asprintf(&value, "VALUE:%d", i); gpr_asprintf(&value, "VALUE:%d", i);
elem = elem =
@ -171,7 +171,7 @@ static grpc_chttp2_hptbl_find_result find_simple(grpc_chttp2_hptbl *tbl,
const char *key, const char *key,
const char *value) { const char *value) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_mdelem *md = grpc_mdelem md =
grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key), grpc_mdelem_from_slices(&exec_ctx, grpc_slice_from_copied_string(key),
grpc_slice_from_copied_string(value)); grpc_slice_from_copied_string(value));
grpc_chttp2_hptbl_find_result r = grpc_chttp2_hptbl_find(tbl, md); grpc_chttp2_hptbl_find_result r = grpc_chttp2_hptbl_find(tbl, md);
@ -185,7 +185,7 @@ static void test_find(void) {
grpc_chttp2_hptbl tbl; grpc_chttp2_hptbl tbl;
uint32_t i; uint32_t i;
char buffer[32]; char buffer[32];
grpc_mdelem *elem; grpc_mdelem elem;
grpc_chttp2_hptbl_find_result r; grpc_chttp2_hptbl_find_result r;
LOG_TEST("test_find"); LOG_TEST("test_find");

@ -69,7 +69,7 @@ static grpc_slice maybe_dup(grpc_slice in, bool dup) {
} }
static void test_create_metadata(bool intern_keys, bool intern_values) { static void test_create_metadata(bool intern_keys, bool intern_values) {
grpc_mdelem *m1, *m2, *m3; grpc_mdelem m1, *m2, *m3;
gpr_log(GPR_INFO, "test_create_metadata: intern_keys=%d intern_values=%d", gpr_log(GPR_INFO, "test_create_metadata: intern_keys=%d intern_values=%d",
intern_keys, intern_values); intern_keys, intern_values);
@ -129,8 +129,8 @@ static void test_create_many_ephemeral_metadata(bool intern_keys,
static void test_create_many_persistant_metadata(void) { static void test_create_many_persistant_metadata(void) {
char buffer[GPR_LTOA_MIN_BUFSIZE]; char buffer[GPR_LTOA_MIN_BUFSIZE];
long i; long i;
grpc_mdelem **created = gpr_malloc(sizeof(grpc_mdelem *) * MANY); grpc_mdelem *created = gpr_malloc(sizeof(grpc_mdelem) * MANY);
grpc_mdelem *md; grpc_mdelem md;
gpr_log(GPR_INFO, "test_create_many_persistant_metadata"); gpr_log(GPR_INFO, "test_create_many_persistant_metadata");
@ -170,7 +170,7 @@ static void test_spin_creating_the_same_thing(bool intern_keys,
grpc_init(); grpc_init();
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_mdelem *a, *b, *c; grpc_mdelem a, *b, *c;
GRPC_MDELEM_UNREF( GRPC_MDELEM_UNREF(
&exec_ctx, &exec_ctx,
a = grpc_mdelem_from_slices( a = grpc_mdelem_from_slices(
@ -256,7 +256,7 @@ static void test_things_stick_around(void) {
static void test_user_data_works(void) { static void test_user_data_works(void) {
int *ud1; int *ud1;
int *ud2; int *ud2;
grpc_mdelem *md; grpc_mdelem md;
gpr_log(GPR_INFO, "test_user_data_works"); gpr_log(GPR_INFO, "test_user_data_works");
grpc_init(); grpc_init();
@ -279,7 +279,7 @@ static void test_user_data_works(void) {
static void verify_ascii_header_size(grpc_exec_ctx *exec_ctx, const char *key, static void verify_ascii_header_size(grpc_exec_ctx *exec_ctx, const char *key,
const char *value, bool intern_key, const char *value, bool intern_key,
bool intern_value) { bool intern_value) {
grpc_mdelem *elem = grpc_mdelem_from_slices( grpc_mdelem elem = grpc_mdelem_from_slices(
exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key), exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_string(value), intern_value)); maybe_intern(grpc_slice_from_static_string(value), intern_value));
size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem); size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem);
@ -291,7 +291,7 @@ static void verify_ascii_header_size(grpc_exec_ctx *exec_ctx, const char *key,
static void verify_binary_header_size(grpc_exec_ctx *exec_ctx, const char *key, static void verify_binary_header_size(grpc_exec_ctx *exec_ctx, const char *key,
const uint8_t *value, size_t value_len, const uint8_t *value, size_t value_len,
bool intern_key, bool intern_value) { bool intern_key, bool intern_value) {
grpc_mdelem *elem = grpc_mdelem_from_slices( grpc_mdelem elem = grpc_mdelem_from_slices(
exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key), exec_ctx, maybe_intern(grpc_slice_from_static_string(key), intern_key),
maybe_intern(grpc_slice_from_static_buffer(value, value_len), maybe_intern(grpc_slice_from_static_buffer(value, value_len),
intern_value)); intern_value));
@ -343,8 +343,8 @@ static void test_copied_static_metadata(bool dup_key, bool dup_value) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) { for (size_t i = 0; i < GRPC_STATIC_MDELEM_COUNT; i++) {
grpc_mdelem *p = &grpc_static_mdelem_table[i]; grpc_mdelem p = &grpc_static_mdelem_table[i];
grpc_mdelem *q = grpc_mdelem_from_slices( grpc_mdelem q = grpc_mdelem_from_slices(
&exec_ctx, maybe_dup(p->key, dup_key), maybe_dup(p->value, dup_value)); &exec_ctx, maybe_dup(p->key, dup_key), maybe_dup(p->value, dup_value));
GPR_ASSERT(p == q); GPR_ASSERT(p == q);
} }

@ -355,11 +355,11 @@ for i, elem in enumerate(all_elems):
[len(elem[1])] + [ord(c) for c in elem[1]])) [len(elem[1])] + [ord(c) for c in elem[1]]))
print >>H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems) print >>H, '#define GRPC_STATIC_MDELEM_COUNT %d' % len(all_elems)
print >>H, 'extern grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];' print >>H, 'extern grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT];'
print >>H, 'extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];' print >>H, 'extern uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT];'
for i, elem in enumerate(all_elems): for i, elem in enumerate(all_elems):
print >>H, '/* "%s": "%s" */' % elem print >>H, '/* "%s": "%s" */' % elem
print >>H, '#define %s (&grpc_static_mdelem_table[%d])' % (mangle(elem).upper(), i) print >>H, '#define %s ((grpc_mdelem){&grpc_static_mdelem_table[%d]})' % (mangle(elem).upper(), i)
print >>H print >>H
print >>C, 'uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {' print >>C, 'uintptr_t grpc_static_mdelem_user_data[GRPC_STATIC_MDELEM_COUNT] = {'
print >>C, ' %s' % ','.join('%d' % static_userdata.get(elem, 0) for elem in all_elems) print >>C, ' %s' % ','.join('%d' % static_userdata.get(elem, 0) for elem in all_elems)
@ -435,16 +435,16 @@ print >>C, 'static const uint16_t elem_keys[] = {%s};' % ','.join('%d' % k for k
print >>C, 'static const uint8_t elem_idxs[] = {%s};' % ','.join('%d' % i for i in idxs) print >>C, 'static const uint8_t elem_idxs[] = {%s};' % ','.join('%d' % i for i in idxs)
print >>C print >>C
print >>H, 'grpc_mdelem *grpc_static_mdelem_for_static_strings(int a, int b);' print >>H, 'grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b);'
print >>C, 'grpc_mdelem *grpc_static_mdelem_for_static_strings(int a, int b) {' print >>C, 'grpc_mdelem grpc_static_mdelem_for_static_strings(int a, int b) {'
print >>C, ' if (a == -1 || b == -1) return NULL;' print >>C, ' if (a == -1 || b == -1) return GRPC_MDNULL;'
print >>C, ' uint32_t k = (uint32_t)(a * %d + b);' % len(all_strs) print >>C, ' uint32_t k = (uint32_t)(a * %d + b);' % len(all_strs)
print >>C, ' uint32_t h = elems_phash(k);' print >>C, ' uint32_t h = elems_phash(k);'
print >>C, ' return elem_keys[h] == k ? &grpc_static_mdelem_table[elem_idxs[h]] : NULL;' print >>C, ' return elem_keys[h] == k ? (grpc_mdelem){&grpc_static_mdelem_table[elem_idxs[h]]} : GRPC_MDNULL;'
print >>C, '}' print >>C, '}'
print >>C print >>C
print >>C, 'grpc_mdelem grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {' print >>C, 'grpc_mdelem_data grpc_static_mdelem_table[GRPC_STATIC_MDELEM_COUNT] = {'
for a, b in all_elems: for a, b in all_elems:
print >>C, '{%s,%s},' % (slice_def(str_idx(a)), slice_def(str_idx(b))) print >>C, '{%s,%s},' % (slice_def(str_idx(a)), slice_def(str_idx(b)))
print >>C, '};' print >>C, '};'
@ -455,7 +455,7 @@ print >>C, '0,%s' % ','.join('%d' % md_idx(elem) for elem in compression_elems)
print >>C, '};' print >>C, '};'
print >>C print >>C
print >>H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) (&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]])' print >>H, '#define GRPC_MDELEM_ACCEPT_ENCODING_FOR_ALGORITHMS(algs) ((grpc_mdelem){&grpc_static_mdelem_table[grpc_static_accept_encoding_metadata[(algs)]]})'
print >>H, '#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */' print >>H, '#endif /* GRPC_CORE_LIB_TRANSPORT_STATIC_METADATA_H */'

Loading…
Cancel
Save