41#define known_spec(s) ((s) > HttpHdrRangeSpec::UnknownPosition)
79 if (!((p = strchr(field,
'-')) && (p - field < flen))) {
80 debugs(64, 2,
"invalid (missing '-') range-spec near: '" << field <<
"'");
89 if (p - field < flen) {
97 debugs(64, 2,
"invalid (last-byte-pos < first-byte-pos) range-spec near: " << field);
102 if (last_pos == std::numeric_limits<
decltype(last_pos)>
::max()) {
103 debugs(64, 2,
"unsupported (last-byte-pos too large) range-spec near: " << field);
130 debugs(64, 5,
"HttpHdrRangeSpec::canonize: " << note <<
": [" <<
173#if MERGING_BREAKS_NOTHING
176 const int64_t donor_rhs = donor->
offset + donor->
length;
189 if (donor->
offset <= rhs && rhs < donor_rhs) {
235 const char *pos =
nullptr;
239 debugs(64, 8,
"parsing range field: '" << *range_spec <<
"'");
242 if (range_spec->
caseCmp(
"bytes=", 6))
256 while (!
specs.empty()) {
260 debugs(64, 2,
"ignoring invalid range field: '" << *range_spec <<
"'");
264 specs.push_back(spec);
267 debugs(64, 8,
"got range specs: " <<
specs.size());
268 return !
specs.empty();
273 while (!
specs.empty()) {
294 return specs.begin();
306 return specs.begin();
320 while (pos !=
end()) {
324 (*pos)->packInto(packer);
340 while (i != basis.end()) {
341 if (
specs.size() && (*i)->mergeWith(
specs.back())) {
348 specs.push_back (*i);
352 debugs(64, 3,
"HttpHdrRange::merge: had " << basis.size() <<
353 " specs, merged " << basis.size() -
specs.size() <<
" specs");
362 if ((*pos)->canonize(
clen))
363 copy.push_back (*pos);
368 debugs(64, 3,
"found " <<
specs.size() - copy.size() <<
" bad specs");
397 debugs(64, 3,
"HttpHdrRange::canonize: started with " <<
specs.size() <<
398 " specs, clen: " <<
clen);
399 std::vector<HttpHdrRangeSpec*> goods;
402 debugs(64, 3,
"HttpHdrRange::canonize: finished with " <<
specs.size() <<
404 return specs.size() > 0;
416 while (pos !=
end()) {
418 assert ((*pos)->offset >= 0);
420 if ((*pos)->offset < offset)
423 offset = (*pos)->offset + (*pos)->length;
447 assert ((*pos)->offset >= 0);
449 if ((*pos)->offset < offset)
452 offset = (*pos)->offset;
455 offset += (*pos)->length;
472 while (pos !=
end()) {
473 if ((*pos)->offset < offset || !
known_spec(offset))
474 offset = (*pos)->offset;
494 while (pos !=
end()) {
495 int64_t current = (*pos)->offset;
501 current =
size - (*pos)->length;
568 debugs(64, 3,
"HttpHdrRangeIter::debt: was " <<
debt_size <<
" now " << newDebt);
int strListGetItem(const String *str, char del, const char **item, int *ilen, const char **pos)
HttpHdrRange::iterator pos
HttpHdrRange::iterator end
const HttpHdrRangeSpec * currentSpec() const
void packInto(Packable *p) const
bool parseInit(const char *field, int flen)
static HttpHdrRangeSpec * Create(const char *field, int fieldLen)
bool mergeWith(const HttpHdrRangeSpec *donor)
static int64_t const UnknownPosition
int canonize(int64_t clen)
void outputInfo(char const *note) const
std::vector< HttpHdrRangeSpec * >::iterator iterator
void getCanonizedSpecs(std::vector< HttpHdrRangeSpec * > ©)
bool offsetLimitExceeded(const int64_t limit) const
void merge(std::vector< HttpHdrRangeSpec * > &basis)
static size_t ParsedCount
std::vector< HttpHdrRangeSpec * >::const_iterator const_iterator
bool willBeComplex() const
std::vector< HttpHdrRangeSpec * > specs
bool parseInit(const String *range_spec)
int64_t lowestOffset(int64_t) const
void packInto(Packable *p) const
static HttpHdrRange * ParseCreate(const String *range_spec)
int64_t firstOffset() const
const HttpHdrContRange * contentRange() const
void appendf(const char *fmt,...) PRINTF_FORMAT_ARG2
Append operation with printf-style arguments.
virtual void append(const char *buf, int size)=0
Appends a c-string to existing packed data.
Range intersection(Range const &) const
char const * termedBuf() const
int caseCmp(char const *) const
A const & max(A const &lhs, A const &rhs)
#define debugs(SECTION, LEVEL, CONTENT)