RequestMethod.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_HTTPREQUESTMETHOD_H
10 #define SQUID_HTTPREQUESTMETHOD_H
11 
12 #include "http/forward.h"
13 #include "http/MethodType.h"
14 #include "sbuf/SBuf.h"
15 
16 class SquidConfig;
17 
18 #include <iosfwd>
19 
27 {
28 public:
30  HttpRequestMethod(Http::MethodType const aMethod) : theMethod(aMethod), theImage() {}
31  explicit HttpRequestMethod(const SBuf &);
32 
33  void HttpRequestMethodXXX(char const *); // deprecated old c-string to SBuf converter.
34 
36  theMethod = aMethod.theMethod;
37  theImage = aMethod.theImage;
38  return *this;
39  }
40 
42  theMethod = aMethod;
43  theImage.clear();
44  return *this;
45  }
46 
47  bool operator == (Http::MethodType const & aMethod) const { return theMethod == aMethod; }
48  bool operator == (HttpRequestMethod const & aMethod) const {
49  return theMethod == aMethod.theMethod &&
50  (theMethod != Http::METHOD_OTHER || theImage == aMethod.theImage);
51  }
52 
53  bool operator != (Http::MethodType const & aMethod) const { return theMethod != aMethod; }
54  bool operator != (HttpRequestMethod const & aMethod) const {
55  return !operator==(aMethod);
56  }
57 
60  // TODO: when this operator is used in more than one place,
61  // replace it with HttpRequestMethods::Iterator API
62  // XXX: this interface can create Http::METHOD_OTHER without an image
64  theMethod = (Http::MethodType)(1 + (int)theMethod);
65  return *this;
66  }
67 
73  Http::MethodType id() const { return theMethod; }
74 
76  const SBuf &image() const;
77 
80  bool isHttpSafe() const;
81 
84  bool isIdempotent() const;
85 
90  bool respMaybeCacheable() const;
91 
101  bool shouldInvalidate() const;
102 
103  /* Whether this method invalidates existing cached entries.
104  * Kept for backward-compatibility. This is the old 2.x-3.2 invalidation behaviour.
105  *
106  * NOTE:
107  * purgesOthers differs from shouldInvalidate() in that purgesOthers() returns
108  * true on any methods the MAY invalidate (Squid opts to do so).
109  * shouldInvalidate() only returns true on methods which SHOULD invalidate.
110  */
111  bool purgesOthers() const;
112 
113 private:
116 };
117 
118 inline std::ostream &
119 operator << (std::ostream &os, HttpRequestMethod const &method)
120 {
121  os << method.image();
122  return os;
123 }
124 
125 #endif /* SQUID_HTTPREQUESTMETHOD_H */
126 
SBuf theImage
Used for storing the Http::METHOD_OTHER only. A copy of the parsed method text.
#define assert(EX)
Definition: assert.h:17
Definition: SBuf.h:87
the representation of the configuration. POD.
Definition: SquidConfig.h:68
HttpRequestMethod & operator=(const HttpRequestMethod &aMethod)
Definition: RequestMethod.h:35
void clear()
Definition: SBuf.cc:190
HttpRequestMethod & operator++()
Definition: RequestMethod.h:59
bool shouldInvalidate() const
Http::MethodType theMethod
Method type.
enum Http::_method_t MethodType
bool isHttpSafe() const
bool operator==(Http::MethodType const &aMethod) const
Definition: RequestMethod.h:47
Http::MethodType id() const
Definition: RequestMethod.h:73
const SBuf & image() const
void HttpRequestMethodXXX(char const *)
bool respMaybeCacheable() const
HttpRequestMethod(Http::MethodType const aMethod)
Definition: RequestMethod.h:30
size_t HttpReply *STUB StoreEntry const KeyScope scope const HttpRequestMethod & method
Definition: stub_store.cc:126
std::ostream & operator<<(std::ostream &os, HttpRequestMethod const &method)
bool operator!=(Http::MethodType const &aMethod) const
Definition: RequestMethod.h:53
bool purgesOthers() const
bool isIdempotent() const

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors