Properly handle "." in metadata

pull/5053/head
Craig Tiller 9 years ago
parent efda009e24
commit 6f87164f3c
  1. 2
      src/core/surface/validate_metadata.c
  2. 4
      test/cpp/end2end/async_end2end_test.cc
  3. 2
      tools/codegen/core/gen_legal_metadata_characters.c

@ -50,7 +50,7 @@ static int conforms_to(const char *s, size_t len, const uint8_t *legal_bits) {
int grpc_header_key_is_legal(const char *key, size_t length) {
static const uint8_t legal_header_bits[256 / 8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0xff, 0x03, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 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};
if (length == 0) {

@ -479,8 +479,10 @@ TEST_P(AsyncEnd2endTest, ClientInitialMetadataRpc) {
send_request.set_message("Hello");
std::pair<grpc::string, grpc::string> meta1("key1", "val1");
std::pair<grpc::string, grpc::string> meta2("key2", "val2");
std::pair<grpc::string, grpc::string> meta3("g.r.d-bin", "xyz");
cli_ctx.AddMetadata(meta1.first, meta1.second);
cli_ctx.AddMetadata(meta2.first, meta2.second);
cli_ctx.AddMetadata(meta3.first, meta3.second);
std::unique_ptr<ClientAsyncResponseReader<EchoResponse>> response_reader(
stub_->AsyncEcho(&cli_ctx, send_request, cq_.get()));
@ -494,6 +496,8 @@ TEST_P(AsyncEnd2endTest, ClientInitialMetadataRpc) {
ToString(client_initial_metadata.find(meta1.first)->second));
EXPECT_EQ(meta2.second,
ToString(client_initial_metadata.find(meta2.first)->second));
EXPECT_EQ(meta3.second,
ToString(client_initial_metadata.find(meta3.first)->second));
EXPECT_GE(client_initial_metadata.size(), static_cast<size_t>(2));
send_response.set_message(recv_request.message());

@ -52,7 +52,7 @@ static void legal(int x) {
static void dump(void) {
int i;
printf("static const gpr_uint8 legal_header_bits[256/8] = ");
printf("static const uint8_t legal_header_bits[256/8] = ");
for (i = 0; i < 256 / 8; i++)
printf("%c 0x%02x", i ? ',' : '{', legal_bits[i]);
printf(" };\n");

Loading…
Cancel
Save