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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors