proxygen
proxygen::compress Namespace Reference

Classes

class  CompressionScheme
 
class  CompressionSimulator
 
struct  FrameFlags
 
struct  Header
 
class  HeaderPiece
 
class  HPACKScheme
 
class  QMINScheme
 
class  QPACKScheme
 
struct  SimParams
 
struct  SimStats
 
class  SimStreamingCallback
 

Typedefs

using HeaderPieceList = std::deque< HeaderPiece >
 

Enumerations

enum  SchemeType { SchemeType::QPACK, SchemeType::QMIN, SchemeType::HPACK }
 

Functions

std::vector< compress::HeaderprepareMessageForCompression (const HTTPMessage &msg, std::vector< string > &cookies)
 
std::pair< vector< HPACKHeader >, uint32_tprepareHeaders (vector< Header > &headers)
 

Typedef Documentation

using proxygen::compress::HeaderPieceList = typedef std::deque<HeaderPiece>

Definition at line 59 of file HeaderPiece.h.

Enumeration Type Documentation

Function Documentation

std::pair< std::vector< HPACKHeader >, uint32_t > proxygen::compress::prepareHeaders ( vector< Header > &  headers)

Definition at line 29 of file HPACKCodec.cpp.

References h, and uint32_t.

Referenced by proxygen::QPACKCodec::encode(), and proxygen::HPACKCodec::encode().

30  {
31  // convert to HPACK API format
32  std::pair<vector<HPACKHeader>, uint32_t> converted;
33  converted.first.reserve(headers.size());
34  for (const auto& h : headers) {
35  // HPACKHeader automatically lowercases
36  converted.first.emplace_back(*h.name, *h.value);
37  auto& header = converted.first.back();
38  converted.second += header.name.size() + header.value.size() + 2;
39  }
40  return converted;
41 }
*than *hazptr_holder h
Definition: Hazptr.h:116
std::vector< Header > proxygen::compress::prepareMessageForCompression ( const HTTPMessage msg,
std::vector< string > &  cookies 
)

Definition at line 83 of file CompressionUtils.cpp.

References proxygen::CONNECT, cookie, proxygen::HTTPHeaders::forEachWithCode(), proxygen::HTTPMessage::getHeaders(), proxygen::HTTPMessage::getMethod(), proxygen::HTTPMessage::getMethodString(), proxygen::HTTPHeaders::getSingleOrEmpty(), proxygen::HTTPMessage::getURL(), proxygen::HTTP_HEADER_COLON_AUTHORITY, proxygen::HTTP_HEADER_COLON_METHOD, proxygen::HTTP_HEADER_COLON_PATH, proxygen::HTTP_HEADER_COLON_SCHEME, proxygen::HTTP_HEADER_COOKIE, proxygen::HTTP_HEADER_HOST, proxygen::HTTPMessage::isSecure(), proxygen::headers::kAuthority, proxygen::headers::kHttp, proxygen::headers::kHttps, proxygen::headers::kMethod, proxygen::headers::kPath, proxygen::headers::kScheme, folly::ltrimWhitespace(), folly::split(), and value.

Referenced by proxygen::compress::CompressionSimulator::encode().

85  {
86  std::vector<compress::Header> allHeaders;
87  // The encode API is pretty bad. We should just let HPACK directly encode
88  // HTTP messages
89  const HTTPHeaders& headers = msg.getHeaders();
90  const string& host = headers.getSingleOrEmpty(HTTP_HEADER_HOST);
91  bool isPublic = msg.getMethodString().empty();
92  if (!isPublic) {
93  allHeaders.emplace_back(HTTP_HEADER_COLON_METHOD, headers::kMethod,
94  msg.getMethodString());
95  if (msg.getMethod() != HTTPMethod::CONNECT) {
96  allHeaders.emplace_back(
99  allHeaders.emplace_back(HTTP_HEADER_COLON_PATH, headers::kPath,
100  msg.getURL());
101  }
102 
103  if (!host.empty()) {
104  allHeaders.emplace_back(
106  }
107  }
108  // Cookies are coalesced in the HAR file but need to be added as separate
109  // headers to optimize compression ratio
110  headers.forEachWithCode(
111  [&](HTTPHeaderCode code, const string& name, const string& value) {
112  if (code == HTTP_HEADER_COOKIE) {
113  vector<folly::StringPiece> cookiePieces;
114  folly::split(';', value, cookiePieces);
115  cookies.reserve(cookies.size() + cookiePieces.size());
116  for (auto cookie : cookiePieces) {
117  cookies.push_back(ltrimWhitespace(cookie).str());
118  allHeaders.emplace_back(code, name, cookies.back());
119  }
120  } else if (code != HTTP_HEADER_HOST && (isPublic || name[0] != ':')) {
121  // HAR files contain actual serialized headers protocol headers like
122  // :authority, which we are re-adding above. Strip them so our
123  // equality test works
124  allHeaders.emplace_back(code, name, value);
125  }
126  });
127  return allHeaders;
128 }
StringPiece ltrimWhitespace(StringPiece sp)
Definition: String.cpp:131
StringPiece cookie
void split(const Delim &delimiter, const String &input, std::vector< OutputType > &out, bool ignoreEmpty)
Definition: String-inl.h:382
const std::string kScheme
const char * name
Definition: http_parser.c:437
static const char *const value
Definition: Conv.cpp:50
HTTPHeaders & getHeaders()
Definition: HTTPMessage.h:273
const std::string & getSingleOrEmpty(const T &nameOrCode) const
Definition: HTTPHeaders.h:420
const std::string kHttp
const std::string kPath
const std::string & getMethodString() const
bool isSecure() const
Definition: HTTPMessage.h:535
const std::string kAuthority
folly::Optional< HTTPMethod > getMethod() const
const std::string & getURL() const
Definition: HTTPMessage.h:205
void forEachWithCode(LAMBDA func) const
Definition: HTTPHeaders.h:346
const std::string kMethod
const std::string kHttps