]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/Answer.h
Bug 5428: Warn if pkg-config is not found (#1902)
[thirdparty/squid.git] / src / adaptation / Answer.h
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_SRC_ADAPTATION_ANSWER_H
10 #define SQUID_SRC_ADAPTATION_ANSWER_H
11
12 #include "acl/Acl.h"
13 #include "adaptation/forward.h"
14 #include "http/forward.h"
15 #include "sbuf/SBuf.h"
16
17 #include <iosfwd>
18 #include <optional>
19
20 namespace Adaptation
21 {
22
23 /// summarizes adaptation service answer for the noteAdaptationAnswer() API
24 class Answer
25 {
26 public:
27 /// helps interpret other members without a class hierarchy
28 typedef enum {
29 akForward, ///< forward the supplied adapted HTTP message
30 akBlock, ///< block or deny the master xaction; see authority
31 akError, ///< no adapted message will come; see bypassable
32 } Kind;
33
34 static Answer Error(bool final); ///< create an akError answer
35 static Answer Forward(Http::Message *aMsg); ///< create an akForward answer
36 static Answer Block(const SBuf &aRule); ///< create an akBlock answer
37
38 /// creates an Acl::Answer from akBlock answer
39 Acl::Answer blockedToChecklistAnswer() const;
40
41 std::ostream &print(std::ostream &os) const;
42
43 public:
44 Http::MessagePointer message; ///< HTTP request or response to forward
45 std::optional<SBuf> ruleId; ///< ACL (or similar rule) name that blocked forwarding
46 bool final; ///< whether the error, if any, cannot be bypassed
47 Kind kind; ///< the type of the answer
48
49 private:
50 explicit Answer(Kind aKind); ///< use static creators instead
51 };
52
53 inline
54 std::ostream &operator <<(std::ostream &os, const Answer &answer)
55 {
56 return answer.print(os);
57 }
58
59 } // namespace Adaptation
60
61 #endif /* SQUID_SRC_ADAPTATION_ANSWER_H */
62