1 
2 /* Web Polygraph       http://www.web-polygraph.org/
3  * Copyright 2003-2011 The Measurement Factory
4  * Licensed under the Apache License, Version 2.0 */
5 
6 #ifndef POLYGRAPH__CSM_RANGEBODYITER_H
7 #define POLYGRAPH__CSM_RANGEBODYITER_H
8 
9 #include "csm/BodyIter.h"
10 
11 // BodyIter for range requests.
12 // Both single and multi range are supported.
13 // Body content is generated by theProducer BodyIter.
14 class RangeBodyIter: public BodyIter {
15 	public:
16 		RangeBodyIter(const RangeList &ranges, BodyIter *const aProducer);
17 		virtual RangeBodyIter *clone() const;
18 
19 		virtual void start(WrBuf *aBuf);
20 		virtual void stop();
21 
22 		virtual bool pour();
23 
24 		virtual Size fullEntitySize() const;
25 
26 	protected:
27 		virtual void putHeaders(HttpPrinter &hp) const;
28 		bool pourRange(Size &first, const Size &last);
29 		void putRangeHeaders();
30 		void putTerminator();
31 		bool multiRange() const;
32 
33 		const RangeList &theRanges;
34 		BodyIter *theProducer;
35 		WrBuf theProducerBuf;
36 		Size theProducerOffset;
37 		Size theCurrRangeOffset;
38 		bool putPartHeader;
39 		RangeList::const_iterator theCurrRange;
40 };
41 
42 #endif
43