HttpHeaderRange.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_HTTPHEADERRANGE_H
10#define SQUID_HTTPHEADERRANGE_H
11
12#include "base/Range.h"
13#include "mem/forward.h"
14#include "SquidString.h"
15
16#include <vector>
17
18class HttpReply;
19class Packable;
20
21// TODO: Refactor to disambiguate and provide message-specific APIs.
27{
29
30public:
32 static int64_t const UnknownPosition;
33
35 static HttpHdrRangeSpec *Create(const char *field, int fieldLen);
36
37 bool parseInit(const char *field, int flen);
38 int canonize(int64_t clen);
39 void outputInfo( char const *note) const;
40 void packInto(Packable * p) const;
41 bool mergeWith(const HttpHdrRangeSpec * donor);
42 int64_t offset;
43 int64_t length;
44};
45
52{
54
55public:
56 static size_t ParsedCount;
57 /* Http Range Header Field */
58 static HttpHdrRange *ParseCreate(const String * range_spec);
59
64
65 typedef std::vector<HttpHdrRangeSpec *>::iterator iterator;
66 typedef std::vector<HttpHdrRangeSpec *>::const_iterator const_iterator;
68 const_iterator begin () const;
69 iterator end();
70 const_iterator end() const;
71
72 /* adjust specs after the length is known */
73 int canonize(int64_t);
74 int canonize(HttpReply *rep);
75 /* returns true if ranges are valid; inits HttpHdrRange */
76 bool parseInit(const String * range_spec);
77 void packInto(Packable * p) const;
78 /* other */
79 bool isComplex() const;
80 bool willBeComplex() const;
81 int64_t firstOffset() const;
82 int64_t lowestOffset(int64_t) const;
83 bool offsetLimitExceeded(const int64_t limit) const;
84 std::vector<HttpHdrRangeSpec *> specs;
85
86private:
87 void getCanonizedSpecs (std::vector<HttpHdrRangeSpec *> &copy);
88 void merge (std::vector<HttpHdrRangeSpec *> &basis);
89 int64_t clen;
90};
91
96{
97
98public:
101 const HttpHdrRangeSpec *currentSpec() const;
102 void updateSpec();
103 int64_t debt() const;
104 void debt(int64_t);
105 int64_t debt_size = 0; /* bytes left to send from the current spec */
106 String boundary; /* boundary for multipart responses */
107 bool valid = false;
108};
109
110#endif /* SQUID_HTTPHEADERRANGE_H */
111
HttpHdrRange::iterator pos
HttpHdrRange::iterator end
const HttpHdrRangeSpec * currentSpec() const
int64_t debt() const
void packInto(Packable *p) const
bool parseInit(const char *field, int flen)
Definition: HttpHdrRange.cc:64
static HttpHdrRangeSpec * Create(const char *field, int fieldLen)
Definition: HttpHdrRange.cc:53
bool mergeWith(const HttpHdrRangeSpec *donor)
Range< int64_t, uint64_t > HttpRange
MEMPROXY_CLASS(HttpHdrRangeSpec)
static int64_t const UnknownPosition
int canonize(int64_t clen)
void outputInfo(char const *note) const
int canonize(int64_t)
std::vector< HttpHdrRangeSpec * >::iterator iterator
void getCanonizedSpecs(std::vector< HttpHdrRangeSpec * > &copy)
bool offsetLimitExceeded(const int64_t limit) const
void merge(std::vector< HttpHdrRangeSpec * > &basis)
static size_t ParsedCount
iterator begin()
std::vector< HttpHdrRangeSpec * >::const_iterator const_iterator
iterator end()
bool willBeComplex() const
bool isComplex() const
HttpHdrRange & operator=(HttpHdrRange const &)
std::vector< HttpHdrRangeSpec * > specs
bool parseInit(const String *range_spec)
int64_t lowestOffset(int64_t) const
MEMPROXY_CLASS(HttpHdrRange)
void packInto(Packable *p) const
static HttpHdrRange * ParseCreate(const String *range_spec)
int64_t firstOffset() const
Definition: Range.h:19

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors