proxygen
proxygen::HTTPCommonHeaders Class Reference

#include <HTTPCommonHeaders.h>

Static Public Member Functions

static FB_EXPORT HTTPHeaderCode hash (const char *name, size_t len)
 
static FB_EXPORT HTTPHeaderCode hash (const std::string &name)
 
static FB_EXPORT std::stringinitHeaderNames (HTTPCommonHeaderTableType type)
 
static const std::stringgetPointerToCommonHeaderTable (HTTPCommonHeaderTableType type)
 
static const std::stringgetPointerToHeaderName (HTTPHeaderCode code, HTTPCommonHeaderTableType type=TABLE_CAMELCASE)
 
static bool isHeaderNameFromTable (const std::string *headerName, HTTPCommonHeaderTableType type)
 
static HTTPHeaderCode getHeaderCodeFromTableCommonHeaderName (const std::string *headerName, HTTPCommonHeaderTableType type)
 
static FB_EXPORT HTTPHeaderCode hash (const char *name, size_t len)
 
static FB_EXPORT HTTPHeaderCode hash (const std::string &name)
 
static FB_EXPORT std::stringinitHeaderNames (HTTPCommonHeaderTableType type)
 
static const std::stringgetPointerToCommonHeaderTable (HTTPCommonHeaderTableType type)
 
static const std::stringgetPointerToHeaderName (HTTPHeaderCode code, HTTPCommonHeaderTableType type=TABLE_CAMELCASE)
 
static bool isHeaderNameFromTable (const std::string *headerName, HTTPCommonHeaderTableType type)
 
static HTTPHeaderCode getHeaderCodeFromTableCommonHeaderName (const std::string *headerName, HTTPCommonHeaderTableType type)
 

Static Public Attributes

static constexpr uint64_t num_header_codes = 94
 

Detailed Description

Definition at line 142 of file HTTPCommonHeaders.h.

Member Function Documentation

static HTTPHeaderCode proxygen::HTTPCommonHeaders::getHeaderCodeFromTableCommonHeaderName ( const std::string headerName,
HTTPCommonHeaderTableType  type 
)
inlinestatic

Definition at line 81 of file HTTPCommonHeaders.template.h.

References diff(), getPointerToCommonHeaderTable(), proxygen::HTTP_HEADER_NONE, proxygen::HTTP_HEADER_OTHER, and num_header_codes.

82  {
83  if (headerName == nullptr) {
84  return HTTP_HEADER_NONE;
85  } else {
86  auto diff = headerName - getPointerToCommonHeaderTable(type);
88  return static_cast<HTTPHeaderCode>(diff);
89  } else {
90  return HTTP_HEADER_OTHER;
91  }
92  }
93  }
PskType type
uint64_t diff(uint64_t a, uint64_t b)
Definition: FutexTest.cpp:135
static constexpr uint64_t num_header_codes
static const std::string * getPointerToCommonHeaderTable(HTTPCommonHeaderTableType type)
const uint8_t HTTPHeaderCodeCommonOffset
static HTTPHeaderCode proxygen::HTTPCommonHeaders::getHeaderCodeFromTableCommonHeaderName ( const std::string headerName,
HTTPCommonHeaderTableType  type 
)
inlinestatic

Definition at line 172 of file HTTPCommonHeaders.h.

References diff(), getPointerToCommonHeaderTable(), proxygen::HTTP_HEADER_NONE, and proxygen::HTTP_HEADER_OTHER.

Referenced by proxygen::HPACKHeaderName::getHeaderCode(), isHeaderNameFromTable(), and TEST_F().

