6 * SQUID Web Proxy Cache http://www.squid-cache.org/
7 * ----------------------------------------------------------
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.
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.
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.
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.
34 #ifndef SQUID_HTTPHEADERRANGE_H
35 #define SQUID_HTTPHEADERRANGE_H
41 #include "SquidString.h"
44 /* http byte-range-spec */
46 class HttpHdrRangeSpec
50 MEMPROXY_CLASS(HttpHdrRangeSpec
);
51 typedef Range
<int64_t, uint64_t> HttpRange
;
52 static int64_t const UnknownPosition
;
55 static HttpHdrRangeSpec
*Create(const char *field
, int fieldLen
);
57 bool parseInit(const char *field
, int flen
);
58 int canonize(int64_t clen
);
59 void outputInfo( char const *note
) const;
60 void packInto(Packer
* p
) const;
61 bool mergeWith(const HttpHdrRangeSpec
* donor
);
66 MEMPROXY_CLASS_INLINE(HttpHdrRangeSpec
);
69 * There may be more than one byte range specified in the request.
70 * This object holds all range specs in order of their appearence
71 * in the request because we SHOULD preserve that order.
77 MEMPROXY_CLASS(HttpHdrRange
);
79 static size_t ParsedCount
;
80 /* Http Range Header Field */
81 static HttpHdrRange
*ParseCreate(const String
* range_spec
);
84 HttpHdrRange(HttpHdrRange
const &);
86 HttpHdrRange
&operator= (HttpHdrRange
const &);
88 typedef Vector
<HttpHdrRangeSpec
*>::iterator iterator
;
89 typedef Vector
<HttpHdrRangeSpec
*>::const_iterator const_iterator
;
91 const_iterator
begin () const;
93 const_iterator
end() const;
95 /* adjust specs after the length is known */
96 int canonize(int64_t);
97 int canonize(HttpReply
*rep
);
98 /* returns true if ranges are valid; inits HttpHdrRange */
99 bool parseInit(const String
* range_spec
);
100 void packInto(Packer
* p
) const;
102 bool isComplex() const;
103 bool willBeComplex() const;
104 int64_t firstOffset() const;
105 int64_t lowestOffset(int64_t) const;
106 bool offsetLimitExceeded(const int64_t limit
) const;
107 bool contains(HttpHdrRangeSpec
& r
) const;
108 Vector
<HttpHdrRangeSpec
*> specs
;
111 void getCanonizedSpecs (Vector
<HttpHdrRangeSpec
*> ©
);
112 void merge (Vector
<HttpHdrRangeSpec
*> &basis
);
116 MEMPROXY_CLASS_INLINE(HttpHdrRange
);
119 * Data for iterating thru range specs
121 class HttpHdrRangeIter
125 HttpHdrRange::iterator pos
;
126 const HttpHdrRangeSpec
*currentSpec() const;
128 int64_t debt() const;
130 int64_t debt_size
; /* bytes left to send from the current spec */
131 String boundary
; /* boundary for multipart responses */
135 #endif /* SQUID_HTTPHEADERRANGE_H */