]>
Commit | Line | Data |
---|---|---|
fdc96a39 | 1 | /* |
b8ae064d | 2 | * Copyright (C) 1996-2023 The Squid Software Foundation and contributors |
bbc27441 AJ |
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. | |
fdc96a39 AR |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 93 eCAP Interface */ |
10 | ||
ff9d9458 FC |
11 | #ifndef SQUID_SRC_ADAPTATION_ECAP_XACTIONREP_H |
12 | #define SQUID_SRC_ADAPTATION_ECAP_XACTIONREP_H | |
fdc96a39 | 13 | |
1f3c65fc | 14 | #include "adaptation/ecap/MessageRep.h" |
a22e6cd3 | 15 | #include "adaptation/ecap/ServiceRep.h" |
602d9612 A |
16 | #include "adaptation/Initiate.h" |
17 | #include "adaptation/Message.h" | |
18 | #include "BodyPipe.h" | |
fdc96a39 AR |
19 | #include <libecap/common/forward.h> |
20 | #include <libecap/common/memory.h> | |
21 | #include <libecap/host/xaction.h> | |
22 | #include <libecap/adapter/xaction.h> | |
23 | ||
af6a12ee AJ |
24 | namespace Adaptation |
25 | { | |
e1381638 AJ |
26 | namespace Ecap |
27 | { | |
fdc96a39 AR |
28 | |
29 | /* The eCAP xaction representative maintains information about a single eCAP | |
26ac0430 | 30 | xaction that Squid communicates with. One eCAP module may register many |
fdc96a39 AR |
31 | eCAP xactions. */ |
32 | class XactionRep : public Adaptation::Initiate, public libecap::host::Xaction, | |
f53969cc | 33 | public BodyConsumer, public BodyProducer |
fdc96a39 | 34 | { |
337b9aa4 | 35 | CBDATA_CHILD(XactionRep); |
5c2f68b7 | 36 | |
fdc96a39 | 37 | public: |
63df1d28 | 38 | XactionRep(Http::Message *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp, const Adaptation::ServicePointer &service); |
337b9aa4 | 39 | ~XactionRep() override; |
fdc96a39 | 40 | |
f1a768b2 AR |
41 | typedef libecap::shared_ptr<libecap::adapter::Xaction> AdapterXaction; |
42 | void master(const AdapterXaction &aMaster); // establish a link | |
fdc96a39 AR |
43 | |
44 | // libecap::host::Xaction API | |
337b9aa4 AR |
45 | const libecap::Area option(const libecap::Name &name) const override; |
46 | void visitEachOption(libecap::NamedValueVisitor &visitor) const override; | |
47 | libecap::Message &virgin() override; | |
48 | const libecap::Message &cause() override; | |
49 | libecap::Message &adapted() override; | |
50 | void useVirgin() override; | |
51 | void useAdapted(const libecap::shared_ptr<libecap::Message> &msg) override; | |
52 | void blockVirgin() override; | |
53 | void adaptationDelayed(const libecap::Delay &) override; | |
54 | void adaptationAborted() override; | |
55 | void resume() override; | |
56 | void vbDiscard() override; | |
57 | void vbMake() override; | |
58 | void vbStopMaking() override; | |
59 | void vbMakeMore() override; | |
60 | libecap::Area vbContent(libecap::size_type offset, libecap::size_type size) override; | |
61 | void vbContentShift(libecap::size_type size) override; | |
62 | void noteAbContentDone(bool atEnd) override; | |
63 | void noteAbContentAvailable() override; | |
4d0854d4 | 64 | |
fdc96a39 | 65 | // BodyProducer API |
337b9aa4 AR |
66 | void noteMoreBodySpaceAvailable(RefCount<BodyPipe> bp) override; |
67 | void noteBodyConsumerAborted(RefCount<BodyPipe> bp) override; | |
fdc96a39 AR |
68 | |
69 | // BodyConsumer API | |
337b9aa4 AR |
70 | void noteMoreBodyDataAvailable(RefCount<BodyPipe> bp) override; |
71 | void noteBodyProductionEnded(RefCount<BodyPipe> bp) override; | |
72 | void noteBodyProducerAborted(RefCount<BodyPipe> bp) override; | |
fdc96a39 | 73 | |
5c2f68b7 | 74 | // Initiate API |
337b9aa4 | 75 | void noteInitiatorAborted() override; |
fdc96a39 AR |
76 | |
77 | // AsyncJob API (via Initiate) | |
337b9aa4 AR |
78 | void start() override; |
79 | bool doneAll() const override; | |
80 | void swanSong() override; | |
81 | const char *status() const override; | |
fdc96a39 AR |
82 | |
83 | protected: | |
a22e6cd3 AR |
84 | Service &service(); |
85 | ||
4d0854d4 AR |
86 | Adaptation::Message &answer(); |
87 | ||
e1e90d26 AR |
88 | void sinkVb(const char *reason); |
89 | void preserveVb(const char *reason); | |
90 | void forgetVb(const char *reason); | |
91 | ||
8679e6c2 AR |
92 | void moveAbContent(); |
93 | ||
63df1d28 | 94 | void updateHistory(Http::Message *adapted); |
fdc96a39 | 95 | void terminateMaster(); |
4d0854d4 | 96 | void scheduleStop(const char *reason); |
63df1d28 | 97 | void updateSources(Http::Message *adapted); |
fdc96a39 | 98 | |
22fff3bf AR |
99 | const libecap::Area clientIpValue() const; |
100 | const libecap::Area usernameValue() const; | |
5038f9d8 | 101 | const libecap::Area masterxSharedValue(const libecap::Name &name) const; |
71be37e0 CT |
102 | /// Return the adaptation meta header value for the given header "name" |
103 | const libecap::Area metaValue(const libecap::Name &name) const; | |
104 | /// Return the adaptation meta headers and their values | |
105 | void visitEachMetaHeader(libecap::NamedValueVisitor &visitor) const; | |
22fff3bf | 106 | |
0a720258 AR |
107 | void doResume(); |
108 | ||
fdc96a39 | 109 | private: |
f1a768b2 | 110 | AdapterXaction theMaster; // the actual adaptation xaction we represent |
a22e6cd3 | 111 | Adaptation::ServicePointer theService; ///< xaction's adaptation service |
fdc96a39 | 112 | |
f1a768b2 AR |
113 | MessageRep theVirginRep; |
114 | MessageRep *theCauseRep; | |
4d0854d4 | 115 | |
f1a768b2 AR |
116 | typedef libecap::shared_ptr<libecap::Message> MessagePtr; |
117 | MessagePtr theAnswerRep; | |
fdc96a39 | 118 | |
ea76d91e | 119 | typedef enum { opUndecided, opOn, opComplete, opNever } OperationState; |
e1e90d26 | 120 | OperationState makingVb; //< delivering virgin body from pipe to adapter |
f1a768b2 | 121 | OperationState proxyingAb; // delivering adapted body from adapter to core |
3ff65596 | 122 | int adaptHistoryId; ///< adaptation history slot reservation |
e1e90d26 | 123 | bool vbProductionFinished; // whether there can be no more vb bytes |
7477a343 AR |
124 | bool abProductionFinished; // whether adapter has finished producing ab |
125 | bool abProductionAtEnd; // whether adapter produced a complete ab | |
af0ded40 | 126 | AccessLogEntry::Pointer al; ///< Master transaction AccessLogEntry |
fdc96a39 AR |
127 | }; |
128 | ||
129 | } // namespace Ecap | |
574b508c | 130 | } // namespace Adaptation |
fdc96a39 | 131 | |
ff9d9458 | 132 | #endif /* SQUID_SRC_ADAPTATION_ECAP_XACTIONREP_H */ |
f53969cc | 133 |