173  {
174  if (headerName == nullptr) {
175  return HTTP_HEADER_NONE;
176  } else {
177  auto diff = headerName - getPointerToCommonHeaderTable(type);
179  return static_cast<HTTPHeaderCode>(diff);
180  } else {
181  return HTTP_HEADER_OTHER;
182  }
183  }
184  }
PskType type
uint64_t diff(uint64_t a, uint64_t b)
Definition: FutexTest.cpp:135
static constexpr uint64_t num_header_codes
static const std::string * getPointerToCommonHeaderTable(HTTPCommonHeaderTableType type)
const uint8_t HTTPHeaderCodeCommonOffset
static const std::string* proxygen::HTTPCommonHeaders::getPointerToCommonHeaderTable ( HTTPCommonHeaderTableType  type)
static
const std::string * proxygen::HTTPCommonHeaders::getPointerToCommonHeaderTable ( HTTPCommonHeaderTableType  type)
static

Definition at line 369 of file HTTPCommonHeaders.cpp.

References string, proxygen::TABLE_CAMELCASE, and proxygen::TABLE_LOWERCASE.

Referenced by getHeaderCodeFromTableCommonHeaderName(), getPointerToHeaderName(), and hash().

370  {
371  // The actual common header tables are static and initialized here in source
372  // so as to prevent duplicate initializations that could occur through the
373  // use of inline semantics or compilation unit referencing if defined in a
374  // header
375  switch(type) {
376  case TABLE_CAMELCASE:
377  static const std::string* camelcaseTable = initHeaderNames(type);
378  return camelcaseTable;
379  case TABLE_LOWERCASE:
380  static const std::string* lowercaseTable = initHeaderNames(type);
381  return lowercaseTable;
382  default:
383  // Controlled abort here so its clear from a crash stack this method
384  // was called with a table type for which there is no current
385  // implementation
386  CHECK(false);
387  return nullptr;
388  }
389 }
static FB_EXPORT std::string * initHeaderNames(HTTPCommonHeaderTableType type)
PskType type
const char * string
Definition: Conv.cpp:212
static const std::string* proxygen::HTTPCommonHeaders::getPointerToHeaderName ( HTTPHeaderCode  code,
HTTPCommonHeaderTableType  type = TABLE_CAMELCASE 
)
inlinestatic

Definition at line 66 of file HTTPCommonHeaders.template.h.

References getPointerToCommonHeaderTable().

67  {
68  return getPointerToCommonHeaderTable(type) + code;
69  }
PskType type
static const std::string * getPointerToCommonHeaderTable(HTTPCommonHeaderTableType type)
static const std::string* proxygen::HTTPCommonHeaders::getPointerToHeaderName ( HTTPHeaderCode  code,
HTTPCommonHeaderTableType  type = TABLE_CAMELCASE 
)
inlinestatic

Definition at line 157 of file HTTPCommonHeaders.h.

References getPointerToCommonHeaderTable().

Referenced by proxygen::HTTPHeaders::add(), proxygen::HTTPHeaders::addFromCodec(), proxygen::HPACKHeaderName::storeAddress(), and TEST_F().

158  {
159  return getPointerToCommonHeaderTable(type) + code;
160  }
PskType type
static const std::string * getPointerToCommonHeaderTable(HTTPCommonHeaderTableType type)
static FB_EXPORT HTTPHeaderCode proxygen::HTTPCommonHeaders::hash ( const char *  name,
size_t  len 
)
static
static FB_EXPORT HTTPHeaderCode proxygen::HTTPCommonHeaders::hash ( const std::string name)
inlinestatic

Definition at line 56 of file HTTPCommonHeaders.template.h.

References FB_EXPORT, getPointerToCommonHeaderTable(), hash(), initHeaderNames(), string, and type.

56  {
57  return hash(name.data(), name.length());
58  }
const char * name
Definition: http_parser.c:437
static FB_EXPORT HTTPHeaderCode hash(const char *name, size_t len)
HTTPHeaderCode proxygen::HTTPCommonHeaders::hash ( const char *  name,
size_t  len 
)
static
static FB_EXPORT HTTPHeaderCode proxygen::HTTPCommonHeaders::hash ( const std::string name)
inlinestatic

