aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-04-04 16:05:23 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-04-04 16:05:23 -0700
commitc5548cce42f8c4783c3c0368ea3ce00a196ff944 (patch)
tree2e8bfafb0eef115e1515aa140bcda2c53dbe351e
parentee787caf0eb143f00092756bafcdb0f82f5f1a55 (diff)
Add parsing for true-binary metadata
-rw-r--r--src/core/ext/transport/chttp2/transport/hpack_parser.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.c b/src/core/ext/transport/chttp2/transport/hpack_parser.c
index 5099d736bf..1846a85fc6 100644
--- a/src/core/ext/transport/chttp2/transport/hpack_parser.c
+++ b/src/core/ext/transport/chttp2/transport/hpack_parser.c
@@ -38,11 +38,6 @@
#include <stddef.h>
#include <string.h>
-/* This is here for grpc_is_binary_header
- * TODO(murgatroid99): Remove this
- */
-#include <grpc/grpc.h>
-
#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include <grpc/support/port_platform.h>
@@ -55,13 +50,11 @@
#include "src/core/lib/support/string.h"
#include "src/core/lib/transport/http2_errors.h"
-/* TODO(ctiller): remove before submission */
-#include "src/core/lib/slice/slice_string_helpers.h"
-
extern int grpc_http_trace;
typedef enum {
NOT_BINARY,
+ BINARY_BEGIN,
B64_BYTE0,
B64_BYTE1,
B64_BYTE2,
@@ -1325,6 +1318,19 @@ static grpc_error *append_string(grpc_exec_ctx *exec_ctx,
case NOT_BINARY:
append_bytes(str, cur, (size_t)(end - cur));
return GRPC_ERROR_NONE;
+ case BINARY_BEGIN:
+ if (cur == end) {
+ p->binary = BINARY_BEGIN;
+ return GRPC_ERROR_NONE;
+ }
+ if (*cur == 0) {
+ /* 'true-binary' case */
+ ++cur;
+ p->binary = NOT_BINARY;
+ append_bytes(str, cur, (size_t)(end - cur));
+ return GRPC_ERROR_NONE;
+ }
+ /* fallthrough */
b64_byte0:
case B64_BYTE0:
if (cur == end) {
@@ -1409,6 +1415,8 @@ static grpc_error *finish_str(grpc_exec_ctx *exec_ctx,
switch ((binary_state)p->binary) {
case NOT_BINARY:
break;
+ case BINARY_BEGIN:
+ break;
case B64_BYTE0:
break;
case B64_BYTE1:
@@ -1571,7 +1579,7 @@ static grpc_error *parse_value_string(grpc_exec_ctx *exec_ctx,
const uint8_t *cur, const uint8_t *end,
bool is_binary) {
return begin_parse_string(exec_ctx, p, cur, end,
- is_binary ? B64_BYTE0 : NOT_BINARY, &p->value);
+ is_binary ? BINARY_BEGIN : NOT_BINARY, &p->value);
}
static grpc_error *parse_value_string_with_indexed_key(