proxygen
|
#include <HTTPMessage.h>
Classes | |
struct | Request |
struct | Response |
Public Types | |
enum | WebSocketUpgrade { NONE, INGRESS, EGRESS } |
using | HTTPPriority = std::tuple< uint32_t, bool, uint8_t > |
Static Public Member Functions | |
static std::string | formatDateHeader () |
static uint8_t | normalizePriority (int8_t pri) |
static const char * | getDefaultReason (uint16_t status) |
static void | splitNameValuePieces (const std::string &input, char pairDelim, char valueDelim, std::function< void(folly::StringPiece, folly::StringPiece)> callback) |
static void | splitNameValue (const std::string &input, char pairDelim, char valueDelim, std::function< void(std::string &&, std::string &&)> callback) |
static std::string | createUrl (const folly::StringPiece scheme, const folly::StringPiece authority, const folly::StringPiece path, const folly::StringPiece query, const folly::StringPiece fragment) |
static std::string | createQueryString (const std::map< std::string, std::string > ¶ms, uint32_t maxSize) |
Static Public Attributes | |
static const std::pair< uint8_t, uint8_t > | kHTTPVersion10 |
static const std::pair< uint8_t, uint8_t > | kHTTPVersion11 |
static const int8_t | kMaxPriority = 7 |
Protected Attributes | |
TimePoint | startTime_ |
int32_t | seqNo_ |
Private Member Functions | |
void | parseCookies () const |
void | parseQueryParams () const |
void | unparseQueryParams () |
bool | doHeaderTokenCheck (const HTTPHeaders &headers_, const HTTPHeaderCode headerCode, char const *token, bool caseSensitive) const |
Request & | request () |
const Request & | request () const |
Response & | response () |
const Response & | response () const |
Static Private Member Functions | |
static folly::StringPiece | trim (folly::StringPiece sp) |
Private Attributes | |
folly::SocketAddress | dstAddress_ |
std::string | dstIP_ |
std::string | dstPort_ |
std::string | localIP_ |
std::string | versionStr_ |
boost::variant< boost::blank, Request, Response > | fields_ |
std::map< folly::StringPiece, folly::StringPiece > | cookies_ |
std::map< std::string, std::string > | queryParams_ |
std::pair< uint8_t, uint8_t > | version_ |
HTTPHeaders | headers_ |
HTTPHeaders | strippedPerHopHeaders_ |
HTTPHeaderSize | size_ |
std::unique_ptr< HTTPHeaders > | trailers_ |
int | sslVersion_ |
const char * | sslCipher_ |
const std::string * | protoStr_ |
uint8_t | pri_ |
folly::Optional< HTTPPriority > | h2Pri_ |
bool | parsedCookies_:1 |
bool | parsedQueryParams_:1 |
bool | chunked_:1 |
bool | upgraded_:1 |
bool | wantsKeepalive_:1 |
bool | trailersAllowed_:1 |
bool | secure_:1 |
WebSocketUpgrade | upgradeWebsocket_ |
std::unique_ptr< std::string > | upgradeProtocol_ |
Static Private Attributes | |
static std::mutex | mutexDump_ |
An HTTP request or response minus the body.
Some of the methods on this class will assert if called from the wrong context since they only make sense for a request or response. Make sure you know what type of HTTPMessage this is before calling such methods.
All header names stored in this class are case-insensitive.
Definition at line 39 of file HTTPMessage.h.
using proxygen::HTTPMessage::HTTPPriority = std::tuple<uint32_t, bool, uint8_t> |
Definition at line 592 of file HTTPMessage.h.
Enumerator | |
---|---|
NONE | |
INGRESS | |
EGRESS |
Definition at line 42 of file HTTPMessage.h.
proxygen::HTTPMessage::HTTPMessage | ( | ) |
Definition at line 63 of file HTTPMessage.cpp.
proxygen::HTTPMessage::~HTTPMessage | ( | ) |
Definition at line 77 of file HTTPMessage.cpp.
|
noexcept |
Definition at line 112 of file HTTPMessage.cpp.
proxygen::HTTPMessage::HTTPMessage | ( | const HTTPMessage & | message | ) |
Definition at line 80 of file HTTPMessage.cpp.
References trailers_.
void proxygen::HTTPMessage::atomicDumpMessage | ( | int | verbosity | ) | const |
Print the message out, serializes through mutex Used in shutdown path
Definition at line 731 of file HTTPMessage.cpp.
References dumpMessage(), g(), and mutexDump_.
Referenced by getUpgradeProtocol().
bool proxygen::HTTPMessage::checkForHeaderToken | ( | const HTTPHeaderCode | headerCode, |
char const * | token, | ||
bool | caseSensitive | ||
) | const |
Check if a particular token value is present in a header that consists of a list of comma separated tokens. (e.g., a header with a #rule body as specified in the RFC 2616 BNF notation.)
Definition at line 782 of file HTTPMessage.cpp.
References doHeaderTokenCheck(), and headers_.
Referenced by computeKeepalive(), ZlibServerFilterTest::exercise_compression(), proxygen::HTTP2Codec::requestUpgrade(), setStartTime(), stripPerHopHeaders(), TEST(), and TEST_F().
bool proxygen::HTTPMessage::computeKeepalive | ( | ) | const |
Computes whether the state of this message is compatible with keepalive. Changing the headers, version, etc can change the result.
Definition at line 740 of file HTTPMessage.cpp.
References checkForHeaderToken(), doHeaderTokenCheck(), proxygen::HTTP_HEADER_CONNECTION, kHTTPVersion10, string, strippedPerHopHeaders_, and version_.
Referenced by setStartTime(), and TEST().
void proxygen::HTTPMessage::constructDirectResponse | ( | const std::pair< uint8_t, uint8_t > & | version, |
const int | statusCode, | ||
const std::string & | statusMsg, | ||
int | contentLength = 0 |
||
) |
Fill in the fields for a response message header that the server will send directly to the client.
version | HTTP version (major, minor) |
statusCode | HTTP status code to respond with |
msg | textual message to embed in "message" status field |
contentLength | the length of the data to be written out through this message |
Definition at line 358 of file HTTPMessage.cpp.
References setStatusCode(), and setStatusMessage().
Referenced by getUpgradeProtocol().
void proxygen::HTTPMessage::constructDirectResponse | ( | const std::pair< uint8_t, uint8_t > & | version, |
int | contentLength = 0 |
||
) |
Fill in the fields for a response message header that the server will send directly to the client. This function assumes the status code and status message have already been set on this HTTPMessage object
version | HTTP version (major, minor) |
contentLength | the length of the data to be written out through this message |
Definition at line 368 of file HTTPMessage.cpp.
References proxygen::HTTPHeaders::add(), proxygen::HTTPHeaders::exists(), headers_, proxygen::HTTP_HEADER_CONTENT_LENGTH, proxygen::HTTP_HEADER_CONTENT_TYPE, proxygen::HTTPHeaders::set(), setHTTPVersion(), setIsChunked(), and setIsUpgraded().
|
static |
Create a query string from the query parameters map containing the name-value pairs.
Definition at line 547 of file HTTPMessage.cpp.
References string.
Referenced by isResponse(), removeQueryParam(), and setQueryParam().
|
static |
Form the URL from the individual components. url -> {scheme}://{authority}{path}?{query}#{fragment}
Definition at line 561 of file HTTPMessage.cpp.
References folly::Range< Iter >::empty(), folly::Range< Iter >::size(), folly::Range< Iter >::str(), string, and folly::toAppend().
Referenced by PushService::generateUrl(), isResponse(), and setQueryString().
void proxygen::HTTPMessage::describe | ( | std::ostream & | os | ) | const |
Definition at line 680 of file HTTPMessage.cpp.
References chunked_, proxygen::HTTPMessage::Request::clientIP_, proxygen::HTTPMessage::Request::clientPort_, dstIP_, dstPort_, folly::gen::field(), fields_, proxygen::HTTPHeaders::forEach(), getMethodString(), h, headers_, localIP_, proxygen::HTTPMessage::Request::path_, proxygen::HTTPMessage::Request::pushStatusStr_, proxygen::HTTPMessage::Request::query_, request(), response(), proxygen::HTTPHeaders::size(), proxygen::HTTPMessage::Response::statusMsg_, proxygen::HTTPMessage::Response::statusStr_, proxygen::stripCntrlChars(), strippedPerHopHeaders_, upgraded_, proxygen::HTTPMessage::Request::url_, and versionStr_.
Referenced by getUpgradeProtocol(), and proxygen::operator<<().
|
private |
Definition at line 788 of file HTTPMessage.cpp.
References c, folly::test::end(), proxygen::HTTPHeaders::forEachValueOfHeader(), proxygen::isLWS(), cpp.ast::next(), folly::Range< Iter >::reset(), and value.
Referenced by checkForHeaderToken(), and computeKeepalive().
void proxygen::HTTPMessage::dumpMessage | ( | int | verbosity | ) | const |
Print the message out.
Definition at line 676 of file HTTPMessage.cpp.
Referenced by atomicDumpMessage(), getUpgradeProtocol(), and CurlService::CurlClient::sendRequest().
void proxygen::HTTPMessage::dumpMessageToSink | ( | google::LogSink * | logSink | ) | const |
Print the message out to logSink.
Definition at line 736 of file HTTPMessage.cpp.
Referenced by getUpgradeProtocol().
void proxygen::HTTPMessage::ensureHostHeader | ( | ) |
Ensures this HTTPMessage contains a host header, adding a default one with the destination address if necessary.
Definition at line 327 of file HTTPMessage.cpp.
References proxygen::HTTPHeaders::add(), proxygen::HTTPHeaders::exists(), getDstAddress(), getDstIP(), headers_, and proxygen::HTTP_HEADER_HOST.
Referenced by is5xxResponse(), and TEST().
|
inline |
Move headers out of current message (returns rvalue ref)
Definition at line 279 of file HTTPMessage.h.
References headers_, and folly::gen::move.
|
static |
Formats the current time appropriately for a Date header
Definition at line 321 of file HTTPMessage.cpp.
References folly::SingletonThreadLocal< T, Tag, Make, TLTag >::get().
Referenced by proxygen::HTTP1xCodec::addDateHeader(), is5xxResponse(), proxygen::CodecUtil::prepareMessageForCompression(), and proxygen::SPDYCodec::serializeResponseHeaders().
|
inline |
|
inline |
Definition at line 104 of file HTTPMessage.h.
References proxygen::HTTPMessage::Request::clientAddress_, and request().
|
inline |
Definition at line 108 of file HTTPMessage.h.
References proxygen::HTTPMessage::Request::clientIP_, and request().
|
inline |
Definition at line 112 of file HTTPMessage.h.
References proxygen::HTTPMessage::Request::clientPort_, and request().
const StringPiece proxygen::HTTPMessage::getCookie | ( | const std::string & | name | ) | const |
Get the cookie with the specified name.
Returns a StringPiece to the cookie value, or an empty StringPiece if there is no cookie with the specified name. The returned cookie is only valid as long as the Cookie Header in HTTPMessage object exists. Applications should make sure they call unparseCookies() when editing the Cookie Header, so that the StringPiece references are cleared.
Definition at line 401 of file HTTPMessage.cpp.
References cookies_, parseCookies(), parsedCookies_, and unparseCookies().
Referenced by getUpgradeProtocol(), and TEST().
std::string proxygen::HTTPMessage::getDecodedQueryParam | ( | const std::string & | name | ) | const |
Get the query parameter with the specified name after percent decoding.
Returns empty string if parameter is missing or folly::uriUnescape query param
Definition at line 482 of file HTTPMessage.cpp.
References folly::exceptionStr(), getQueryParam(), folly::QUERY, string, folly::uriUnescape(), and val.
Referenced by getUpgradeProtocol(), and TEST().
|
static |
Get the default reason string for a status code.
This returns the reason string for the specified status code as specified in RFC 2616. For unknown status codes, the string "-" is returned.
Definition at line 882 of file HTTPMessage.cpp.
Referenced by proxygen::HTTP1xCodec::generateHeader(), proxygen::HeaderDecodeInfo::onHeader(), proxygen::HTTPDirectResponseHandler::onHeadersComplete(), and setStartTime().
|
inline |
Definition at line 132 of file HTTPMessage.h.
References dstAddress_.
Referenced by ensureHostHeader().
|
inline |
|
inline |
|
inline |
Access the headers (fpreq, fpres)
Definition at line 273 of file HTTPMessage.h.
References headers_.
Referenced by proxygen::HTTPArchive::convertToHPACK(), TestPriorityMapBuilder::createVirtualStreams(), CurlService::CurlClient::CurlClient(), doEmptyHeaderValueTest(), proxygen::SPDYCodec::encodeHeaders(), ZlibServerFilterTest::exercise_compression(), HTTPDownstreamTest< SPDY3_1CodecPair >::expect101(), proxygen::HTTPArchive::fromFile(), proxygen::HTTPArchive::fromPublicFile(), proxygen::HTTPChecks::generateHeader(), proxygen::HTTP1xCodec::generateHeader(), proxygen::HTTP2Codec::generateHeaderImpl(), PushService::generateUrl(), proxygen::getBigGetRequest(), proxygen::getChunkedPostRequest(), proxygen::getGetRequest(), proxygen::getPostRequest(), proxygen::getPubRequest(), proxygen::getResponse(), CurlService::CurlClient::getServerName(), proxygen::HTTPArchive::getSize(), getSynStream(), proxygen::getUpgradeRequest(), proxygen::compress::SimStreamingCallback::onHeader(), proxygen::HTTPDirectResponseHandler::onHeadersComplete(), proxygen::compress::SimStreamingCallback::onHeadersComplete(), proxygen::HTTP2Codec::onIngressUpgradeMessage(), proxygen::HTTPDownstreamSession::onNativeProtocolUpgrade(), proxygen::operator==(), proxygen::compress::prepareMessageForCompression(), proxygen::CodecUtil::prepareMessageForCompression(), proxygen::HTTP2Codec::requestUpgrade(), proxygen::HTTPHandlerBase::sendHeaders(), proxygen::HTTPTransaction::sendHeadersWithOptionalEOM(), proxygen::MockHTTPPushHandler::sendPushHeaders(), CurlService::CurlClient::sendRequest(), proxygen::SPDYCodec::serializeRequestHeaders(), proxygen::SPDYCodec::serializeResponseHeaders(), proxygen::HTTPRequestVerifier::setAuthority(), TEST(), TEST_F(), TEST_P(), HTTPUpstreamTest< C >::testBasicRequestHttp10(), and HTTP2CodecTest::testHeaderListSize().
|
inline |
|
inline |
Definition at line 594 of file HTTPMessage.h.
References h2Pri_.
Referenced by proxygen::HTTP2Codec::generateHeaderImpl(), and proxygen::HTTPSession::getMessagePriority().
Definition at line 262 of file HTTPMessage.cpp.
References version_.
Referenced by proxygen::HTTP1xCodec::generateHeader().
|
inline |
Definition at line 615 of file HTTPMessage.h.
References size_.
Referenced by HTTP1xCodecCallback::onHeadersComplete().
int proxygen::HTTPMessage::getIntQueryParam | ( | const std::string & | name | ) | const |
Get the query parameter with the specified name as int.
If the conversion fails, throws exception.
Definition at line 469 of file HTTPMessage.cpp.
References getQueryParam().
Referenced by getIntQueryParam(), getUpgradeProtocol(), and TEST().
int proxygen::HTTPMessage::getIntQueryParam | ( | const std::string & | name, |
int | defval | ||
) | const |
Get the query parameter with the specified name as int.
Returns the query parameter if it can be parsed as int otherwise the default value.
Definition at line 473 of file HTTPMessage.cpp.
References getIntQueryParam().
|
inline |
Definition at line 80 of file HTTPMessage.h.
References chunked_.
Referenced by ZlibServerFilterTest::exercise_compression(), proxygen::HTTP1xCodec::generateHeader(), and TEST_F().
|
inline |
|
inline |
folly::Optional< HTTPMethod > proxygen::HTTPMessage::getMethod | ( | ) | const |
an HTTPMethod enum value representing the method if it is a standard request method, or else "none" if it is an extension method (fpreq)
Definition at line 235 of file HTTPMessage.cpp.
References folly::none, and request().
Referenced by proxygen::HTTPChecks::generateHeader(), proxygen::HTTP1xCodec::generateHeader(), proxygen::HTTP2Codec::onHeadersComplete(), proxygen::compress::prepareMessageForCompression(), proxygen::CodecUtil::prepareMessageForCompression(), processMaxForwards(), rawSetMethod(), proxygen::HTTPTransaction::sendHeadersWithOptionalEOM(), TEST(), and proxygen::HTTPRequestVerifier::validate().
const std::string & proxygen::HTTPMessage::getMethodString | ( | ) | const |
a string representation of the request method (fpreq)
Definition at line 246 of file HTTPMessage.cpp.
References proxygen::empty_string, proxygen::methodToString(), and request().
Referenced by describe(), proxygen::HTTP1xCodec::generateHeader(), proxygen::operator==(), proxygen::compress::prepareMessageForCompression(), proxygen::CodecUtil::prepareMessageForCompression(), rawSetMethod(), proxygen::SPDYCodec::serializeRequestHeaders(), and TEST().
|
inline |
Access the path component (fpreq)
Definition at line 215 of file HTTPMessage.h.
References proxygen::HTTPMessage::Request::path_, and request().
Referenced by testPathAndQuery().
|
inline |
Definition at line 590 of file HTTPMessage.h.
References pri_.
Referenced by proxygen::SPDYCodec::generateSynStream(), and proxygen::HTTPSession::getMessagePriority().
|
inline |
Return the protocol string used by this HTTPMessage.
If this HTTP message is using an advanced protocol, the protocol string will be the advanced protocol. If not, it will simply be the HTTP version.
Definition at line 558 of file HTTPMessage.h.
References isAdvancedProto(), protoStr_, and versionStr_.
Referenced by TEST().
uint16_t proxygen::HTTPMessage::getPushStatusCode | ( | ) | const |
Definition at line 353 of file HTTPMessage.cpp.
References proxygen::HTTPMessage::Request::pushStatus_, and request().
Referenced by getUpgradeProtocol().
const std::string & proxygen::HTTPMessage::getPushStatusStr | ( | ) | const |
Definition at line 349 of file HTTPMessage.cpp.
References proxygen::HTTPMessage::Request::pushStatusStr_, and request().
Referenced by getUpgradeProtocol(), and proxygen::SPDYCodec::serializeRequestHeaders().
const string & proxygen::HTTPMessage::getQueryParam | ( | const std::string & | name | ) | const |
Get the query parameter with the specified name.
Returns a reference to the query parameter value, or proxygen::empty_string if there is no parameter with the specified name. The returned value is only valid as long as this HTTPMessage object.
Definition at line 464 of file HTTPMessage.cpp.
References proxygen::empty_string, and getQueryParamPtr().
Referenced by getDecodedQueryParam(), getIntQueryParam(), getUpgradeProtocol(), and TEST().
const string * proxygen::HTTPMessage::getQueryParamPtr | ( | const std::string & | name | ) | const |
Get the query parameter with the specified name.
Returns a pointer to the query parameter value, or nullptr if there is no parameter with the specified name. The returned value is only valid as long as this HTTPMessage object.
Definition at line 447 of file HTTPMessage.cpp.
References parsedQueryParams_, parseQueryParams(), and queryParams_.
Referenced by getQueryParam(), getUpgradeProtocol(), and hasQueryParam().
const std::map< std::string, std::string > & proxygen::HTTPMessage::getQueryParams | ( | ) | const |
Get all the query parameters.
Returns a reference to the query parameters map. The returned value is only valid as long as this HTTPMessage object.
Definition at line 494 of file HTTPMessage.cpp.
References parsedQueryParams_, parseQueryParams(), and queryParams_.
Referenced by getUpgradeProtocol().
|
inline |
Access the query component (fpreq)
Definition at line 222 of file HTTPMessage.h.
References proxygen::HTTPMessage::Request::query_, and request().
Referenced by testPathAndQuery(), testRemoveQueryParam(), and testSetQueryParam().
|
inline |
|
inline |
|
inline |
|
inline |
Getter and setter for the time when the first byte of the message arrived
Definition at line 622 of file HTTPMessage.h.
References startTime_.
Referenced by proxygen::compress::CompressionSimulator::readInputFromFileAndSchedule().
uint16_t proxygen::HTTPMessage::getStatusCode | ( | ) | const |
Definition at line 340 of file HTTPMessage.cpp.
References response(), and proxygen::HTTPMessage::Response::status_.
Referenced by HTTPDownstreamTest< SPDY3_1CodecPair >::expect101(), proxygen::HTTP1xCodec::generateHeader(), hasTrailers(), is1xxResponse(), is4xxResponse(), is5xxResponse(), proxygen::HTTP2Codec::onHeadersComplete(), proxygen::HTTPDownstreamSession::onHeadersSent(), proxygen::CodecUtil::prepareMessageForCompression(), proxygen::HTTPTransaction::sendHeadersWithOptionalEOM(), proxygen::SPDYCodec::serializeResponseHeaders(), DownstreamTransactionTest::setupRequestResponseFlow(), and TEST_F().
|
inline |
Definition at line 245 of file HTTPMessage.h.
References response(), and proxygen::HTTPMessage::Response::statusMsg_.
Referenced by HTTPDownstreamTest< SPDY3_1CodecPair >::expect101(), proxygen::HTTP1xCodec::generateHeader(), and proxygen::SPDYCodec::serializeResponseHeaders().
|
inline |
Definition at line 530 of file HTTPMessage.h.
References strippedPerHopHeaders_.
Referenced by TEST().
|
inline |
Access the trailers
Definition at line 286 of file HTTPMessage.h.
References trailers_.
|
inline |
Definition at line 287 of file HTTPMessage.h.
References trailers_.
|
inline |
Definition at line 378 of file HTTPMessage.h.
References atomicDumpMessage(), constructDirectResponse(), describe(), dumpMessage(), dumpMessageToSink(), getCookie(), getDecodedQueryParam(), getIntQueryParam(), getPushStatusCode(), getPushStatusStr(), getQueryParam(), getQueryParamPtr(), getQueryParams(), hasQueryParam(), name, removeQueryParam(), setPushStatusCode(), setQueryParam(), setQueryString(), statusCode, string, stripPerHopHeaders(), uint16_t, upgradeProtocol_, value, upload::verbosity, and version.
Referenced by proxygen::HTTP2Codec::onHeadersComplete().
|
inline |
Definition at line 205 of file HTTPMessage.h.
References request(), and proxygen::HTTPMessage::Request::url_.
Referenced by proxygen::HTTP1xCodec::generateHeader(), proxygen::operator==(), proxygen::compress::prepareMessageForCompression(), proxygen::CodecUtil::prepareMessageForCompression(), proxygen::SPDYCodec::serializeRequestHeaders(), testPathAndQuery(), testRemoveQueryParam(), and testSetQueryParam().
|
inline |
Get/Set the HTTP version string (like "1.1"). XXX: Note we only support X.Y format while setting version.
Definition at line 256 of file HTTPMessage.h.
References versionStr_.
bool proxygen::HTTPMessage::hasQueryParam | ( | const std::string & | name | ) | const |
Check if query parameter with the specified name exists.
Definition at line 460 of file HTTPMessage.cpp.
References getQueryParamPtr().
Referenced by getUpgradeProtocol(), and TEST().
|
inline |
Returns true if this message has trailers that need to be serialized
Definition at line 365 of file HTTPMessage.h.
References getStatusCode(), setStatusCode(), trailers_, trailersAllowed_, and uint16_t.
|
inline |
Returns true if this is a 1xx response.
Definition at line 316 of file HTTPMessage.h.
References getStatusCode().
Referenced by proxygen::HTTP1xCodec::generateHeader().
|
inline |
Returns true if this is a 4xx response.
Definition at line 321 of file HTTPMessage.h.
References getStatusCode().
|
inline |
Returns true if this is a 5xx response.
Definition at line 326 of file HTTPMessage.h.
References ensureHostHeader(), formatDateHeader(), getStatusCode(), and string.
|
inline |
Definition at line 545 of file HTTPMessage.h.
References protoStr_.
Referenced by getProtocolString().
|
inline |
Definition at line 72 of file HTTPMessage.h.
References upgradeWebsocket_.
Referenced by proxygen::HTTP1xCodec::generateHeader(), proxygen::HTTP2Codec::generateHeaderImpl(), and proxygen::CodecUtil::prepareMessageForCompression().
bool proxygen::HTTPMessage::isHTTP1_0 | ( | ) | const |
Returns true if the version of this message is HTTP/1.0
Definition at line 290 of file HTTPMessage.cpp.
References kHTTPVersion10, and version_.
Referenced by setTrailers().
bool proxygen::HTTPMessage::isHTTP1_1 | ( | ) | const |
Returns true if the version of this message is HTTP/1.1
Definition at line 294 of file HTTPMessage.cpp.
References kHTTPVersion11, and version_.
Referenced by setTrailers().
|
inline |
Definition at line 69 of file HTTPMessage.h.
References upgradeWebsocket_.
|
inline |
Definition at line 661 of file HTTPMessage.h.
References fields_.
Referenced by proxygen::HTTPChecks::generateHeader(), proxygen::HTTP2Codec::generateHeaderImpl(), proxygen::CodecUtil::prepareMessageForCompression(), and proxygen::HTTPTransaction::sendHeadersWithOptionalEOM().
|
inline |
Definition at line 668 of file HTTPMessage.h.
References createQueryString(), createUrl(), fields_, params, splitNameValue(), splitNameValuePieces(), string, and uint32_t.
Referenced by proxygen::CodecUtil::prepareMessageForCompression(), and proxygen::HTTPTransaction::sendHeadersWithOptionalEOM().
|
inline |
Definition at line 535 of file HTTPMessage.h.
References secure_.
Referenced by PushService::generateUrl(), proxygen::operator==(), proxygen::compress::prepareMessageForCompression(), proxygen::CodecUtil::prepareMessageForCompression(), and proxygen::SPDYCodec::serializeRequestHeaders().
Definition at line 576 of file HTTPMessage.h.
References kMaxPriority.
Referenced by setPriority(), and proxygen::HTTPTransaction::updateAndSendPriority().
HTTPMessage & proxygen::HTTPMessage::operator= | ( | const HTTPMessage & | message | ) |
Definition at line 142 of file HTTPMessage.cpp.
References chunked_, cookies_, dstAddress_, dstIP_, dstPort_, fields_, h2Pri_, headers_, localIP_, parsedCookies_, parsedQueryParams_, pri_, protoStr_, queryParams_, secure_, seqNo_, sslCipher_, sslVersion_, startTime_, strippedPerHopHeaders_, trailers_, trailersAllowed_, upgraded_, upgradeWebsocket_, version_, versionStr_, and wantsKeepalive_.
HTTPMessage & proxygen::HTTPMessage::operator= | ( | HTTPMessage && | message | ) |
Definition at line 181 of file HTTPMessage.cpp.
References chunked_, cookies_, dstAddress_, dstIP_, dstPort_, fields_, h2Pri_, headers_, localIP_, folly::gen::move, parsedCookies_, parsedQueryParams_, pri_, protoStr_, queryParams_, secure_, seqNo_, sslCipher_, sslVersion_, startTime_, strippedPerHopHeaders_, trailers_, trailersAllowed_, upgraded_, upgradeWebsocket_, version_, versionStr_, and wantsKeepalive_.
|
private |
Definition at line 381 of file HTTPMessage.cpp.
References cookies_, proxygen::HTTPHeaders::forEachValueOfHeader(), headers_, proxygen::HTTP_HEADER_COOKIE, parsedCookies_, and splitNameValuePieces().
Referenced by getCookie().
|
private |
Definition at line 418 of file HTTPMessage.cpp.
References parsedQueryParams_, proxygen::HTTPMessage::Request::query_, request(), and splitNameValue().
Referenced by getQueryParamPtr(), getQueryParams(), removeQueryParam(), and setQueryParam().
int proxygen::HTTPMessage::processMaxForwards | ( | ) |
Decrements Max-Forwards header, when present on OPTIONS or TRACE methods.
Returns HTTP status code.
Definition at line 266 of file HTTPMessage.cpp.
References getMethod(), proxygen::HTTPHeaders::getSingleOrEmpty(), headers_, proxygen::HTTP_HEADER_MAX_FORWARDS, int64_t, proxygen::OPTIONS, proxygen::HTTPHeaders::set(), proxygen::TRACE, and value.
Referenced by setTrailers().
|
inline |
Definition at line 160 of file HTTPMessage.h.
References getMethod(), getMethodString(), setMethod(), and string.
|
inline |
|
inline |
bool proxygen::HTTPMessage::removeQueryParam | ( | const std::string & | name | ) |
Remove the query parameter with the specified name.
Returns true if the query parameter was present and deleted.
Definition at line 520 of file HTTPMessage.cpp.
References createQueryString(), parsedQueryParams_, parseQueryParams(), queryParams_, request(), and setQueryString().
Referenced by getUpgradeProtocol(), and testRemoveQueryParam().
|
inlineprivate |
Definition at line 761 of file HTTPMessage.h.
References fields_.
Referenced by describe(), getClientAddress(), getClientIP(), getClientPort(), getMethod(), getMethodString(), getPath(), getPushStatusCode(), getPushStatusStr(), getQueryString(), getURL(), parseQueryParams(), removeQueryParam(), setClientAddress(), setMethod(), setPushStatusCode(), setQueryParam(), setQueryString(), and setURL().
|
inlineprivate |
Definition at line 770 of file HTTPMessage.h.
References fields_.
|
inlineprivate |
Definition at line 779 of file HTTPMessage.h.
References fields_.
Referenced by describe(), getStatusCode(), getStatusMessage(), setStatusCode(), and setStatusMessage().
|
inlineprivate |
Definition at line 788 of file HTTPMessage.h.
References fields_.
|
inline |
|
inline |
Set/Get client address
Definition at line 91 of file HTTPMessage.h.
References addr, proxygen::HTTPMessage::Request::clientAddress_, proxygen::HTTPMessage::Request::clientIP_, proxygen::HTTPMessage::Request::clientPort_, folly::SocketAddress::getAddressStr(), folly::SocketAddress::getPort(), folly::gen::move, and request().
|
inline |
Set/Get destination (vip) address
Definition at line 119 of file HTTPMessage.h.
References addr, dstAddress_, dstIP_, dstPort_, folly::SocketAddress::getAddressStr(), folly::SocketAddress::getPort(), and folly::gen::move.
Referenced by TEST().
|
inline |
Definition at line 66 of file HTTPMessage.h.
References upgradeWebsocket_.
Referenced by TEST(), and TEST_F().
|
inline |
Definition at line 599 of file HTTPMessage.h.
References h2Pri_.
Referenced by proxygen::MockHTTPPushHandler::sendPushHeaders(), and TEST_F().
Access the HTTP version number (fpreq, fpres)
Definition at line 256 of file HTTPMessage.cpp.
References min, version_, and versionStr_.
Referenced by constructDirectResponse(), proxygen::getBigGetRequest(), proxygen::getChunkedPostRequest(), proxygen::getGetRequest(), proxygen::getPostRequest(), proxygen::getPubRequest(), proxygen::HTTPDirectResponseHandler::onHeadersComplete(), proxygen::HTTPDownstreamSession::onNativeProtocolUpgrade(), proxygen::HTTPHandlerBase::sendChunkedReplyWithBody(), proxygen::HTTPHandlerBase::sendHeaders(), CurlService::CurlClient::sendRequest(), setVersionString(), TEST(), TEST_F(), and HTTPUpstreamTest< C >::testBasicRequestHttp10().
|
inline |
getter and setter for size in serialized form
Definition at line 612 of file HTTPMessage.h.
References folly::size(), and size_.
|
inline |
Definition at line 63 of file HTTPMessage.h.
References upgradeWebsocket_.
Referenced by proxygen::HTTP2Codec::onHeadersComplete().
|
inline |
Is this a chunked message? (fpreq, fpresp)
Definition at line 79 of file HTTPMessage.h.
References folly::gen::chunked(), and chunked_.
Referenced by constructDirectResponse(), proxygen::getChunkedPostRequest(), proxygen::HTTPHandlerBase::sendChunkedReplyWithBody(), and TEST().
|
inline |
Is this an upgraded message? (fpreq, fpresp)
Definition at line 85 of file HTTPMessage.h.
References upgraded_.
Referenced by constructDirectResponse().
|
inline |
Set/Get the local IP address
Definition at line 148 of file HTTPMessage.h.
References localIP_.
Referenced by TEST().
void proxygen::HTTPMessage::setMethod | ( | HTTPMethod | method | ) |
Access the method (fpreq)
Definition at line 216 of file HTTPMessage.cpp.
References proxygen::HTTPMessage::Request::method_, and request().
Referenced by doEmptyHeaderValueTest(), proxygen::getBigGetRequest(), proxygen::getChunkedPostRequest(), proxygen::getGetRequest(), getLocalIp(), proxygen::getPostRequest(), proxygen::getPubRequest(), getSynStream(), proxygen::getUpgradeRequest(), proxygen::compress::SimStreamingCallback::onHeader(), rawSetMethod(), CurlService::CurlClient::sendRequest(), proxygen::HTTPRequestVerifier::setMethod(), TEST(), TEST_F(), and TEST_P().
void proxygen::HTTPMessage::setMethod | ( | folly::StringPiece | method | ) |
Definition at line 221 of file HTTPMessage.cpp.
References proxygen::HTTPMessage::Request::method_, request(), folly::Range< Iter >::str(), proxygen::stringToMethod(), and folly::pushmi::operators::transform.
|
inline |
Definition at line 586 of file HTTPMessage.h.
References h2Pri_, folly::none, normalizePriority(), and pri_.
void proxygen::HTTPMessage::setPushStatusCode | ( | const uint16_t | status | ) |
Access the push status code
Definition at line 344 of file HTTPMessage.cpp.
References proxygen::HTTPMessage::Request::pushStatus_, proxygen::HTTPMessage::Request::pushStatusStr_, and request().
Referenced by getUpgradeProtocol(), TEST(), and TEST_F().
bool proxygen::HTTPMessage::setQueryParam | ( | const std::string & | name, |
const std::string & | value | ||
) |
Sets the query parameter with the specified name to the specified value.
Returns true if the query parameter was successfully set.
Definition at line 535 of file HTTPMessage.cpp.
References createQueryString(), name, parsedQueryParams_, parseQueryParams(), queryParams_, request(), setQueryString(), and value.
Referenced by getUpgradeProtocol(), and testSetQueryParam().
bool proxygen::HTTPMessage::setQueryString | ( | const std::string & | query | ) |
Set the query string to the specified value, and recreate the url_.
Returns true if the query string was changed successfully.
Definition at line 502 of file HTTPMessage.cpp.
References proxygen::ParseURL::authority(), createUrl(), proxygen::ParseURL::fragment(), proxygen::ParseURL::path(), proxygen::HTTPMessage::Request::query_, request(), proxygen::ParseURL::scheme(), proxygen::HTTPMessage::Request::url_, and proxygen::ParseURL::valid().
Referenced by getUpgradeProtocol(), removeQueryParam(), and setQueryParam().
|
inline |
Definition at line 534 of file HTTPMessage.h.
References secure_.
Referenced by proxygen::compress::SimStreamingCallback::onHeader(), CurlService::CurlClient::sendRequest(), proxygen::HTTPRequestVerifier::setScheme(), and TEST_F().
|
inline |
|
inline |
get and setter for transaction sequence number
Definition at line 606 of file HTTPMessage.h.
References seqNo_.
|
inline |
Definition at line 623 of file HTTPMessage.h.
References checkForHeaderToken(), computeKeepalive(), getDefaultReason(), startTime_, uint16_t, and unparseCookies().
void proxygen::HTTPMessage::setStatusCode | ( | uint16_t | status | ) |
Access the status code (fpres)
Definition at line 335 of file HTTPMessage.cpp.
References response(), proxygen::HTTPMessage::Response::status_, and proxygen::HTTPMessage::Response::statusStr_.
Referenced by constructDirectResponse(), TestPriorityMapBuilder::createVirtualStreams(), proxygen::getResponse(), hasTrailers(), proxygen::HTTPDirectResponseHandler::onHeadersComplete(), proxygen::HTTPDownstreamSession::onNativeProtocolUpgrade(), proxygen::HTTPHandlerBase::sendChunkedReplyWithBody(), proxygen::HTTPHandlerBase::sendHeaders(), TEST(), and TEST_F().
|
inline |
Access the HTTP status message string (res)
Definition at line 242 of file HTTPMessage.h.
References response(), and proxygen::HTTPMessage::Response::statusMsg_.
Referenced by constructDirectResponse(), TestPriorityMapBuilder::createVirtualStreams(), proxygen::HTTPDirectResponseHandler::onHeadersComplete(), proxygen::HTTPDownstreamSession::onNativeProtocolUpgrade(), rawSetStatusMessage(), TEST(), and TEST_F().
|
inline |
Set the trailers, replacing any that might already be present
Definition at line 292 of file HTTPMessage.h.
References isHTTP1_0(), isHTTP1_1(), folly::gen::move, processMaxForwards(), and trailers_.
|
inline |
Accessor to set whether trailers are allowed in the response
Definition at line 358 of file HTTPMessage.h.
References trailersAllowed_.
|
inline |
Definition at line 375 of file HTTPMessage.h.
References folly::gen::move, and upgradeProtocol_.
Referenced by proxygen::HTTPRequestVerifier::setUpgradeProtocol().
Access the URL component (fpreq)
The <url> component from the initial "METHOD <url> HTTP/..." line. When valid, this is a full URL, not just a path.
Definition at line 183 of file HTTPMessage.h.
References proxygen::ParseURL::path(), proxygen::HTTPMessage::Request::path_, proxygen::ParseURL::query(), proxygen::HTTPMessage::Request::query_, request(), folly::Range< Iter >::str(), unparseQueryParams(), proxygen::HTTPMessage::Request::url_, and proxygen::ParseURL::valid().
Referenced by doEmptyHeaderValueTest(), ZlibServerFilterTest::exercise_compression(), proxygen::getBigGetRequest(), proxygen::getChunkedPostRequest(), proxygen::getGetRequest(), proxygen::getPostRequest(), proxygen::getPubRequest(), getSynStream(), proxygen::compress::SimStreamingCallback::onHeader(), rawSetURL(), proxygen::MockHTTPPushHandler::sendPushHeaders(), CurlService::CurlClient::sendRequest(), proxygen::HTTPRequestVerifier::setPath(), setURL(), TEST(), TEST_F(), TEST_P(), testPathAndQuery(), testRemoveQueryParam(), and testSetQueryParam().
|
inline |
|
inline |
Definition at line 259 of file HTTPMessage.h.
References setHTTPVersion().
|
inline |
Indicates if this request wants the connection to be kept-alive (default true). Not all codecs respect this option.
Definition at line 343 of file HTTPMessage.h.
References wantsKeepalive_.
Referenced by proxygen::HTTPHandlerBase::sendHeaders(), TEST(), and TEST_F().
|
static |
Definition at line 628 of file HTTPMessage.cpp.
References folly::Range< Iter >::advance(), folly::Range< Iter >::empty(), folly::Range< Iter >::find(), folly::gen::move, name, folly::Range< Iter >::size(), folly::Range< Iter >::str(), folly::Range< Iter >::subpiece(), and value.
Referenced by isResponse(), and parseQueryParams().
|
static |
Assuming input contains <name><valueDelim>
(<pairDelim><name><valueDelim>
), invoke callback once with each name,value pair.
Definition at line 583 of file HTTPMessage.cpp.
References folly::Range< Iter >::advance(), name, trim(), and value.
Referenced by isResponse(), and parseCookies().
void proxygen::HTTPMessage::stripPerHopHeaders | ( | ) |
Interact with headers that are defined to be per-hop.
It is expected that during request processing, stripPerHopHeaders() will be called before the message is proxied to the other connection.
Definition at line 48 of file HTTPMessage.cpp.
References checkForHeaderToken(), headers_, proxygen::HTTP_HEADER_TE, proxygen::HTTPHeaders::removeAll(), strippedPerHopHeaders_, proxygen::HTTPHeaders::stripPerHopHeaders(), and trailersAllowed_.
Referenced by getUpgradeProtocol(), and TEST().
|
inline |
Returns true if trailers are allowed on this message. Trailers are not allowed on responses unless the client is expecting them.
Definition at line 354 of file HTTPMessage.h.
References trailersAllowed_.
|
staticprivate |
Trims whitespace from the beggining and end of the StringPiece.
Definition at line 619 of file HTTPMessage.cpp.
Referenced by splitNameValuePieces().
void proxygen::HTTPMessage::unparseCookies | ( | ) | const |
Forget about the parsed cookies.
Ideally HTTPMessage should automatically forget about the current parsed cookie state whenever a Cookie header is changed. However, at the moment callers have to explicitly call unparseCookies() after modifying the cookie headers.
Definition at line 396 of file HTTPMessage.cpp.
References cookies_, and parsedCookies_.
Referenced by getCookie(), and setStartTime().
|
private |
Definition at line 442 of file HTTPMessage.cpp.
References parsedQueryParams_, and queryParams_.
Referenced by setURL().
|
inline |
Definition at line 346 of file HTTPMessage.h.
References wantsKeepalive_.
Referenced by proxygen::HTTP1xCodec::generateHeader(), and TEST().
|
private |
Definition at line 820 of file HTTPMessage.h.
Referenced by describe(), getIsChunked(), operator=(), and setIsChunked().
|
mutableprivate |
Definition at line 802 of file HTTPMessage.h.
Referenced by getCookie(), operator=(), parseCookies(), and unparseCookies().
|
private |
Definition at line 752 of file HTTPMessage.h.
Referenced by getDstAddress(), operator=(), and setDstAddress().
|
private |
Definition at line 753 of file HTTPMessage.h.
Referenced by describe(), getDstIP(), operator=(), and setDstAddress().
|
private |
Definition at line 754 of file HTTPMessage.h.
Referenced by describe(), getDstPort(), operator=(), and setDstAddress().
Definition at line 759 of file HTTPMessage.h.
Referenced by describe(), isRequest(), isResponse(), operator=(), request(), and response().
|
private |
Definition at line 816 of file HTTPMessage.h.
Referenced by getHTTP2Priority(), operator=(), setHTTP2Priority(), and setPriority().
|
private |
Definition at line 807 of file HTTPMessage.h.
Referenced by checkForHeaderToken(), constructDirectResponse(), describe(), ensureHostHeader(), extractHeaders(), getHeaders(), operator=(), parseCookies(), processMaxForwards(), and stripPerHopHeaders().
Version constants
Definition at line 229 of file HTTPMessage.h.
Referenced by computeKeepalive(), proxygen::HTTP1xCodec::generateHeader(), and isHTTP1_0().
Definition at line 230 of file HTTPMessage.h.
Referenced by proxygen::HTTP1xCodec::generateHeader(), and isHTTP1_1().
|
static |
Definition at line 574 of file HTTPMessage.h.
Referenced by normalizePriority().
|
private |
Definition at line 756 of file HTTPMessage.h.
Referenced by describe(), getLocalIp(), operator=(), and setLocalIp().
|
staticprivate |
Definition at line 829 of file HTTPMessage.h.
Referenced by atomicDumpMessage().
|
mutableprivate |
Definition at line 818 of file HTTPMessage.h.
Referenced by getCookie(), operator=(), parseCookies(), and unparseCookies().
|
mutableprivate |
Definition at line 819 of file HTTPMessage.h.
Referenced by getQueryParamPtr(), getQueryParams(), operator=(), parseQueryParams(), removeQueryParam(), setQueryParam(), and unparseQueryParams().
|
private |
Definition at line 815 of file HTTPMessage.h.
Referenced by getPriority(), operator=(), and setPriority().
|
private |
Definition at line 814 of file HTTPMessage.h.
Referenced by getAdvancedProtocolString(), getProtocolString(), isAdvancedProto(), operator=(), and setAdvancedProtocolString().
|
mutableprivate |
Definition at line 804 of file HTTPMessage.h.
Referenced by getQueryParamPtr(), getQueryParams(), operator=(), removeQueryParam(), setQueryParam(), and unparseQueryParams().
|
private |
Definition at line 826 of file HTTPMessage.h.
Referenced by isSecure(), operator=(), and setSecure().
|
protected |
Definition at line 709 of file HTTPMessage.h.
Referenced by getSeqNo(), operator=(), and setSeqNo().
|
private |
Definition at line 809 of file HTTPMessage.h.
Referenced by getIngressHeaderSize(), and setIngressHeaderSize().
|
private |
Definition at line 813 of file HTTPMessage.h.
Referenced by getSecureCipher(), operator=(), and setSecureInfo().
|
private |
Definition at line 812 of file HTTPMessage.h.
Referenced by getSecureVersion(), operator=(), and setSecureInfo().
|
protected |
Definition at line 708 of file HTTPMessage.h.
Referenced by getStartTime(), operator=(), and setStartTime().
|
private |
Definition at line 808 of file HTTPMessage.h.
Referenced by computeKeepalive(), describe(), getStrippedPerHopHeaders(), operator=(), and stripPerHopHeaders().
|
private |
Definition at line 810 of file HTTPMessage.h.
Referenced by getTrailers(), hasTrailers(), HTTPMessage(), operator=(), and setTrailers().
|
private |
Definition at line 823 of file HTTPMessage.h.
Referenced by hasTrailers(), operator=(), setTrailersAllowed(), stripPerHopHeaders(), and trailersAllowed().
|
private |
Definition at line 821 of file HTTPMessage.h.
Referenced by describe(), getIsUpgraded(), operator=(), and setIsUpgraded().
|
private |
Definition at line 832 of file HTTPMessage.h.
Referenced by getUpgradeProtocol(), and setUpgradeProtocol().
|
private |
Definition at line 831 of file HTTPMessage.h.
Referenced by isEgressWebsocketUpgrade(), isIngressWebsocketUpgrade(), operator=(), setEgressWebsocketUpgrade(), and setIngressWebsocketUpgrade().
Definition at line 806 of file HTTPMessage.h.
Referenced by computeKeepalive(), getHTTPVersion(), isHTTP1_0(), isHTTP1_1(), operator=(), and setHTTPVersion().
|
private |
Definition at line 757 of file HTTPMessage.h.
Referenced by describe(), getProtocolString(), getVersionString(), operator=(), and setHTTPVersion().
|
private |
Definition at line 822 of file HTTPMessage.h.
Referenced by operator=(), setWantsKeepalive(), and wantsKeepalive().