MCPcopy Create free account
hub / github.com/apache/brpc / AddHeader

Function AddHeader

src/brpc/details/hpack.cpp:150–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

148 }
149
150 void AddHeader(const Header& h) {
151 CHECK(!h.name.empty());
152 const size_t entry_size = HeaderSize(h);
153
154 while (!empty() && (_size + entry_size) > _max_size) {
155 PopHeader();
156 }
157
158 if (entry_size > _max_size) {
159 // https://tools.ietf.org/html/rfc7541#section-4.1
160 // If this header is larger than the max size, clear the table only.
161 DCHECK(empty());
162 return;
163 }
164
165 _size += entry_size;
166 CHECK(!_header_queue.full());
167 _header_queue.push(h);
168
169 const int id = _add_times++;
170 if (_need_indexes) {
171 // Overwrite existance value.
172 if (!h.value.empty()) {
173 _header_index[h] = id;
174 }
175 _name_index[h.name] = id;
176 }
177 }
178
179 void ResetMaxSize(size_t new_max_size) {
180 LOG(INFO) << this << ".size=" << _size << " new_max_size=" << new_max_size

Callers 2

AppendHeaderMethod · 0.85
InitMethod · 0.85

Calls 6

HeaderSizeFunction · 0.85
PopHeaderFunction · 0.85
emptyFunction · 0.70
emptyMethod · 0.45
fullMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected