RequestMethod.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 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
16class SquidConfig;
17
18#include <iosfwd>
19
27{
28public:
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;
38 return *this;
39 }
40
42 explicit operator bool() const { return theMethod != Http::METHOD_NONE; }
43
44 bool operator == (Http::MethodType const & aMethod) const { return theMethod == aMethod; }
45 bool operator == (HttpRequestMethod const & aMethod) const {
46 return theMethod == aMethod.theMethod &&
48 }
49
50 bool operator != (Http::MethodType const & aMethod) const { return theMethod != aMethod; }
51 bool operator != (HttpRequestMethod const & aMethod) const {
52 return !operator==(aMethod);
53 }
54
57 // TODO: when this operator is used in more than one place,
58 // replace it with HttpRequestMethods::Iterator API
59 // XXX: this interface can create Http::METHOD_OTHER without an image
62 return *this;
63 }
64
70 Http::MethodType id() const { return theMethod; }
71
73 const SBuf &image() const;
74
77 bool isHttpSafe() const;
78
81 bool isIdempotent() const;
82
87 bool respMaybeCacheable() const;
88
98 bool shouldInvalidate() const;
99
100 /* Whether this method invalidates existing cached entries.
101 * Kept for backward-compatibility. This is the old 2.x-3.2 invalidation behaviour.
102 *
103 * NOTE:
104 * purgesOthers differs from shouldInvalidate() in that purgesOthers() returns
105 * true on any methods the MAY invalidate (Squid opts to do so).
106 * shouldInvalidate() only returns true on methods which SHOULD invalidate.
107 */
108 bool purgesOthers() const;
109
110private:
113};
114
115inline std::ostream &
116operator << (std::ostream &os, HttpRequestMethod const &method)
117{
118 os << method.image();
119 return os;
120}
121
122#endif /* SQUID_HTTPREQUESTMETHOD_H */
123
std::ostream & operator<<(std::ostream &os, HttpRequestMethod const &method)
#define assert(EX)
Definition: assert.h:17
bool purgesOthers() const
HttpRequestMethod & operator=(Http::MethodType const aMethod)
Definition: RequestMethod.h:35
SBuf theImage
Used for storing the Http::METHOD_OTHER only. A copy of the parsed method text.
HttpRequestMethod & operator++()
Definition: RequestMethod.h:56
bool operator==(Http::MethodType const &aMethod) const
Definition: RequestMethod.h:44
bool shouldInvalidate() const
bool isHttpSafe() const
void HttpRequestMethodXXX(char const *)
const SBuf & image() const
bool respMaybeCacheable() const
HttpRequestMethod(Http::MethodType const aMethod)
Definition: RequestMethod.h:30
bool isIdempotent() const
bool operator!=(Http::MethodType const &aMethod) const
Definition: RequestMethod.h:50
Http::MethodType theMethod
Method type.
Http::MethodType id() const
Definition: RequestMethod.h:70
Definition: SBuf.h:94
void clear()
Definition: SBuf.cc:175
the representation of the configuration. POD.
Definition: SquidConfig.h:79
Definition: forward.h:18
enum Http::_method_t MethodType
@ METHOD_NONE
Definition: MethodType.h:22
@ METHOD_OTHER
Definition: MethodType.h:93
@ METHOD_ENUM_END
Definition: MethodType.h:94

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors