|
|
@ -134,7 +134,7 @@ static void begin_new_frame(framer_state *st, frame_type type) { |
|
|
|
space to add at least about_to_add bytes -- finishes the current frame if |
|
|
|
space to add at least about_to_add bytes -- finishes the current frame if |
|
|
|
needed */ |
|
|
|
needed */ |
|
|
|
static void ensure_frame_type(framer_state *st, frame_type type, |
|
|
|
static void ensure_frame_type(framer_state *st, frame_type type, |
|
|
|
int need_bytes) { |
|
|
|
size_t need_bytes) { |
|
|
|
if (st->cur_frame_type == type && |
|
|
|
if (st->cur_frame_type == type && |
|
|
|
st->output->length - st->output_length_at_start_of_frame + need_bytes <= |
|
|
|
st->output->length - st->output_length_at_start_of_frame + need_bytes <= |
|
|
|
GRPC_CHTTP2_MAX_PAYLOAD_LENGTH) { |
|
|
|
GRPC_CHTTP2_MAX_PAYLOAD_LENGTH) { |
|
|
@ -174,7 +174,7 @@ static void add_header_data(framer_state *st, gpr_slice slice) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static gpr_uint8 *add_tiny_header_data(framer_state *st, int len) { |
|
|
|
static gpr_uint8 *add_tiny_header_data(framer_state *st, size_t len) { |
|
|
|
ensure_frame_type(st, HEADER, len); |
|
|
|
ensure_frame_type(st, HEADER, len); |
|
|
|
return gpr_slice_buffer_tiny_add(st->output, len); |
|
|
|
return gpr_slice_buffer_tiny_add(st->output, len); |
|
|
|
} |
|
|
|
} |
|
|
@ -270,7 +270,7 @@ static grpc_mdelem *add_elem(grpc_chttp2_hpack_compressor *c, |
|
|
|
|
|
|
|
|
|
|
|
static void emit_indexed(grpc_chttp2_hpack_compressor *c, gpr_uint32 index, |
|
|
|
static void emit_indexed(grpc_chttp2_hpack_compressor *c, gpr_uint32 index, |
|
|
|
framer_state *st) { |
|
|
|
framer_state *st) { |
|
|
|
int len = GRPC_CHTTP2_VARINT_LENGTH(index, 1); |
|
|
|
size_t len = GRPC_CHTTP2_VARINT_LENGTH(index, 1); |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(index, 1, 0x80, add_tiny_header_data(st, len), len); |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(index, 1, 0x80, add_tiny_header_data(st, len), len); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -288,11 +288,11 @@ static gpr_slice get_wire_value(grpc_mdelem *elem, gpr_uint8 *huffman_prefix) { |
|
|
|
static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c, |
|
|
|
static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c, |
|
|
|
gpr_uint32 key_index, grpc_mdelem *elem, |
|
|
|
gpr_uint32 key_index, grpc_mdelem *elem, |
|
|
|
framer_state *st) { |
|
|
|
framer_state *st) { |
|
|
|
int len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2); |
|
|
|
gpr_uint32 len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2); |
|
|
|
gpr_uint8 huffman_prefix; |
|
|
|
gpr_uint8 huffman_prefix; |
|
|
|
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); |
|
|
|
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); |
|
|
|
int len_val = GPR_SLICE_LENGTH(value_slice); |
|
|
|
gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice); |
|
|
|
int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); |
|
|
|
gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, |
|
|
|
add_tiny_header_data(st, len_pfx), len_pfx); |
|
|
|
add_tiny_header_data(st, len_pfx), len_pfx); |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, 0x00, |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, 0x00, |
|
|
@ -303,11 +303,11 @@ 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, |
|
|
|
gpr_uint32 key_index, grpc_mdelem *elem, |
|
|
|
gpr_uint32 key_index, grpc_mdelem *elem, |
|
|
|
framer_state *st) { |
|
|
|
framer_state *st) { |
|
|
|
int len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); |
|
|
|
gpr_uint32 len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); |
|
|
|
gpr_uint8 huffman_prefix; |
|
|
|
gpr_uint8 huffman_prefix; |
|
|
|
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); |
|
|
|
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); |
|
|
|
int len_val = GPR_SLICE_LENGTH(value_slice); |
|
|
|
gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice); |
|
|
|
int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); |
|
|
|
gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, |
|
|
|
add_tiny_header_data(st, len_pfx), len_pfx); |
|
|
|
add_tiny_header_data(st, len_pfx), len_pfx); |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, 0x00, |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, 0x00, |
|
|
@ -317,12 +317,12 @@ 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) { |
|
|
|
int len_key = GPR_SLICE_LENGTH(elem->key->slice); |
|
|
|
gpr_uint32 len_key = GPR_SLICE_LENGTH(elem->key->slice); |
|
|
|
gpr_uint8 huffman_prefix; |
|
|
|
gpr_uint8 huffman_prefix; |
|
|
|
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); |
|
|
|
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); |
|
|
|
int len_val = GPR_SLICE_LENGTH(value_slice); |
|
|
|
gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice); |
|
|
|
int len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); |
|
|
|
gpr_uint32 len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); |
|
|
|
int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); |
|
|
|
gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); |
|
|
|
*add_tiny_header_data(st, 1) = 0x40; |
|
|
|
*add_tiny_header_data(st, 1) = 0x40; |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, |
|
|
|
add_tiny_header_data(st, len_key_len), len_key_len); |
|
|
|
add_tiny_header_data(st, len_key_len), len_key_len); |
|
|
@ -334,12 +334,12 @@ 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) { |
|
|
|
int len_key = GPR_SLICE_LENGTH(elem->key->slice); |
|
|
|
gpr_uint32 len_key = GPR_SLICE_LENGTH(elem->key->slice); |
|
|
|
gpr_uint8 huffman_prefix; |
|
|
|
gpr_uint8 huffman_prefix; |
|
|
|
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); |
|
|
|
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); |
|
|
|
int len_val = GPR_SLICE_LENGTH(value_slice); |
|
|
|
gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice); |
|
|
|
int len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); |
|
|
|
gpr_uint32 len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); |
|
|
|
int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); |
|
|
|
gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); |
|
|
|
*add_tiny_header_data(st, 1) = 0x00; |
|
|
|
*add_tiny_header_data(st, 1) = 0x00; |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, |
|
|
|
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, |
|
|
|
add_tiny_header_data(st, len_key_len), len_key_len); |
|
|
|
add_tiny_header_data(st, len_key_len), len_key_len); |
|
|
|