hpack_encoder.cc
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 
20 
22 
23 #include <algorithm>
24 #include <cstdint>
25 #include <memory>
26 
27 #include "absl/utility/utility.h"
28 
29 #include <grpc/slice.h>
30 #include <grpc/slice_buffer.h>
31 #include <grpc/support/log.h>
32 
42 
43 namespace grpc_core {
44 
45 namespace {
46 
47 constexpr size_t kDataFrameHeaderSize = 9;
48 
49 } /* namespace */
50 
51 /* fills p (which is expected to be kDataFrameHeaderSize bytes long)
52  * with a data frame header */
53 static void FillHeader(uint8_t* p, uint8_t type, uint32_t id, size_t len,
54  uint8_t flags) {
55  /* len is the current frame size (i.e. for the frame we're finishing).
56  We finish a frame if:
57  1) We called ensure_space(), (i.e. add_tiny_header_data()) and adding
58  'need_bytes' to the frame would cause us to exceed max_frame_size.
59  2) We called add_header_data, and adding the slice would cause us to exceed
60  max_frame_size.
61  3) We're done encoding the header.
62 
63  Thus, len is always <= max_frame_size.
64  max_frame_size is derived from GRPC_CHTTP2_SETTINGS_MAX_FRAME_SIZE,
65  which has a max allowable value of 16777215 (see chttp_transport.cc).
66  Thus, the following assert can be a debug assert. */
67  GPR_DEBUG_ASSERT(len < 16777316);
68  *p++ = static_cast<uint8_t>(len >> 16);
69  *p++ = static_cast<uint8_t>(len >> 8);
70  *p++ = static_cast<uint8_t>(len);
71  *p++ = type;
72  *p++ = flags;
73  *p++ = static_cast<uint8_t>(id >> 24);
74  *p++ = static_cast<uint8_t>(id >> 16);
75  *p++ = static_cast<uint8_t>(id >> 8);
76  *p++ = static_cast<uint8_t>(id);
77 }
78 
80  const size_t frame_size =
82  GPR_DEBUG_ASSERT(frame_size <= max_frame_size_);
83  return frame_size;
84 }
85 
86 // finish a frame - fill in the previously reserved header
87 void HPackCompressor::Framer::FinishFrame(bool is_header_boundary) {
88  const uint8_t type = is_first_frame_ ? GRPC_CHTTP2_FRAME_HEADER
90  uint8_t flags = 0;
91  // per the HTTP/2 spec:
92  // A HEADERS frame carries the END_STREAM flag that signals the end of a
93  // stream. However, a HEADERS frame with the END_STREAM flag set can be
94  // followed by CONTINUATION frames on the same stream. Logically, the
95  // CONTINUATION frames are part of the HEADERS frame.
96  // Thus, we add the END_STREAM flag to the HEADER frame (the first frame).
97  if (is_first_frame_ && is_end_of_stream_) {
99  }
100  // per the HTTP/2 spec:
101  // A HEADERS frame without the END_HEADERS flag set MUST be followed by
102  // a CONTINUATION frame for the same stream.
103  // Thus, we add the END_HEADER flag to the last frame.
104  if (is_header_boundary) {
106  }
107  FillHeader(GRPC_SLICE_START_PTR(output_->slices[prefix_.header_idx]), type,
108  stream_id_, CurrentFrameSize(), flags);
109  stats_->framing_bytes += kDataFrameHeaderSize;
110  is_first_frame_ = false;
111 }
112 
113 // begin a new frame: reserve off header space, remember how many bytes we'd
114 // output before beginning
116  grpc_slice reserved;
117  reserved.refcount = nullptr;
118  reserved.data.inlined.length = kDataFrameHeaderSize;
120  output_->length};
121 }
122 
123 // make sure that the current frame is of the type desired, and has sufficient
124 // space to add at least about_to_add bytes -- finishes the current frame if
125 // needed
126 void HPackCompressor::Framer::EnsureSpace(size_t need_bytes) {
127  if (GPR_LIKELY(CurrentFrameSize() + need_bytes <= max_frame_size_)) {
128  return;
129  }
130  FinishFrame(false);
131  prefix_ = BeginFrame();
132 }
133 
135  while (true) {
136  const size_t len = slice.length();
137  if (len == 0) return;
138  const size_t remaining = max_frame_size_ - CurrentFrameSize();
139  if (len <= remaining) {
140  stats_->header_bytes += len;
141  grpc_slice_buffer_add(output_, slice.TakeCSlice());
142  return;
143  } else {
144  stats_->header_bytes += remaining;
145  Slice tail = slice.Split(remaining);
146  grpc_slice_buffer_add(output_, slice.TakeCSlice());
147  slice = std::move(tail);
148  FinishFrame(false);
149  prefix_ = BeginFrame();
150  }
151  }
152 }
153 
155  EnsureSpace(len);
156  stats_->header_bytes += len;
158 }
159 
162  VarintWriter<1> w(elem_index);
163  w.Write(0x80, AddTiny(w.length()));
164 }
165 
166 struct WireValue {
167  WireValue(uint8_t huffman_prefix, bool insert_null_before_wire_value,
168  Slice slice)
169  : data(std::move(slice)),
170  huffman_prefix(huffman_prefix),
171  insert_null_before_wire_value(insert_null_before_wire_value),
172  length(data.length() + (insert_null_before_wire_value ? 1 : 0)) {}
176  const size_t length;
177 };
178 
179 static WireValue GetWireValue(Slice value, bool true_binary_enabled,
180  bool is_bin_hdr) {
181  if (is_bin_hdr) {
182  if (true_binary_enabled) {
184  return WireValue(0x00, true, std::move(value));
185  } else {
187  return WireValue(0x80, false,
189  value.c_slice())));
190  }
191  } else {
192  /* TODO(ctiller): opportunistically compress non-binary headers */
194  return WireValue(0x00, false, std::move(value));
195  }
196 }
197 
199  static bool IsBinary(grpc_slice key) {
201  }
202 };
204  static bool IsBinary(grpc_slice key) {
206  }
207 };
208 
210  public:
211  explicit BinaryStringValue(Slice value, bool use_true_binary_metadata)
212  : wire_value_(
213  GetWireValue(std::move(value), use_true_binary_metadata, true)),
214  len_val_(wire_value_.length) {}
215 
216  size_t prefix_length() const {
217  return len_val_.length() +
218  (wire_value_.insert_null_before_wire_value ? 1 : 0);
219  }
220 
221  void WritePrefix(uint8_t* prefix_data) {
222  len_val_.Write(wire_value_.huffman_prefix, prefix_data);
223  if (wire_value_.insert_null_before_wire_value) {
224  prefix_data[len_val_.length()] = 0;
225  }
226  }
227 
228  Slice data() { return std::move(wire_value_.data); }
229 
230  private:
233 };
234 
236  public:
238  : value_(std::move(value)), len_val_(value_.length()) {}
239 
240  size_t prefix_length() const { return len_val_.length(); }
241 
242  void WritePrefix(uint8_t* prefix_data) { len_val_.Write(0x00, prefix_data); }
243 
244  Slice data() { return std::move(value_); }
245 
246  private:
249 };
250 
251 class StringKey {
252  public:
253  explicit StringKey(Slice key)
254  : key_(std::move(key)), len_key_(key_.length()) {}
255 
256  size_t prefix_length() const { return 1 + len_key_.length(); }
257 
259  data[0] = type;
260  len_key_.Write(0x00, data + 1);
261  }
262 
263  Slice key() { return std::move(key_); }
264 
265  private:
268 };
269 
271  Slice key_slice, Slice value_slice) {
274  StringKey key(std::move(key_slice));
275  key.WritePrefix(0x40, AddTiny(key.prefix_length()));
276  Add(key.key());
277  NonBinaryStringValue emit(std::move(value_slice));
278  emit.WritePrefix(AddTiny(emit.prefix_length()));
279  Add(emit.data());
280 }
281 
283  Slice key_slice, Slice value_slice) {
286  StringKey key(std::move(key_slice));
287  key.WritePrefix(0x00, AddTiny(key.prefix_length()));
288  Add(key.key());
289  BinaryStringValue emit(std::move(value_slice), use_true_binary_metadata_);
290  emit.WritePrefix(AddTiny(emit.prefix_length()));
291  Add(emit.data());
292 }
293 
295  Slice key_slice, Slice value_slice) {
298  StringKey key(std::move(key_slice));
299  key.WritePrefix(0x40, AddTiny(key.prefix_length()));
300  Add(key.key());
301  BinaryStringValue emit(std::move(value_slice), use_true_binary_metadata_);
302  emit.WritePrefix(AddTiny(emit.prefix_length()));
303  Add(emit.data());
304 }
305 
307  uint32_t key_index, Slice value_slice) {
310  BinaryStringValue emit(std::move(value_slice), use_true_binary_metadata_);
311  VarintWriter<4> key(key_index);
312  uint8_t* data = AddTiny(key.length() + emit.prefix_length());
313  key.Write(0x00, data);
314  emit.WritePrefix(data + key.length());
315  Add(emit.data());
316 }
317 
319  Slice key_slice, Slice value_slice) {
322  StringKey key(std::move(key_slice));
323  key.WritePrefix(0x00, AddTiny(key.prefix_length()));
324  Add(key.key());
325  NonBinaryStringValue emit(std::move(value_slice));
326  emit.WritePrefix(AddTiny(emit.prefix_length()));
327  Add(emit.data());
328 }
329 
331  VarintWriter<3> w(compressor_->table_.max_size());
332  w.Write(0x20, AddTiny(w.length()));
333 }
334 
336  const Slice& value, Framer* framer) {
337  auto& table = framer->compressor_->table_;
339  It prev = values_.end();
340  uint32_t transport_length =
341  key.length() + value.length() + hpack_constants::kEntryOverhead;
342  if (transport_length > HPackEncoderTable::MaxEntrySize()) {
344  value.Ref());
345  return;
346  }
347  // Linear scan through previous values to see if we find the value.
348  for (It it = values_.begin(); it != values_.end(); ++it) {
349  if (value == it->value) {
350  // Got a hit... is it still in the decode table?
351  if (table.ConvertableToDynamicIndex(it->index)) {
352  // Yes, emit the index and proceed to cleanup.
353  framer->EmitIndexed(table.DynamicIndex(it->index));
354  } else {
355  // Not current, emit a new literal and update the index.
356  it->index = table.AllocateIndex(transport_length);
359  }
360  // Bubble this entry up if we can - ensures that the most used values end
361  // up towards the start of the array.
362  if (prev != values_.end()) std::swap(*prev, *it);
363  // If there are entries at the end of the array, and those entries are no
364  // longer in the table, remove them.
365  while (!values_.empty() &&
366  !table.ConvertableToDynamicIndex(values_.back().index)) {
367  values_.pop_back();
368  }
369  // All done, early out.
370  return;
371  }
372  prev = it;
373  }
374  // No hit, emit a new literal and add it to the index.
375  uint32_t index = table.AllocateIndex(transport_length);
377  value.Ref());
378  values_.emplace_back(value.Ref(), index);
379 }
380 
382  if (absl::EndsWith(key.as_string_view(), "-bin")) {
383  EmitLitHdrWithBinaryStringKeyNotIdx(key.Ref(), value.Ref());
384  } else {
385  EmitLitHdrWithNonBinaryStringKeyNotIdx(key.Ref(), value.Ref());
386  }
387 }
388 
390  compressor_->path_index_.EmitTo(HttpPathMetadata::key(), value, this);
391 }
392 
394  const Slice& value) {
395  compressor_->authority_index_.EmitTo(HttpAuthorityMetadata::key(), value,
396  this);
397 }
398 
400  GPR_ASSERT(value == TeMetadata::ValueType::kTrailers);
401  EncodeAlwaysIndexed(
402  &compressor_->te_index_, "te", Slice::FromStaticString("trailers"),
403  2 /* te */ + 8 /* trailers */ + hpack_constants::kEntryOverhead);
404 }
405 
408  if (value != ContentTypeMetadata::ValueType::kApplicationGrpc) {
409  gpr_log(GPR_ERROR, "Not encoding bad content-type header");
410  return;
411  }
412  EncodeAlwaysIndexed(&compressor_->content_type_index_, "content-type",
413  Slice::FromStaticString("application/grpc"),
414  12 /* content-type */ + 16 /* application/grpc */ +
416 }
417 
420  switch (value) {
421  case HttpSchemeMetadata::ValueType::kHttp:
422  EmitIndexed(6); // :scheme: http
423  break;
424  case HttpSchemeMetadata::ValueType::kHttps:
425  EmitIndexed(7); // :scheme: https
426  break;
427  case HttpSchemeMetadata::ValueType::kInvalid:
428  GPR_ASSERT(false);
429  break;
430  }
431 }
432 
434  EncodeIndexedKeyWithBinaryValue(&compressor_->grpc_trace_bin_index_,
435  "grpc-trace-bin", slice.Ref());
436 }
437 
439  EncodeIndexedKeyWithBinaryValue(&compressor_->grpc_tags_bin_index_,
440  "grpc-tags-bin", slice.Ref());
441 }
442 
444  if (status == 200) {
445  EmitIndexed(8); // :status: 200
446  return;
447  }
448  uint8_t index = 0;
449  switch (status) {
450  case 204:
451  index = 9; // :status: 204
452  break;
453  case 206:
454  index = 10; // :status: 206
455  break;
456  case 304:
457  index = 11; // :status: 304
458  break;
459  case 400:
460  index = 12; // :status: 400
461  break;
462  case 404:
463  index = 13; // :status: 404
464  break;
465  case 500:
466  index = 14; // :status: 500
467  break;
468  }
469  if (GPR_LIKELY(index != 0)) {
470  EmitIndexed(index);
471  } else {
472  EmitLitHdrWithNonBinaryStringKeyIncIdx(Slice::FromStaticString(":status"),
474  }
475 }
476 
479  switch (method) {
480  case HttpMethodMetadata::ValueType::kPost:
481  EmitIndexed(3); // :method: POST
482  break;
483  case HttpMethodMetadata::ValueType::kGet:
484  EmitIndexed(2); // :method: GET
485  break;
486  case HttpMethodMetadata::ValueType::kPut:
487  // Right now, we only emit PUT as a method for testing purposes, so it's
488  // fine to not index it.
489  EmitLitHdrWithNonBinaryStringKeyNotIdx(Slice::FromStaticString(":method"),
490  Slice::FromStaticString("PUT"));
491  break;
492  case HttpMethodMetadata::ValueType::kInvalid:
493  GPR_ASSERT(false);
494  break;
495  }
496 }
497 
500  Slice value,
501  uint32_t transport_length) {
502  if (compressor_->table_.ConvertableToDynamicIndex(*index)) {
503  EmitIndexed(compressor_->table_.DynamicIndex(*index));
504  } else {
505  *index = compressor_->table_.AllocateIndex(transport_length);
506  EmitLitHdrWithNonBinaryStringKeyIncIdx(Slice::FromStaticString(key),
507  std::move(value));
508  }
509 }
510 
513  if (compressor_->table_.ConvertableToDynamicIndex(*index)) {
514  EmitLitHdrWithBinaryStringKeyNotIdx(
515  compressor_->table_.DynamicIndex(*index), std::move(value));
516  } else {
517  *index = compressor_->table_.AllocateIndex(key.length() + value.length() +
519  EmitLitHdrWithBinaryStringKeyIncIdx(Slice::FromStaticString(key),
520  std::move(value));
521  }
522 }
523 
526  for (auto it = compressor_->previous_timeouts_.begin();
527  it != compressor_->previous_timeouts_.end(); ++it) {
528  double ratio = timeout.RatioVersus(it->timeout);
529  // If the timeout we're sending is shorter than a previous timeout, but
530  // within 3% of it, we'll consider sending it.
531  if (ratio > -3 && ratio <= 0 &&
532  compressor_->table_.ConvertableToDynamicIndex(it->index)) {
533  EmitIndexed(compressor_->table_.DynamicIndex(it->index));
534  // Put this timeout to the front of the queue - forces common timeouts to
535  // be considered earlier.
536  std::swap(*it, *compressor_->previous_timeouts_.begin());
537  return;
538  }
539  }
540  // Clean out some expired timeouts.
541  while (!compressor_->previous_timeouts_.empty() &&
542  !compressor_->table_.ConvertableToDynamicIndex(
543  compressor_->previous_timeouts_.back().index)) {
544  compressor_->previous_timeouts_.pop_back();
545  }
546  Slice encoded = timeout.Encode();
547  uint32_t index = compressor_->table_.AllocateIndex(
548  GrpcTimeoutMetadata::key().length() + encoded.length() +
550  compressor_->previous_timeouts_.push_back(PreviousTimeout{timeout, index});
551  EmitLitHdrWithNonBinaryStringKeyIncIdx(
553 }
554 
556  if (slice.length() > HPackEncoderTable::MaxEntrySize()) {
557  EmitLitHdrWithNonBinaryStringKeyNotIdx(
559  return;
560  }
561  if (!slice.is_equivalent(compressor_->user_agent_)) {
562  compressor_->user_agent_ = slice.Ref();
563  compressor_->user_agent_index_ = 0;
564  }
565  EncodeAlwaysIndexed(
566  &compressor_->user_agent_index_, "user-agent", slice.Ref(),
567  10 /* user-agent */ + slice.size() + hpack_constants::kEntryOverhead);
568 }
569 
572  const uint32_t code = static_cast<uint32_t>(status);
573  uint32_t* index = nullptr;
575  index = &compressor_->cached_grpc_status_[code];
576  if (compressor_->table_.ConvertableToDynamicIndex(*index)) {
577  EmitIndexed(compressor_->table_.DynamicIndex(*index));
578  return;
579  }
580  }
583  const uint32_t transport_length =
584  key.length() + value.length() + hpack_constants::kEntryOverhead;
585  if (index != nullptr) {
586  *index = compressor_->table_.AllocateIndex(transport_length);
587  EmitLitHdrWithNonBinaryStringKeyIncIdx(std::move(key), std::move(value));
588  } else {
589  EmitLitHdrWithNonBinaryStringKeyNotIdx(std::move(key), std::move(value));
590  }
591 }
592 
595  uint32_t* index = nullptr;
597  index = &compressor_->cached_grpc_encoding_[static_cast<uint32_t>(value)];
598  if (compressor_->table_.ConvertableToDynamicIndex(*index)) {
599  EmitIndexed(compressor_->table_.DynamicIndex(*index));
600  return;
601  }
602  }
604  auto encoded_value = GrpcEncodingMetadata::Encode(value);
605  uint32_t transport_length =
606  key.length() + encoded_value.length() + hpack_constants::kEntryOverhead;
607  if (index != nullptr) {
608  *index = compressor_->table_.AllocateIndex(transport_length);
609  EmitLitHdrWithNonBinaryStringKeyIncIdx(std::move(key),
610  std::move(encoded_value));
611  } else {
612  EmitLitHdrWithNonBinaryStringKeyNotIdx(std::move(key),
613  std::move(encoded_value));
614  }
615 }
616 
619  if (compressor_->grpc_accept_encoding_index_ != 0 &&
620  value == compressor_->grpc_accept_encoding_ &&
621  compressor_->table_.ConvertableToDynamicIndex(
622  compressor_->grpc_accept_encoding_index_)) {
623  EmitIndexed(compressor_->table_.DynamicIndex(
624  compressor_->grpc_accept_encoding_index_));
625  return;
626  }
628  auto encoded_value = GrpcAcceptEncodingMetadata::Encode(value);
629  uint32_t transport_length =
630  key.length() + encoded_value.length() + hpack_constants::kEntryOverhead;
631  compressor_->grpc_accept_encoding_index_ =
632  compressor_->table_.AllocateIndex(transport_length);
633  compressor_->grpc_accept_encoding_ = value;
634  EmitLitHdrWithNonBinaryStringKeyIncIdx(std::move(key),
635  std::move(encoded_value));
636 }
637 
639  max_usable_size_ = max_table_size;
640  SetMaxTableSize(std::min(table_.max_size(), max_table_size));
641 }
642 
644  if (table_.SetMaxSize(std::min(max_usable_size_, max_table_size))) {
647  gpr_log(GPR_INFO, "set max table size from encoder to %d",
648  max_table_size);
649  }
650  }
651 }
652 
654  HPackCompressor* compressor,
656  : max_frame_size_(options.max_frame_size),
657  use_true_binary_metadata_(options.use_true_binary_metadata),
658  is_end_of_stream_(options.is_end_of_stream),
659  stream_id_(options.stream_id),
660  output_(output),
661  stats_(options.stats),
662  compressor_(compressor),
663  prefix_(BeginFrame()) {
666  }
667 }
668 
669 } // namespace grpc_core
grpc_core::HPackCompressor::Framer::FramePrefix::output_length_at_start_of_frame
size_t output_length_at_start_of_frame
Definition: hpack_encoder.h:132
grpc_is_refcounted_slice_binary_header
int grpc_is_refcounted_slice_binary_header(const grpc_slice &slice)
Definition: validate_metadata.h:42
GPR_INFO
#define GPR_INFO
Definition: include/grpc/impl/codegen/log.h:56
grpc_core::GrpcTimeoutMetadata
Definition: metadata_batch.h:59
regen-readme.it
it
Definition: regen-readme.py:15
grpc_core::GetWireValue
static WireValue GetWireValue(Slice value, bool true_binary_enabled, bool is_bin_hdr)
Definition: hpack_encoder.cc:179
log.h
grpc_chttp2_base64_encode_and_huffman_compress
grpc_slice grpc_chttp2_base64_encode_and_huffman_compress(const grpc_slice &input)
Definition: bin_encoder.cc:169
grpc_slice::refcount
struct grpc_slice_refcount * refcount
Definition: include/grpc/impl/codegen/slice.h:66
grpc_core::HttpPathMetadata::key
static absl::string_view key()
Definition: metadata_batch.h:264
GPR_DEBUG_ASSERT
#define GPR_DEBUG_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:103
GRPC_STATS_INC_HPACK_SEND_INDEXED
#define GRPC_STATS_INC_HPACK_SEND_INDEXED()
Definition: stats_data.h:332
grpc_core::GrpcTimeoutMetadata::key
static absl::string_view key()
Definition: metadata_batch.h:63
grpc_core::CompressionAlgorithmSet
Definition: compression_internal.h:52
slice.h
grpc_core::StringKey
Definition: hpack_encoder.cc:251
varint.h
grpc_core::StringKey::len_key_
VarintWriter< 1 > len_key_
Definition: hpack_encoder.cc:267
grpc_core::HttpMethodMetadata
Definition: metadata_batch.h:136
grpc_core
Definition: call_metric_recorder.h:31
grpc_core::Slice
Definition: src/core/lib/slice/slice.h:282
grpc_core::HttpPathMetadata
Definition: metadata_batch.h:262
GPR_LIKELY
#define GPR_LIKELY(x)
Definition: impl/codegen/port_platform.h:769
options
double_dict options[]
Definition: capstone_test.c:55
grpc_core::HPackCompressor::Framer::EnsureSpace
void EnsureSpace(size_t need_bytes)
Definition: hpack_encoder.cc:126
grpc_compression_algorithm
grpc_compression_algorithm
Definition: compression_types.h:60
grpc_core::slice_detail::StaticConstructors< Slice >::FromStaticString
static Slice FromStaticString(const char *s)
Definition: src/core/lib/slice/slice.h:201
grpc_core::StringKey::WritePrefix
void WritePrefix(uint8_t type, uint8_t *data)
Definition: hpack_encoder.cc:258
absl::string_view
Definition: abseil-cpp/absl/strings/string_view.h:167
grpc_core::Timestamp
Definition: src/core/lib/gprpp/time.h:62
grpc_core::HPackCompressor::Framer
Definition: hpack_encoder.h:83
grpc_core::HttpSchemeMetadata::ValueType
ValueType
Definition: metadata_batch.h:116
grpc_status_code
grpc_status_code
Definition: include/grpc/impl/codegen/status.h:28
grpc_core::DefinitelyInterned::IsBinary
static bool IsBinary(grpc_slice key)
Definition: hpack_encoder.cc:199
grpc_core::GrpcEncodingMetadata
Definition: metadata_batch.h:175
grpc_core::BinaryStringValue
Definition: hpack_encoder.cc:209
grpc_http_trace
grpc_core::TraceFlag grpc_http_trace(false, "http")
GRPC_CHTTP2_DATA_FLAG_END_HEADERS
#define GRPC_CHTTP2_DATA_FLAG_END_HEADERS
Definition: frame.h:39
status
absl::Status status
Definition: rls.cc:251
grpc_core::StringKey::prefix_length
size_t prefix_length() const
Definition: hpack_encoder.cc:256
grpc_core::HttpStatusMetadata
Definition: metadata_batch.h:320
google::protobuf::python::cdescriptor_pool::Add
static PyObject * Add(PyObject *self, PyObject *file_descriptor_proto)
Definition: bloaty/third_party/protobuf/python/google/protobuf/pyext/descriptor_pool.cc:621
grpc_core::GrpcAcceptEncodingMetadata
Definition: metadata_batch.h:187
grpc_core::HPackCompressor::kNumCachedGrpcStatusValues
static constexpr uint32_t kNumCachedGrpcStatusValues
Definition: hpack_encoder.h:176
grpc_is_binary_header_internal
int grpc_is_binary_header_internal(const grpc_slice &slice)
Definition: validate_metadata.cc:126
grpc_core::HPackCompressor::Framer::EmitLitHdrWithNonBinaryStringKeyNotIdx
void EmitLitHdrWithNonBinaryStringKeyNotIdx(Slice key_slice, Slice value_slice)
Definition: hpack_encoder.cc:318
grpc_core::StringKey::key_
Slice key_
Definition: hpack_encoder.cc:266
uint8_t
unsigned char uint8_t
Definition: stdint-msvc2008.h:78
iterator
const typedef MCPhysReg * iterator
Definition: MCRegisterInfo.h:27
grpc_core::TeMetadata
Definition: metadata_batch.h:71
grpc_core::BinaryStringValue::wire_value_
WireValue wire_value_
Definition: hpack_encoder.cc:231
GRPC_TRACE_FLAG_ENABLED
#define GRPC_TRACE_FLAG_ENABLED(f)
Definition: debug/trace.h:114
grpc_core::WireValue::data
Slice data
Definition: hpack_encoder.cc:173
grpc_core::HPackEncoderTable::max_size
uint32_t max_size() const
Definition: hpack_encoder_table.h:44
stats.h
grpc_core::Timeout::FromDuration
static Timeout FromDuration(Duration duration)
Definition: timeout_encoding.cc:47
GRPC_CHTTP2_FRAME_HEADER
#define GRPC_CHTTP2_FRAME_HEADER
Definition: frame.h:29
grpc_status._async.code
code
Definition: grpcio_status/grpc_status/_async.py:34
true
#define true
Definition: setup_once.h:324
max_frame_size_
size_t max_frame_size_
Definition: security_handshaker.cc:134
grpc_core::HPackCompressor::EncodeHeaderOptions
Definition: hpack_encoder.h:68
grpc_slice_buffer_tiny_add
GPRAPI uint8_t * grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len)
Definition: slice/slice_buffer.cc:134
grpc_core::Timeout
Definition: timeout_encoding.h:33
timeout_encoding.h
grpc_core::BinaryStringValue::len_val_
VarintWriter< 1 > len_val_
Definition: hpack_encoder.cc:232
uint32_t
unsigned int uint32_t
Definition: stdint-msvc2008.h:80
grpc_core::FillHeader
static void FillHeader(uint8_t *p, uint8_t type, uint32_t id, size_t len, uint8_t flags)
Definition: hpack_encoder.cc:53
grpc_core::HPackCompressor::Framer::EmitLitHdrWithBinaryStringKeyNotIdx
void EmitLitHdrWithBinaryStringKeyNotIdx(Slice key_slice, Slice value_slice)
Definition: hpack_encoder.cc:282
grpc_core::GrpcAcceptEncodingMetadata::Encode
static Slice Encode(ValueType x)
Definition: metadata_batch.h:196
grpc_core::HPackCompressor::SliceIndex::EmitTo
void EmitTo(absl::string_view key, const Slice &value, Framer *framer)
Definition: hpack_encoder.cc:335
grpc_core::WireValue::length
const size_t length
Definition: hpack_encoder.cc:176
absl::move
constexpr absl::remove_reference_t< T > && move(T &&t) noexcept
Definition: abseil-cpp/absl/utility/utility.h:221
GPR_ASSERT
#define GPR_ASSERT(x)
Definition: include/grpc/impl/codegen/log.h:94
grpc_core::HPackCompressor::Framer::Add
void Add(Slice slice)
Definition: hpack_encoder.cc:134
grpc_core::HPackCompressor
Definition: hpack_encoder.h:51
GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V
#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX_V()
Definition: stats_data.h:340
gmock_output_test.output
output
Definition: bloaty/third_party/googletest/googlemock/test/gmock_output_test.py:175
grpc_core::GrpcTagsBinMetadata
Definition: metadata_batch.h:250
grpc_core::UnsureIfInterned::IsBinary
static bool IsBinary(grpc_slice key)
Definition: hpack_encoder.cc:204
grpc_slice::grpc_slice_data::grpc_slice_inlined::length
uint8_t length
Definition: include/grpc/impl/codegen/slice.h:73
grpc_core::NonBinaryStringValue::len_val_
VarintWriter< 1 > len_val_
Definition: hpack_encoder.cc:248
grpc_core::HttpAuthorityMetadata
Definition: metadata_batch.h:256
slice
grpc_slice slice
Definition: src/core/lib/surface/server.cc:467
gpr_log
GPRAPI void gpr_log(const char *file, int line, gpr_log_severity severity, const char *format,...) GPR_PRINT_FORMAT_CHECK(4
grpc_core::HPackCompressor::Framer::AddTiny
uint8_t * AddTiny(size_t len)
Definition: hpack_encoder.cc:154
grpc_core::WireValue::huffman_prefix
const uint8_t huffman_prefix
Definition: hpack_encoder.cc:174
grpc_core::BinaryStringValue::BinaryStringValue
BinaryStringValue(Slice value, bool use_true_binary_metadata)
Definition: hpack_encoder.cc:211
grpc_core::GrpcAcceptEncodingMetadata::key
static absl::string_view key()
Definition: metadata_batch.h:189
gen_stats_data.stats
list stats
Definition: gen_stats_data.py:58
grpc_core::HttpMethodMetadata::ValueType
ValueType
Definition: metadata_batch.h:138
grpc_slice::grpc_slice_data::inlined
struct grpc_slice::grpc_slice_data::grpc_slice_inlined inlined
grpc_slice_buffer::length
size_t length
Definition: include/grpc/impl/codegen/slice.h:96
GRPC_SLICE_START_PTR
#define GRPC_SLICE_START_PTR(slice)
Definition: include/grpc/impl/codegen/slice.h:101
GRPC_CHTTP2_FRAME_CONTINUATION
#define GRPC_CHTTP2_FRAME_CONTINUATION
Definition: frame.h:30
slice_buffer.h
grpc_core::HPackCompressor::max_usable_size_
uint32_t max_usable_size_
Definition: hpack_encoder.h:180
std::swap
void swap(Json::Value &a, Json::Value &b)
Specialize std::swap() for Json::Value.
Definition: third_party/bloaty/third_party/protobuf/conformance/third_party/jsoncpp/json.h:1226
prefix_
std::string prefix_
Definition: bloaty/third_party/protobuf/src/google/protobuf/descriptor.cc:376
grpc_slice
Definition: include/grpc/impl/codegen/slice.h:65
grpc_core::NonBinaryStringValue::data
Slice data()
Definition: hpack_encoder.cc:244
grpc_core::hpack_constants::kEntryOverhead
static constexpr uint32_t kEntryOverhead
Definition: hpack_constants.h:25
grpc_core::HPackCompressor::Framer::BeginFrame
FramePrefix BeginFrame()
Definition: hpack_encoder.cc:115
grpc_core::UserAgentMetadata
Definition: metadata_batch.h:214
GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V
#define GRPC_STATS_INC_HPACK_SEND_LITHDR_INCIDX_V()
Definition: stats_data.h:336
grpc_core::VarintWriter::Write
void Write(uint8_t prefix, uint8_t *target) const
Definition: varint.h:56
key_
RlsLb::RequestKey key_
Definition: rls.cc:659
data
char data[kBufferLength]
Definition: abseil-cpp/absl/strings/internal/str_format/float_conversion.cc:1006
grpc_core::HttpAuthorityMetadata::key
static absl::string_view key()
Definition: metadata_batch.h:258
grpc_core::HPackEncoderTable::MaxEntrySize
static constexpr size_t MaxEntrySize()
Definition: hpack_encoder_table.h:35
GRPC_STATS_INC_HPACK_SEND_BINARY
#define GRPC_STATS_INC_HPACK_SEND_BINARY()
Definition: stats_data.h:350
GPR_ERROR
#define GPR_ERROR
Definition: include/grpc/impl/codegen/log.h:57
grpc_core::HPackCompressor::Framer::CurrentFrameSize
size_t CurrentFrameSize() const
Definition: hpack_encoder.cc:79
min
#define min(a, b)
Definition: qsort.h:83
grpc_core::HPackCompressor::Framer::FramePrefix
Definition: hpack_encoder.h:127
grpc_core::HPackCompressor::SetMaxTableSize
void SetMaxTableSize(uint32_t max_table_size)
Definition: hpack_encoder.cc:643
grpc_core::HPackCompressor::Framer::prefix_
FramePrefix prefix_
Definition: hpack_encoder.h:171
grpc_core::GrpcStatusMetadata
Definition: metadata_batch.h:293
GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64
#define GRPC_STATS_INC_HPACK_SEND_BINARY_BASE64()
Definition: stats_data.h:352
grpc_core::HPackCompressor::Framer::EncodeIndexedKeyWithBinaryValue
void EncodeIndexedKeyWithBinaryValue(uint32_t *index, absl::string_view key, Slice value)
Definition: hpack_encoder.cc:511
grpc_core::StringKey::StringKey
StringKey(Slice key)
Definition: hpack_encoder.cc:253
grpc_core::HPackCompressor::PreviousTimeout
Definition: hpack_encoder.h:200
frame.h
grpc_core::NonBinaryStringValue::WritePrefix
void WritePrefix(uint8_t *prefix_data)
Definition: hpack_encoder.cc:242
emit
nibblelut emit
Definition: gen_hpack_tables.cc:88
grpc_core::HPackEncoderTable::SetMaxSize
bool SetMaxSize(uint32_t max_table_size)
Definition: hpack_encoder_table.cc:52
grpc_core::NonBinaryStringValue::prefix_length
size_t prefix_length() const
Definition: hpack_encoder.cc:240
value_
int value_
Definition: orphanable_test.cc:38
grpc_core::slice_detail::CopyConstructors< Slice >::FromInt64
static Slice FromInt64(int64_t i)
Definition: src/core/lib/slice/slice.h:192
grpc_core::HPackCompressor::Framer::EmitLitHdrWithNonBinaryStringKeyIncIdx
void EmitLitHdrWithNonBinaryStringKeyIncIdx(Slice key_slice, Slice value_slice)
Definition: hpack_encoder.cc:270
value
const char * value
Definition: hpack_parser_table.cc:165
grpc_core::slice_detail::BaseSlice::length
size_t length() const
Definition: src/core/lib/slice/slice.h:103
grpc_core::StringKey::key
Slice key()
Definition: hpack_encoder.cc:263
output_
std::string output_
Definition: json_writer.cc:76
absl::Now
ABSL_NAMESPACE_BEGIN Time Now()
Definition: abseil-cpp/absl/time/clock.cc:39
grpc_slice_buffer_add
GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice)
Definition: slice/slice_buffer.cc:170
grpc_core::WireValue
Definition: hpack_encoder.cc:166
grpc_core::HPackCompressor::Framer::FinishFrame
void FinishFrame(bool is_header_boundary)
Definition: hpack_encoder.cc:87
grpc_core::ContentTypeMetadata::ValueType
ValueType
Definition: metadata_batch.h:97
grpc_core::HPackCompressor::SetMaxUsableSize
void SetMaxUsableSize(uint32_t max_table_size)
Definition: hpack_encoder.cc:638
key
const char * key
Definition: hpack_parser_table.cc:164
GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED
#define GRPC_STATS_INC_HPACK_SEND_UNCOMPRESSED()
Definition: stats_data.h:346
grpc_core::BinaryStringValue::prefix_length
size_t prefix_length() const
Definition: hpack_encoder.cc:216
absl::flags_internal
Definition: abseil-cpp/absl/flags/commandlineflag.h:40
grpc_core::HttpSchemeMetadata
Definition: metadata_batch.h:114
GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX
#define GRPC_STATS_INC_HPACK_SEND_LITHDR_NOTIDX()
Definition: stats_data.h:338
grpc_core::VarintWriter::length
uint32_t length() const
Definition: varint.h:54
GRPC_CHTTP2_DATA_FLAG_END_STREAM
#define GRPC_CHTTP2_DATA_FLAG_END_STREAM
Definition: frame.h:37
validate_metadata.h
grpc_core::NonBinaryStringValue
Definition: hpack_encoder.cc:235
index
int index
Definition: bloaty/third_party/protobuf/php/ext/google/protobuf/protobuf.h:1184
grpc_core::HPackCompressor::Framer::max_frame_size_
const size_t max_frame_size_
Definition: hpack_encoder.h:162
grpc_core::VarintWriter< 1 >
hpack_constants.h
std
Definition: grpcpp/impl/codegen/async_unary_call.h:407
GRPC_COMPRESS_ALGORITHMS_COUNT
@ GRPC_COMPRESS_ALGORITHMS_COUNT
Definition: compression_types.h:65
grpc_slice::data
union grpc_slice::grpc_slice_data data
grpc_core::GrpcEncodingMetadata::key
static absl::string_view key()
Definition: metadata_batch.h:177
hpack_encoder.h
exec_ctx.h
grpc_core::GrpcStatusMetadata::key
static absl::string_view key()
Definition: metadata_batch.h:296
grpc_core::HPackCompressor::Framer::EncodeAlwaysIndexed
void EncodeAlwaysIndexed(uint32_t *index, absl::string_view key, Slice value, uint32_t transport_length)
Definition: hpack_encoder.cc:498
grpc_core::WireValue::WireValue
WireValue(uint8_t huffman_prefix, bool insert_null_before_wire_value, Slice slice)
Definition: hpack_encoder.cc:167
grpc_core::CompressionAlgorithmBasedMetadata::Encode
static Slice Encode(ValueType x)
Definition: metadata_batch.h:161
grpc_core::WireValue::insert_null_before_wire_value
const bool insert_null_before_wire_value
Definition: hpack_encoder.cc:175
hpack_encoder_table.h
grpc_core::NonBinaryStringValue::NonBinaryStringValue
NonBinaryStringValue(Slice value)
Definition: hpack_encoder.cc:237
grpc_core::DefinitelyInterned
Definition: hpack_encoder.cc:198
table
uint8_t table[256]
Definition: hpack_parser.cc:456
grpc_core::ContentTypeMetadata
Definition: metadata_batch.h:92
flags
uint32_t flags
Definition: retry_filter.cc:632
grpc_slice_buffer
Definition: include/grpc/impl/codegen/slice.h:83
grpc_core::UserAgentMetadata::key
static absl::string_view key()
Definition: metadata_batch.h:216
asyncio_get_stats.type
type
Definition: asyncio_get_stats.py:37
code
Definition: bloaty/third_party/zlib/contrib/infback9/inftree9.h:24
len
int len
Definition: abseil-cpp/absl/base/internal/low_level_alloc_test.cc:46
grpc_core::HPackCompressor::Framer::output_
grpc_slice_buffer *const output_
Definition: hpack_encoder.h:168
length
std::size_t length
Definition: abseil-cpp/absl/time/internal/test_util.cc:57
grpc_core::HPackCompressor::Framer::AdvertiseTableSizeChange
void AdvertiseTableSizeChange()
Definition: hpack_encoder.cc:330
method
NSString * method
Definition: ProtoMethod.h:28
grpc_core::NonBinaryStringValue::value_
Slice value_
Definition: hpack_encoder.cc:247
grpc_core::HPackCompressor::Framer::compressor_
HPackCompressor *const compressor_
Definition: hpack_encoder.h:170
grpc_core::HPackCompressor::advertise_table_size_change_
bool advertise_table_size_change_
Definition: hpack_encoder.h:183
grpc_core::BinaryStringValue::data
Slice data()
Definition: hpack_encoder.cc:228
grpc_core::UnsureIfInterned
Definition: hpack_encoder.cc:203
grpc_core::TeMetadata::ValueType
ValueType
Definition: metadata_batch.h:76
grpc_core::GrpcTraceBinMetadata
Definition: metadata_batch.h:244
grpc_core::HPackCompressor::Framer::Framer
Framer(const EncodeHeaderOptions &options, HPackCompressor *compressor, grpc_slice_buffer *output)
Definition: hpack_encoder.cc:653
bin_encoder.h
grpc_core::HPackCompressor::table_
HPackEncoderTable table_
Definition: hpack_encoder.h:184
timeout
uv_timer_t timeout
Definition: libuv/docs/code/uvwget/main.c:9
absl::EndsWith
bool EndsWith(absl::string_view text, absl::string_view suffix) noexcept
Definition: third_party/abseil-cpp/absl/strings/match.h:68
grpc_core::ExecCtx::Get
static ExecCtx * Get()
Definition: exec_ctx.h:205
absl::exchange
T exchange(T &obj, U &&new_value)
Definition: abseil-cpp/absl/utility/utility.h:314
grpc_slice_buffer_add_indexed
GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice slice)
Definition: slice/slice_buffer.cc:161
grpc_core::BinaryStringValue::WritePrefix
void WritePrefix(uint8_t *prefix_data)
Definition: hpack_encoder.cc:221
id
uint32_t id
Definition: flow_control_fuzzer.cc:70
grpc_core::HPackCompressor::Framer::EmitLitHdrWithBinaryStringKeyIncIdx
void EmitLitHdrWithBinaryStringKeyIncIdx(Slice key_slice, Slice value_slice)
Definition: hpack_encoder.cc:294
grpc_core::HPackCompressor::Framer::EmitIndexed
void EmitIndexed(uint32_t index)
Definition: hpack_encoder.cc:160
port_platform.h
grpc_core::HPackCompressor::Framer::Encode
void Encode(const Slice &key, const Slice &value)
Definition: hpack_encoder.cc:381


grpc
Author(s):
autogenerated on Thu Mar 13 2025 03:00:13