GRPC C++  1.39.1
hpack_parser.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2015 gRPC authors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H
20 #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H
21 
23 
24 #include <stddef.h>
25 
29 
31 
33  grpc_chttp2_hpack_parser* p, const uint8_t* beg, const uint8_t* end);
34 
36  bool copied;
37  struct {
39  struct {
40  char* str;
41  uint32_t length;
42  uint32_t capacity;
43  } copied;
44  } data;
45 };
47  /* user specified callback for each header output */
48  grpc_error_handle (*on_header)(void* user_data, grpc_mdelem md);
50 
52 
53  /* current parse state - or a function that implements it */
55  /* future states dependent on the opening op code */
57  /* what to do after skipping prioritization data */
59  /* the refcount of the slice that we're currently parsing */
61  /* the value we're currently parsing */
62  union {
63  uint32_t* value;
66  /* string parameters for each chunk */
69  /* parsed index */
70  uint32_t index;
71  /* When we parse a value string, we determine the metadata element for a
72  specific index, which we need again when we're finishing up with that
73  header. To avoid calculating the metadata element for that index a second
74  time at that stage, we cache (and invalidate) the element here. */
76 #ifndef NDEBUG
78 #endif
79  /* length of source bytes for the currently parsing string */
80  uint32_t strlen;
81  /* number of source bytes read for the currently parsing string */
82  uint32_t strgot;
83  /* huffman decoding state */
84  int16_t huff_state;
85  /* is the string being decoded binary? */
86  uint8_t binary;
87  /* is the current string huffman encoded? */
88  uint8_t huff;
89  /* is a dynamic table update allowed? */
91  /* set by higher layers, used by grpc_chttp2_header_parser_parse to signal
92  it should append a metadata boundary at the end of frame */
93  uint8_t is_boundary;
94  uint8_t is_eof;
95  uint32_t base64_buffer;
96 
97  /* hpack table */
99 };
100 
103 
105 
107  const grpc_slice& slice);
108 
109 /* wraps grpc_chttp2_hpack_parser_parse to provide a frame level parser for
110  the transport */
114  const grpc_slice& slice,
115  int is_last);
116 
117 #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */
grpc_error * grpc_error_handle
Definition: error.h:48
grpc_error_handle grpc_chttp2_header_parser_parse(void *hpack_parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, const grpc_slice &slice, int is_last)
Definition: hpack_parser.cc:1731
grpc_error_handle(* grpc_chttp2_hpack_parser_state)(grpc_chttp2_hpack_parser *p, const uint8_t *beg, const uint8_t *end)
Definition: hpack_parser.h:32
grpc_error_handle grpc_chttp2_hpack_parser_parse(grpc_chttp2_hpack_parser *p, const grpc_slice &slice)
Definition: hpack_parser.cc:1677
void grpc_chttp2_hpack_parser_init(grpc_chttp2_hpack_parser *p)
Definition: hpack_parser.cc:1635
void grpc_chttp2_hpack_parser_set_has_priority(grpc_chttp2_hpack_parser *p)
Definition: hpack_parser.cc:1663
void grpc_chttp2_hpack_parser_destroy(grpc_chttp2_hpack_parser *p)
Definition: hpack_parser.cc:1668
grpc_slice slice
Definition: server.cc:461
Definition: hpack_parser.h:35
grpc_slice referenced
Definition: hpack_parser.h:38
struct grpc_chttp2_hpack_parser_string::@13 data
uint32_t length
Definition: hpack_parser.h:41
uint32_t capacity
Definition: hpack_parser.h:42
char * str
Definition: hpack_parser.h:40
bool copied
Definition: hpack_parser.h:36
Definition: hpack_parser.h:46
uint32_t strgot
Definition: hpack_parser.h:82
uint32_t * value
Definition: hpack_parser.h:63
uint8_t is_eof
Definition: hpack_parser.h:94
uint8_t binary
Definition: hpack_parser.h:86
union grpc_chttp2_hpack_parser::@15 parsing
grpc_chttp2_hpack_parser_string key
Definition: hpack_parser.h:67
grpc_chttp2_hpack_parser_string * str
Definition: hpack_parser.h:64
grpc_chttp2_hpack_parser_string value
Definition: hpack_parser.h:68
grpc_error_handle last_error
Definition: hpack_parser.h:51
uint8_t dynamic_table_update_allowed
Definition: hpack_parser.h:90
grpc_chttp2_hpack_parser_state state
Definition: hpack_parser.h:54
const grpc_chttp2_hpack_parser_state * next_state
Definition: hpack_parser.h:56
uint8_t huff
Definition: hpack_parser.h:88
void * on_header_user_data
Definition: hpack_parser.h:49
grpc_chttp2_hptbl table
Definition: hpack_parser.h:98
grpc_error_handle(* on_header)(void *user_data, grpc_mdelem md)
Definition: hpack_parser.h:48
grpc_mdelem md_for_index
Definition: hpack_parser.h:75
uint32_t base64_buffer
Definition: hpack_parser.h:95
uint32_t strlen
Definition: hpack_parser.h:80
int64_t precomputed_md_index
Definition: hpack_parser.h:77
uint32_t index
Definition: hpack_parser.h:70
grpc_chttp2_hpack_parser_state after_prioritization
Definition: hpack_parser.h:58
uint8_t is_boundary
Definition: hpack_parser.h:93
int16_t huff_state
Definition: hpack_parser.h:84
grpc_slice_refcount * current_slice_refcount
Definition: hpack_parser.h:60
Definition: hpack_table.h:50
Definition: internal.h:509
Definition: internal.h:288
Definition: error_internal.h:41
Definition: metadata.h:98
Definition: slice_internal.h:100
A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1].
Definition: slice.h:60