]> git.ipfire.org Git - thirdparty/squid.git/blame - src/HttpHeaderRange.h
Cleanup: zap CVS Id tags
[thirdparty/squid.git] / src / HttpHeaderRange.h
CommitLineData
528b2c61 1
2/*
262a0e14 3 * $Id$
528b2c61 4 *
5 *
6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
8 *
9 * Squid is the result of efforts by numerous individuals from
10 * the Internet community; see the CONTRIBUTORS file for full
11 * details. Many organizations have provided support for Squid's
12 * development; see the SPONSORS file for full details. Squid is
13 * Copyrighted (C) 2001 by the Regents of the University of
14 * California; see the COPYRIGHT file for full details. Squid
15 * incorporates software developed and/or copyrighted by other
16 * sources; see the CREDITS file for full details.
17 *
18 * This program is free software; you can redistribute it and/or modify
19 * it under the terms of the GNU General Public License as published by
20 * the Free Software Foundation; either version 2 of the License, or
21 * (at your option) any later version.
26ac0430 22 *
528b2c61 23 * This program is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU General Public License for more details.
26ac0430 27 *
528b2c61 28 * You should have received a copy of the GNU General Public License
29 * along with this program; if not, write to the Free Software
30 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 *
32 */
33
34#ifndef SQUID_HTTPHEADERRANGE_H
35#define SQUID_HTTPHEADERRANGE_H
36
25b6a907 37#include "MemPool.h"
528b2c61 38#include "Range.h"
83d8f9f4 39#include "Array.h"
25b6a907 40#include "Packer.h"
41#include "SquidString.h"
528b2c61 42
0353e724 43class HttpReply;
528b2c61 44/* http byte-range-spec */
62e76326 45
46class HttpHdrRangeSpec
47{
48
49public:
b001e822 50 MEMPROXY_CLASS(HttpHdrRangeSpec);
47f6e231 51 typedef Range<int64_t> HttpRange;
52 static int64_t const UnknownPosition;
62e76326 53
528b2c61 54 HttpHdrRangeSpec();
55 static HttpHdrRangeSpec *Create(const char *field, int fieldLen);
56
57 bool parseInit(const char *field, int flen);
47f6e231 58 int canonize(int64_t clen);
528b2c61 59 void outputInfo( char const *note) const;
60 void packInto(Packer * p) const;
61 bool mergeWith(const HttpHdrRangeSpec * donor);
47f6e231 62 int64_t offset;
63 int64_t length;
528b2c61 64};
65
63be0a78 66MEMPROXY_CLASS_INLINE(HttpHdrRangeSpec) /**DOCS_NOSEMI*/
b001e822 67
63be0a78 68/**
69 * There may be more than one byte range specified in the request.
528b2c61 70 * This object holds all range specs in order of their appearence
71 * in the request because we SHOULD preserve that order.
72 */
62e76326 73class HttpHdrRange
74{
75
528b2c61 76public:
b001e822 77 MEMPROXY_CLASS(HttpHdrRange);
528b2c61 78
79 static size_t ParsedCount;
80 /* Http Range Header Field */
30abd221 81 static HttpHdrRange *ParseCreate(const String * range_spec);
528b2c61 82
83 HttpHdrRange();
84 HttpHdrRange(HttpHdrRange const &);
85 ~HttpHdrRange();
86 HttpHdrRange &operator= (HttpHdrRange const &);
87
88 typedef Vector<HttpHdrRangeSpec *>::iterator iterator;
89 typedef Vector<HttpHdrRangeSpec *>::const_iterator const_iterator;
90 iterator begin();
91 const_iterator begin () const;
92 iterator end();
93 const_iterator end() const;
62e76326 94
528b2c61 95 /* adjust specs after the length is known */
47f6e231 96 int canonize(int64_t);
528b2c61 97 int canonize(HttpReply *rep);
98 /* returns true if ranges are valid; inits HttpHdrRange */
30abd221 99 bool parseInit(const String * range_spec);
528b2c61 100 void packInto(Packer * p) const;
101 /* other */
102 bool isComplex() const;
103 bool willBeComplex() const;
47f6e231 104 int64_t firstOffset() const;
105 int64_t lowestOffset(int64_t) const;
528b2c61 106 bool offsetLimitExceeded() const;
fedd1531 107 bool contains(HttpHdrRangeSpec& r) const;
528b2c61 108 Vector<HttpHdrRangeSpec *> specs;
62e76326 109
528b2c61 110private:
528b2c61 111 void getCanonizedSpecs (Vector<HttpHdrRangeSpec *> &copy);
112 void merge (Vector<HttpHdrRangeSpec *> &basis);
47f6e231 113 int64_t clen;
528b2c61 114};
115
63be0a78 116MEMPROXY_CLASS_INLINE(HttpHdrRange) /**DOCS_NOSEMI*/
62e76326 117
63be0a78 118/**
119 * Data for iterating thru range specs
120 */
62e76326 121class HttpHdrRangeIter
122{
123
124public:
528b2c61 125 HttpHdrRange::iterator pos;
126 const HttpHdrRangeSpec *currentSpec() const;
127 void updateSpec();
47f6e231 128 int64_t debt() const;
129 void debt(int64_t);
130 int64_t debt_size; /* bytes left to send from the current spec */
30abd221 131 String boundary; /* boundary for multipart responses */
528b2c61 132 bool valid;
133};
62e76326 134
528b2c61 135#endif /* SQUID_HTTPHEADERRANGE_H */