13 #include <boost/variant.hpp> 18 #include <glog/logging.h> 95 if (ipStr.empty() || portStr.empty()) {
123 if (addressStr.empty() || portStr.empty()) {
147 template <
typename T>
182 template <
typename T>
184 VLOG(9) <<
"setURL: " << url;
189 VLOG(9) <<
"set path: " << u.
path() <<
" query:" << u.
query();
194 VLOG(4) <<
"Error in parsing URL: " << url;
241 template <
typename T>
260 if (ver.size() != 3 ||
402 int contentLength = 0);
414 int contentLength = 0);
509 void describe(std::ostream& os)
const;
577 if (pri > kMaxPriority || pri < -kMaxPriority) {
580 }
else if (pri < 0) {
581 return pri + kMaxPriority + 1;
632 bool caseSensitive)
const;
704 const std::map<std::string, std::string>&
params,
uint32_t maxSize);
721 bool caseSensitive)
const;
737 mutable boost::variant<boost::blank, std::string, HTTPMethod>
method_;
759 mutable boost::variant<boost::blank, Request, Response>
fields_;
762 DCHECK(fields_.which() == 0 || fields_.which() == 1) << fields_.which();
763 if (fields_.which() == 0) {
767 return boost::get<Request>(
fields_);
771 DCHECK(fields_.which() == 0 || fields_.which() == 1) << fields_.which();
772 if (fields_.which() == 0) {
776 return boost::get<const Request>(
fields_);
780 DCHECK(fields_.which() == 0 || fields_.which() == 2) << fields_.which();
781 if (fields_.which() == 0) {
785 return boost::get<Response>(
fields_);
789 DCHECK(fields_.which() == 0 || fields_.which() == 2) << fields_.which();
790 if (fields_.which() == 0) {
794 return boost::get<const Response>(
fields_);
802 mutable std::map<folly::StringPiece, folly::StringPiece>
cookies_;
841 template<
typename Str>
844 res.reserve(str.length());
845 for (
size_t i = 0;
i < str.size(); ++
i) {
846 if (!(str[
i] <= 0x1F || str[
i] == 0x7F)) {
void setIngressHeaderSize(const HTTPHeaderSize &size)
static void splitNameValuePieces(const std::string &input, char pairDelim, char valueDelim, std::function< void(folly::StringPiece, folly::StringPiece)> callback)
HTTPHeaders strippedPerHopHeaders_
folly::SocketAddress clientAddress_
std::unique_ptr< HTTPHeaders > trailers_
std::string stripCntrlChars(const Str &str)
const std::string & getLocalIp() const
spdy::GoawayStatusCode statusCode
folly::StringPiece query() const
void atomicDumpMessage(int verbosity) const
void setWantsKeepalive(bool wantsKeepaliveVal)
void setTrailers(std::unique_ptr< HTTPHeaders > &&trailers)
static const std::pair< uint8_t, uint8_t > kHTTPVersion10
const std::string & getPath() const
const Response & response() const
std::ostream & operator<<(std::ostream &os, const HeaderTable &table)
const std::string * getUpgradeProtocol() const
std::unique_ptr< std::string > upgradeProtocol_
const std::string & getStatusMessage() const
static folly::StringPiece trim(folly::StringPiece sp)
static std::string createQueryString(const std::map< std::string, std::string > ¶ms, uint32_t maxSize)
const HTTPHeaders & getHeaders() const
void setIngressWebsocketUpgrade()
void setStatusMessage(T &&msg)
const folly::SocketAddress & getDstAddress() const
uint16_t getStatusCode() const
const folly::SocketAddress & getClientAddress() const
constexpr detail::Map< Move > move
const std::string * protoStr_
bool doHeaderTokenCheck(const HTTPHeaders &headers_, const HTTPHeaderCode headerCode, char const *token, bool caseSensitive) const
void setDstAddress(const folly::SocketAddress &addr, std::string addressStr=empty_string, std::string portStr=empty_string)
static std::string formatDateHeader()
bool is1xxResponse() const
void setVersionString(const std::string &ver)
const HTTPHeaders * getTrailers() const
const HTTPHeaderSize & getIngressHeaderSize() const
uint8_t getPriority() const
boost::variant< boost::blank, std::string, HTTPMethod > method_
requires E e noexcept(noexcept(s.error(std::move(e))))
bool is5xxResponse() const
const HTTPHeaders & getStrippedPerHopHeaders() const
void setAdvancedProtocolString(const std::string &protocol)
static void splitNameValue(const std::string &input, char pairDelim, char valueDelim, std::function< void(std::string &&, std::string &&)> callback)
void setPushStatusCode(const uint16_t status)
void constructDirectResponse(const std::pair< uint8_t, uint8_t > &version, const int statusCode, const std::string &statusMsg, int contentLength=0)
TimePoint getStartTime() const
int getSecureVersion() const
void dumpMessageToSink(google::LogSink *logSink) const
bool computeKeepalive() const
const std::string & getQueryString() const
void setIsChunked(bool chunked)
const Request & request() const
constexpr auto size(C const &c) -> decltype(c.size())
const folly::StringPiece getCookie(const std::string &name) const
const std::string & getQueryParam(const std::string &name) const
void setSeqNo(int32_t seqNo)
bool checkForHeaderToken(const HTTPHeaderCode headerCode, char const *token, bool caseSensitive) const
constexpr Params params[]
bool trailersAllowed() const
void setSecure(bool secure)
bool getIsChunked() const
void setHTTP2Priority(HTTPPriority h2Pri)
WebSocketUpgrade upgradeWebsocket_
folly::Optional< HTTPPriority > h2Pri_
void parseCookies() const
const std::string * getQueryParamPtr(const std::string &name) const
std::pair< uint8_t, uint8_t > version_
HTTPHeaders && extractHeaders()
std::map< folly::StringPiece, folly::StringPiece > cookies_
uint16_t getPushStatusCode() const
folly::StringPiece path() const
static const std::pair< uint8_t, uint8_t > kHTTPVersion11
std::string pushStatusStr_
const std::string & getClientIP() const
void rawSetMethod(const std::string &method)
void setStartTime(const TimePoint &startTime)
void setUpgradeProtocol(std::string protocol)
void setSecureInfo(int ver, const char *cipher)
folly::Optional< HTTPPriority > getHTTP2Priority() const
void stripPerHopHeaders()
const std::string * getAdvancedProtocolString() const
const char * getSecureCipher() const
int getIntQueryParam(const std::string &name) const
void setURL(const char *url)
static const char *const value
static const int8_t kMaxPriority
bool setQueryParam(const std::string &name, const std::string &value)
HTTPHeaders & getHeaders()
bool is4xxResponse() const
static std::string createUrl(const folly::StringPiece scheme, const folly::StringPiece authority, const folly::StringPiece path, const folly::StringPiece query, const folly::StringPiece fragment)
const std::string & getDstPort() const
void setIsUpgraded(bool upgraded)
void setPriority(int8_t pri)
const std::string & getPushStatusStr() const
bool setQueryString(const std::string &query)
void setMethod(HTTPMethod method)
boost::variant< boost::blank, Request, Response > fields_
std::string getDecodedQueryParam(const std::string &name) const
std::tuple< uint32_t, bool, uint8_t > HTTPPriority
SteadyClock::time_point TimePoint
void describe(std::ostream &os) const
const std::string empty_string
bool removeQueryParam(const std::string &name)
folly::SocketAddress dstAddress_
bool hasQueryParam(const std::string &name) const
const std::string & getClientPort() const
HTTPHeaders * getTrailers()
void parseQueryParams() const
const std::string & getMethodString() const
void setHTTPVersion(uint8_t major, uint8_t minor)
void setTrailersAllowed(bool trailersAllowedVal)
void rawSetStatusMessage(std::string msg)
std::map< std::string, std::string > queryParams_
bool isIngressWebsocketUpgrade() const
void rawSetURL(const std::string &url)
static const char * getDefaultReason(uint16_t status)
bool isAdvancedProto() const
folly::Optional< HTTPMethod > getMethod() const
void setEgressWebsocketUpgrade()
static uint8_t normalizePriority(int8_t pri)
const std::string & getProtocolString() const
const std::map< std::string, std::string > & getQueryParams() const
const std::string & getURL() const
static std::mutex mutexDump_
ThreadPoolListHook * addr
void dumpMessage(int verbosity) const
bool getIsUpgraded() const
const std::string & getVersionString() const
Chunked chunked(const Container &container, int chunkSize=256)
void unparseCookies() const
void setClientAddress(const folly::SocketAddress &addr, std::string ipStr=empty_string, std::string portStr=empty_string)
bool isEgressWebsocketUpgrade() const
const std::string & getDstIP() const
std::string getAddressStr() const
bool wantsKeepalive() const
const std::pair< uint8_t, uint8_t > & getHTTPVersion() const
void unparseQueryParams()
void setStatusCode(uint16_t status)