21 bool strtoulWrapper(
const char *&curs,
const char *
end,
unsigned long&
val) {
22 char* endptr =
nullptr;
24 unsigned long v = strtoul(curs, &endptr, 10);
55 return (status == 304 || status == 204 ||
56 (100 <= status && status < 200));
69 for (
auto& token: *tokens) {
70 auto pos = token.find(
';');
72 if (pos != std::string::npos) {
73 auto qpos = token.find(
"q=", pos);
74 if (qpos != std::string::npos) {
76 token.size() - (qpos + 2));
78 qvalue = folly::to<double>(&qvalueStr);
79 }
catch (
const std::range_error&) {
89 token.reset(token.start(), pos);
92 while (token.size() > 0 && isspace(token[0])) {
93 token.reset(token.start() + 1, token.size() - 1);
95 if (token.size() == 0) {
99 output.emplace_back(token, qvalue);
102 return result && output.size() > 0;
107 unsigned long& outFirstByte,
108 unsigned long& outLastByte,
109 unsigned long& outInstanceLength) {
115 const char* curs = value.
begin() + 6 ;
116 const char* end = value.
end();
118 unsigned long firstByte = ULONG_MAX;
119 unsigned long lastByte = ULONG_MAX;
120 unsigned long instanceLength = ULONG_MAX;
122 if (!strtoulWrapper(curs, end, firstByte)) {
128 lastByte = ULONG_MAX;
137 if (!strtoulWrapper(curs, end, lastByte)) {
148 if (!strtoulWrapper(curs, end, instanceLength)) {
155 if (curs < end && *curs !=
'\0') {
159 if (lastByte < firstByte) {
163 if ((lastByte - firstByte + 1) > instanceLength) {
167 outFirstByte = firstByte;
168 outLastByte = lastByte;
169 outInstanceLength = instanceLength;
bool bodyImplied(const HTTPHeaders &headers)
bool responseBodyMustBeEmpty(unsigned status)
void split(const Delim &delimiter, const String &input, std::vector< OutputType > &out, bool ignoreEmpty)
BodyAllowed isRequestBodyAllowed(folly::Optional< HTTPMethod > method)
auto end(TestAdlIterable &instance)
static const char *const value
constexpr Iter end() const
constexpr Iter begin() const
bool startsWith(const const_range_type &other) const
bool parseByteRangeSpec(folly::StringPiece value, unsigned long &outFirstByte, unsigned long &outLastByte, unsigned long &outInstanceLength)
static const char tokens[256]
bool parseQvalues(folly::StringPiece value, std::vector< TokenQPair > &output)