diff options
author | Craig Tiller <ctiller@google.com> | 2016-01-06 16:38:12 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2016-01-06 16:38:12 -0800 |
commit | 160a690a4cdbb8b359580564bfda215259dc0d52 (patch) | |
tree | 311cc8df38536b5b76f67354e2e1b8ccc039a5d1 /src/core/transport/metadata.c | |
parent | 296ae72581f17438e9355d4862c3ad5c66d49807 (diff) | |
parent | 36187ab66b562a536d13999ee31c36cdee760d48 (diff) |
Merge pull request #4633 from murgatroid99/core_validate_metadata
Expose core metadata validation functions in public headers
Diffstat (limited to 'src/core/transport/metadata.c')
-rw-r--r-- | src/core/transport/metadata.c | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/src/core/transport/metadata.c b/src/core/transport/metadata.c index df05d1a302..e645ef9d8c 100644 --- a/src/core/transport/metadata.c +++ b/src/core/transport/metadata.c @@ -688,37 +688,3 @@ gpr_slice grpc_mdstr_as_base64_encoded_and_huffman_compressed(grpc_mdstr *gs) { gpr_mu_unlock(&shard->mu); return slice; } - -static int conforms_to(grpc_mdstr *s, const gpr_uint8 *legal_bits) { - const gpr_uint8 *p = GPR_SLICE_START_PTR(s->slice); - const gpr_uint8 *e = GPR_SLICE_END_PTR(s->slice); - for (; p != e; p++) { - int idx = *p; - int byte = idx / 8; - int bit = idx % 8; - if ((legal_bits[byte] & (1 << bit)) == 0) return 0; - } - return 1; -} - -int grpc_mdstr_is_legal_header(grpc_mdstr *s) { - static const gpr_uint8 legal_header_bits[256 / 8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xff, 0x03, 0x00, 0x00, 0x00, - 0x80, 0xfe, 0xff, 0xff, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - return conforms_to(s, legal_header_bits); -} - -int grpc_mdstr_is_legal_nonbin_header(grpc_mdstr *s) { - static const gpr_uint8 legal_header_bits[256 / 8] = { - 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - return conforms_to(s, legal_header_bits); -} - -int grpc_mdstr_is_bin_suffixed(grpc_mdstr *s) { - /* TODO(ctiller): consider caching this */ - return grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(s->slice), - GPR_SLICE_LENGTH(s->slice)); -} |