Esempio n. 1
0
void HPACKEncoder::encodeAsLiteral(const HPACKHeader& header) {
  bool indexing = header.isIndexable();
  uint8_t prefix = indexing ?
    HPACK::HeaderEncoding::LITERAL_INCR_INDEXING :
    HPACK::HeaderEncoding::LITERAL_NO_INDEXING;
  // name
  uint32_t index = nameIndex(header.name);
  if (index) {
    buffer_.encodeInteger(index, prefix, 6);
  } else {
    buffer_.encodeInteger(0, prefix, 6);
    buffer_.encodeLiteral(header.name);
  }
  // value
  buffer_.encodeLiteral(header.value);
  // indexed ones need to get added to the header table
  if (indexing) {
    if (table_.add(header)) {
      table_.addReference(1);
    }
  }
}
Esempio n. 2
0
bool HPACKEncoder::willBeAdded(const HPACKHeader& header) {
  auto index = getIndex(header);
  return isStatic(index) || (index == 0 && header.isIndexable());
}