Definition at line 147 of file HTTPCommonHeaders.h.

References FB_EXPORT, hash(), initHeaderNames(), string, and type.

147  {
148  return hash(name.data(), name.length());
149  }
const char * name
Definition: http_parser.c:437
static FB_EXPORT HTTPHeaderCode hash(const char *name, size_t len)
static FB_EXPORT std::string* proxygen::HTTPCommonHeaders::initHeaderNames ( HTTPCommonHeaderTableType  type)
static
std::string * proxygen::HTTPCommonHeaders::initHeaderNames ( HTTPCommonHeaderTableType  type)
static

Definition at line 349 of file HTTPCommonHeaders.cpp.

References proxygen::HTTPCommonHeaderName::code, data, proxygen::MAX_HASH_VALUE, proxygen::MIN_HASH_VALUE, proxygen::HTTPCommonHeaderName::name, num_header_codes, folly::size(), string, proxygen::TABLE_LOWERCASE, folly::toLowerAscii(), proxygen::TOTAL_KEYWORDS, and uint8_t.

Referenced by hash().

350  {
351  auto headerNames = new std::string[HTTPCommonHeaders::num_header_codes];
352  for (int j = MIN_HASH_VALUE; j <= MAX_HASH_VALUE; ++j) {
353  uint8_t code = wordlist[j].code;
354  const uint8_t OFFSET = 2; // first 2 values are reserved for special cases
355  if (code >= OFFSET && code < TOTAL_KEYWORDS + OFFSET
356  && wordlist[j].name[0] != '\0') {
357  DCHECK_EQ(headerNames[code], std::string());
358  // this would mean a duplicate header code in the .gperf file
359  headerNames[code] = wordlist[j].name;
360  if (type == TABLE_LOWERCASE) {
361  folly::toLowerAscii(const_cast<char*>(headerNames[code].data()),
362  headerNames[code].size());
363  }
364  }
365  }
366  return headerNames;
367 }
PskType type
const char * name
Definition: http_parser.c:437
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
static const struct HTTPCommonHeaderName wordlist[]
void toLowerAscii(char *str, size_t length)
Definition: String.cpp:601
static constexpr uint64_t num_header_codes
const char * string
Definition: Conv.cpp:212
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
static bool proxygen::HTTPCommonHeaders::isHeaderNameFromTable ( const std::string headerName,
HTTPCommonHeaderTableType  type 
)
inlinestatic

Definition at line 71 of file HTTPCommonHeaders.template.h.

References getHeaderCodeFromTableCommonHeaderName(), and proxygen::HTTPHeaderCodeCommonOffset.

72  {
73  return getHeaderCodeFromTableCommonHeaderName(headerName, type) >=
75  }
PskType type
static HTTPHeaderCode getHeaderCodeFromTableCommonHeaderName(const std::string *headerName, HTTPCommonHeaderTableType type)
const uint8_t HTTPHeaderCodeCommonOffset
static bool proxygen::HTTPCommonHeaders::isHeaderNameFromTable ( const std::string headerName,
HTTPCommonHeaderTableType  type 
)
inlinestatic

Definition at line 162 of file HTTPCommonHeaders.h.

References getHeaderCodeFromTableCommonHeaderName(), and proxygen::HTTPHeaderCodeCommonOffset.

Referenced by proxygen::HPACKHeaderName::isAllocated(), proxygen::HPACKHeaderName::isCommonHeader(), and TEST_F().

163  {
164  return getHeaderCodeFromTableCommonHeaderName(headerName, type) >=
166  }
PskType type
static HTTPHeaderCode getHeaderCodeFromTableCommonHeaderName(const std::string *headerName, HTTPCommonHeaderTableType type)
const uint8_t HTTPHeaderCodeCommonOffset

Member Data Documentation

constexpr uint64_t proxygen::HTTPCommonHeaders::num_header_codes = 94
static

The documentation for this class was generated from the following files: