proxygen
|
Typedefs | |
using | TokenQPair = std::pair< folly::StringPiece, double > |
Enumerations | |
enum | BodyAllowed { BodyAllowed::DEFINED, BodyAllowed::NOT_DEFINED, BodyAllowed::NOT_ALLOWED } |
Functions | |
BodyAllowed | isRequestBodyAllowed (folly::Optional< HTTPMethod > method) |
bool | responseBodyMustBeEmpty (unsigned status) |
bool | bodyImplied (const HTTPHeaders &headers) |
bool | parseQvalues (folly::StringPiece value, std::vector< TokenQPair > &output) |
bool | parseByteRangeSpec (folly::StringPiece value, unsigned long &outFirstByte, unsigned long &outLastByte, unsigned long &outInstanceLength) |
using proxygen::RFC2616::TokenQPair = typedef std::pair<folly::StringPiece, double> |
Parse a string containing tokens and qvalues, such as the RFC strings for Accept-Charset, Accept-Encoding and Accept-Language. It won't work for complex Accept: headers because it doesn't return parameters or accept-extension.
See RFC sections 14.2, 14.3, 14.4 for definitions of these header values
TODO: optionally sort by qvalue descending
Return true if the string was well formed according to the RFC. Note it can return false but still populate output with best-effort parsing.
|
strong |
This file contains functions for determining when certain tricky parts of RFC 2616 arise. The HTTP request as defined in RFC 2616 may or may not have a body. In some cases they MUST NOT have a body. In other cases, the body has no semantic meaning and so is not defined. Finally, for some methods, the body is well defined. Please see Section 9 and 4.3 for details on this.
Enumerator | |
---|---|
DEFINED | |
NOT_DEFINED | |
NOT_ALLOWED |
bool proxygen::RFC2616::bodyImplied | ( | const HTTPHeaders & | headers | ) |
Returns true if the headers imply that a body will follow. Note that in some situations a body may come even if this function returns false (e.g. a 1.0 response body's length can be given implicitly by closing the connection).
Definition at line 59 of file RFC2616.cpp.
References proxygen::HTTPHeaders::exists(), proxygen::HTTP_HEADER_CONTENT_LENGTH, and proxygen::HTTP_HEADER_TRANSFER_ENCODING.
Referenced by proxygen::HTTPChecks::generateHeader(), and proxygen::HTTPChecks::onHeadersComplete().
BodyAllowed proxygen::RFC2616::isRequestBodyAllowed | ( | folly::Optional< HTTPMethod > | method | ) |
Definition at line 43 of file RFC2616.cpp.
References DEFINED, NOT_ALLOWED, NOT_DEFINED, proxygen::OPTIONS, proxygen::POST, proxygen::PUT, and proxygen::TRACE.
Referenced by proxygen::HTTPChecks::generateHeader(), and proxygen::HTTPChecks::onHeadersComplete().
bool proxygen::RFC2616::parseByteRangeSpec | ( | folly::StringPiece | value, |
unsigned long & | firstByte, | ||
unsigned long & | lastByte, | ||
unsigned long & | instanceLength | ||
) |
Parse an RFC 2616 section 14.16 "bytes A-B/C" string and returns them as the first and last bytes and instance length, respectively.
Wildcards are handled specially as follows: if the range is actually "*", the first byte is parsed as 0 and last byte as ULONG_MAX; if instance length is actually "*", it is parsed as ULONG_MAX.
Note that is ONLY suitable for use in parsing "Content-Range" response headers. The "Range" request header has different but similar syntax.
Definition at line 105 of file RFC2616.cpp.
References folly::Range< Iter >::begin(), folly::Range< Iter >::end(), and folly::Range< Iter >::startsWith().
Referenced by TEST().
bool proxygen::RFC2616::parseQvalues | ( | folly::StringPiece | value, |
std::vector< TokenQPair > & | output | ||
) |
Definition at line 64 of file RFC2616.cpp.
References folly::split(), and tokens.
Referenced by proxygen::ZlibServerFilterFactory::acceptsSupportedCompressionType(), proxygen::CodecUtil::hasGzipAndDeflate(), and TEST().
bool proxygen::RFC2616::responseBodyMustBeEmpty | ( | unsigned | status | ) |
Some status codes imply that there MUST NOT be a response body. See section 4.3: "All 1xx (informational), 204 (no content), and 304 (not modified) responses MUST NOT include a message-body."
status | The code to test (100 <= status <= 999) |
Definition at line 54 of file RFC2616.cpp.
Referenced by proxygen::HTTP1xCodec::generateHeader(), proxygen::HTTP1xCodec::onHeadersComplete(), and proxygen::HTTPTransaction::onIngressHeadersComplete().