HttpHeaderRange.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 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 
18 class HttpReply;
19 class Packable;
20 
21 /* http byte-range-spec */
22 
24 {
26 
27 public:
29  static int64_t const UnknownPosition;
30 
32  static HttpHdrRangeSpec *Create(const char *field, int fieldLen);
33 
34  bool parseInit(const char *field, int flen);
35  int canonize(int64_t clen);
36  void outputInfo( char const *note) const;
37  void packInto(Packable * p) const;
38  bool mergeWith(const HttpHdrRangeSpec * donor);
39  int64_t offset;
40  int64_t length;
41 };
42 
49 {
51 
52 public:
53  static size_t ParsedCount;
54  /* Http Range Header Field */
55  static HttpHdrRange *ParseCreate(const String * range_spec);
56 
57  HttpHdrRange();
58  HttpHdrRange(HttpHdrRange const &);
59  ~HttpHdrRange();
61 
62  typedef std::vector<HttpHdrRangeSpec *>::iterator iterator;
63  typedef std::vector<HttpHdrRangeSpec *>::const_iterator const_iterator;
64  iterator begin();
65  const_iterator begin () const;
66  iterator end();
67  const_iterator end() const;
68 
69  /* adjust specs after the length is known */
70  int canonize(int64_t);
71  int canonize(HttpReply *rep);
72  /* returns true if ranges are valid; inits HttpHdrRange */
73  bool parseInit(const String * range_spec);
74  void packInto(Packable * p) const;
75  /* other */
76  bool isComplex() const;
77  bool willBeComplex() const;
78  int64_t firstOffset() const;
79  int64_t lowestOffset(int64_t) const;
80  bool offsetLimitExceeded(const int64_t limit) const;
81  bool contains(const HttpHdrRangeSpec& r) const;
82  std::vector<HttpHdrRangeSpec *> specs;
83 
84 private:
85  void getCanonizedSpecs (std::vector<HttpHdrRangeSpec *> &copy);
86  void merge (std::vector<HttpHdrRangeSpec *> &basis);
87  int64_t clen;
88 };
89 
94 {
95 
96 public:
99  const HttpHdrRangeSpec *currentSpec() const;
100  void updateSpec();
101  int64_t debt() const;
102  void debt(int64_t);
103  int64_t debt_size; /* bytes left to send from the current spec */
104  String boundary; /* boundary for multipart responses */
105  bool valid;
106 };
107 
108 #endif /* SQUID_HTTPHEADERRANGE_H */
109 
void getCanonizedSpecs(std::vector< HttpHdrRangeSpec * > &copy)
bool mergeWith(const HttpHdrRangeSpec *donor)
int64_t debt() const
std::vector< HttpHdrRangeSpec * >::iterator iterator
MEMPROXY_CLASS(HttpHdrRange)
static size_t ParsedCount
Definition: Range.h:18
HttpHdrRange & operator=(HttpHdrRange const &)
char * p
Definition: membanger.c:43
static int64_t const UnknownPosition
void outputInfo(char const *note) const
bool willBeComplex() const
void merge(std::vector< HttpHdrRangeSpec * > &basis)
int64_t firstOffset() const
iterator end()
MEMPROXY_CLASS(HttpHdrRangeSpec)
int64_t lowestOffset(int64_t) const
bool offsetLimitExceeded(const int64_t limit) const
void packInto(Packable *p) const
iterator begin()
bool parseInit(const char *field, int flen)
Definition: HttpHdrRange.cc:64
bool contains(const HttpHdrRangeSpec &r) const
static HttpHdrRange * ParseCreate(const String *range_spec)
std::vector< HttpHdrRangeSpec * > specs
void packInto(Packable *p) const
int canonize(int64_t clen)
static HttpHdrRangeSpec * Create(const char *field, int fieldLen)
Definition: HttpHdrRange.cc:53
bool isComplex() const
bool parseInit(const String *range_spec)
Range< int64_t, uint64_t > HttpRange
const HttpHdrRangeSpec * currentSpec() const
std::vector< HttpHdrRangeSpec * >::const_iterator const_iterator
HttpHdrRange::iterator end
HttpHdrRange::iterator pos
int canonize(int64_t)

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors