3 * $Id: HttpHeaderRange.h,v 1.8 2006/06/06 19:22:13 hno Exp $
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
<ssize_t
> HttpRange
;
52 static ssize_t
const UnknownPosition
;
55 static HttpHdrRangeSpec
*Create(const char *field
, int fieldLen
);
57 bool parseInit(const char *field
, int flen
);
58 int canonize(size_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
)
68 /* There may be more than one byte range specified in the request.
69 * This object holds all range specs in order of their appearence
70 * 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 */
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 ssize_t
firstOffset() const;
105 ssize_t
lowestOffset(ssize_t
) const;
106 bool offsetLimitExceeded() 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
)
118 /* data for iterating thru range specs */
120 class HttpHdrRangeIter
124 HttpHdrRange::iterator pos
;
125 const HttpHdrRangeSpec
*currentSpec() const;
127 ssize_t
debt() const;
129 ssize_t debt_size
; /* bytes left to send from the current spec */
130 String boundary
; /* boundary for multipart responses */
134 #endif /* SQUID_HTTPHEADERRANGE_H */