]>
Commit | Line | Data |
---|---|---|
fdc96a39 | 1 | /* |
bde978a6 | 2 | * Copyright (C) 1996-2015 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 | ||
fdc96a39 AR |
11 | #ifndef SQUID_ECAP_XACTION_REP_H |
12 | #define SQUID_ECAP_XACTION_REP_H | |
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 | { |
5c2f68b7 AJ |
35 | CBDATA_CLASS(XactionRep); |
36 | ||
fdc96a39 | 37 | public: |
af0ded40 | 38 | XactionRep(HttpMsg *virginHeader, HttpRequest *virginCause, AccessLogEntry::Pointer &alp, const Adaptation::ServicePointer &service); |
fdc96a39 AR |
39 | virtual ~XactionRep(); |
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 | |
22fff3bf AR |
45 | virtual const libecap::Area option(const libecap::Name &name) const; |
46 | virtual void visitEachOption(libecap::NamedValueVisitor &visitor) const; | |
4d0854d4 AR |
47 | virtual libecap::Message &virgin(); |
48 | virtual const libecap::Message &cause(); | |
49 | virtual libecap::Message &adapted(); | |
50 | virtual void useVirgin(); | |
51 | virtual void useAdapted(const libecap::shared_ptr<libecap::Message> &msg); | |
3af10ac0 | 52 | virtual void blockVirgin(); |
4d0854d4 AR |
53 | virtual void adaptationDelayed(const libecap::Delay &); |
54 | virtual void adaptationAborted(); | |
0a720258 | 55 | virtual void resume(); |
a96661a8 | 56 | virtual void vbDiscard(); |
8679e6c2 AR |
57 | virtual void vbMake(); |
58 | virtual void vbStopMaking(); | |
59 | virtual void vbMakeMore(); | |
a96661a8 | 60 | virtual libecap::Area vbContent(libecap::size_type offset, libecap::size_type size); |
8679e6c2 AR |
61 | virtual void vbContentShift(libecap::size_type size); |
62 | virtual void noteAbContentDone(bool atEnd); | |
63 | virtual void noteAbContentAvailable(); | |
4d0854d4 | 64 | |
fdc96a39 AR |
65 | // BodyProducer API |
66 | virtual void noteMoreBodySpaceAvailable(RefCount<BodyPipe> bp); | |
67 | virtual void noteBodyConsumerAborted(RefCount<BodyPipe> bp); | |
68 | ||
69 | // BodyConsumer API | |
70 | virtual void noteMoreBodyDataAvailable(RefCount<BodyPipe> bp); | |
71 | virtual void noteBodyProductionEnded(RefCount<BodyPipe> bp); | |
72 | virtual void noteBodyProducerAborted(RefCount<BodyPipe> bp); | |
73 | ||
5c2f68b7 | 74 | // Initiate API |
fdc96a39 AR |
75 | virtual void noteInitiatorAborted(); |
76 | ||
77 | // AsyncJob API (via Initiate) | |
78 | virtual void start(); | |
4d0854d4 AR |
79 | virtual bool doneAll() const; |
80 | virtual void swanSong(); | |
fdc96a39 AR |
81 | virtual const char *status() const; |
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 | ||
aaf0559d | 94 | void updateHistory(HttpMsg *adapted); |
fdc96a39 | 95 | void terminateMaster(); |
4d0854d4 | 96 | void scheduleStop(const char *reason); |
fdc96a39 | 97 | |
22fff3bf AR |
98 | const libecap::Area clientIpValue() const; |
99 | const libecap::Area usernameValue() const; | |
5038f9d8 | 100 | const libecap::Area masterxSharedValue(const libecap::Name &name) const; |
71be37e0 CT |
101 | /// Return the adaptation meta header value for the given header "name" |
102 | const libecap::Area metaValue(const libecap::Name &name) const; | |
103 | /// Return the adaptation meta headers and their values | |
104 | void visitEachMetaHeader(libecap::NamedValueVisitor &visitor) const; | |
22fff3bf | 105 | |
0a720258 AR |
106 | void doResume(); |
107 | ||
fdc96a39 | 108 | private: |
f1a768b2 | 109 | AdapterXaction theMaster; // the actual adaptation xaction we represent |
a22e6cd3 | 110 | Adaptation::ServicePointer theService; ///< xaction's adaptation service |
fdc96a39 | 111 | |
f1a768b2 AR |
112 | MessageRep theVirginRep; |
113 | MessageRep *theCauseRep; | |
4d0854d4 | 114 | |
f1a768b2 AR |
115 | typedef libecap::shared_ptr<libecap::Message> MessagePtr; |
116 | MessagePtr theAnswerRep; | |
fdc96a39 | 117 | |
ea76d91e | 118 | typedef enum { opUndecided, opOn, opComplete, opNever } OperationState; |
e1e90d26 | 119 | OperationState makingVb; //< delivering virgin body from pipe to adapter |
f1a768b2 | 120 | OperationState proxyingAb; // delivering adapted body from adapter to core |
3ff65596 | 121 | int adaptHistoryId; ///< adaptation history slot reservation |
e1e90d26 | 122 | bool vbProductionFinished; // whether there can be no more vb bytes |
7477a343 AR |
123 | bool abProductionFinished; // whether adapter has finished producing ab |
124 | bool abProductionAtEnd; // whether adapter produced a complete ab | |
af0ded40 | 125 | AccessLogEntry::Pointer al; ///< Master transaction AccessLogEntry |
fdc96a39 AR |
126 | }; |
127 | ||
128 | } // namespace Ecap | |
574b508c | 129 | } // namespace Adaptation |
fdc96a39 AR |
130 | |
131 | #endif /* SQUID_ECAP_XACTION_REP_H */ | |
f53969cc | 132 |