]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Synced with libecap changes.
authorAlex Rousskov <rousskov@measurement-factory.com>
Fri, 16 May 2008 00:38:30 +0000 (18:38 -0600)
committerAlex Rousskov <rousskov@measurement-factory.com>
Fri, 16 May 2008 00:38:30 +0000 (18:38 -0600)
Polished while implementing and testing MessageRep.

src/eCAP/XactionRep.cc
src/eCAP/XactionRep.h

index b45c622d48c188196060e5166615a179fd04b302..6426d4da35e8eac2959e4a6cb22ccc699390603a 100644 (file)
@@ -17,14 +17,18 @@ Ecap::XactionRep::XactionRep(Adaptation::Initiator *anInitiator,
     AsyncJob("Ecap::XactionRep"),
     Adaptation::Initiate("Ecap::XactionRep", anInitiator, aService),
     theVirgin(virginHeader), theCause(virginCause),
-    theVirginRep(theVirgin), theCauseRep(theCause),
-    theAnswerRep(theAnswer)
+    theVirginRep(theVirgin, NULL), theCauseRep(NULL),
+    theAnswerRep(NULL)
 {
+    if (virginCause)
+        theCauseRep = new MessageRep(theCause, NULL);
 }
 
 Ecap::XactionRep::~XactionRep()
 {
     assert(!theMaster);
+    delete theCauseRep;
+    delete theAnswerRep;
 }
 
 void
@@ -60,13 +64,13 @@ Ecap::XactionRep::terminateMaster()
 }
 
 libecap::Message &
-Ecap::XactionRep::virginMessage()
+Ecap::XactionRep::virgin()
 {
     return theVirginRep;
 }
 
-libecap::Message &
-Ecap::XactionRep::virginCause()
+const libecap::Message *
+Ecap::XactionRep::cause()
 {
     return theCauseRep;
 }
@@ -75,30 +79,39 @@ void
 Ecap::XactionRep::useVirgin()
 {
     theMaster.reset();
-    theVirgin.copyTo(theAnswer);
+    Adaptation::Message::ShortCircuit(theVirgin, theAnswer);
+    Must(!theVirgin.body_pipe == !theAnswer.body_pipe);
     sendAnswer(theAnswer.header);
 }
 
 void 
-Ecap::XactionRep::cloneVirgin()
+Ecap::XactionRep::adaptVirgin()
 {
-    theVirgin.copyTo(theAnswer);
+    // XXX: check state everywhere
+    Must(!theAnswerRep);
+    Must(!theAnswer.header);
+    Must(!theAnswer.body_pipe);
+    theAnswer.set(theVirgin.header->clone());
+       theAnswerRep = new MessageRep(theAnswer, this);
+    Must(!theAnswer.body_pipe);
 }
 
 void 
-Ecap::XactionRep::makeAdaptedRequest()
+Ecap::XactionRep::adaptNewRequest()
 {
     theAnswer.set(new HttpRequest);
+       theAnswerRep = new MessageRep(theAnswer, this);
 }
 
 void 
-Ecap::XactionRep::makeAdaptedResponse()
+Ecap::XactionRep::adaptNewResponse()
 {
     theAnswer.set(new HttpReply);
+       theAnswerRep = new MessageRep(theAnswer, this);
 }
 
-libecap::Message &
-Ecap::XactionRep::adaptedMessage()
+libecap::Message *
+Ecap::XactionRep::adapted()
 {
     return theAnswerRep;
 }
index d01db0413fc660db5d70796abcfd9cf7fbf1520f..58a48ad44277490ed090526e26b5fbc7812d5919 100644 (file)
@@ -32,15 +32,15 @@ public:
        void master(const AdapterXaction &aMaster); // establish a link
 
     // libecap::host::Xaction API
-    virtual libecap::Message &virginMessage() ; // request or response
-    virtual libecap::Message &virginCause() ; // request for the above response
-    virtual void useVirgin() ;  // final answer: no adaptation
-    virtual void cloneVirgin() ; // adapted message starts as virgin
-    virtual void makeAdaptedRequest() ; // make fresh adapted request
-    virtual void makeAdaptedResponse() ; // make fresh adapted response
-    virtual libecap::Message &adaptedMessage() ; // request or response
-    virtual void useAdapted() ; // final answer: adapted msg is ready
-    virtual void useNone() ; // final answer: no answer
+    virtual libecap::Message &virgin(); // request or response
+    virtual const libecap::Message *cause(); // request for the above response
+    virtual void useVirgin();  // final answer: no adaptation
+    virtual void adaptVirgin(); // adapted message starts as virgin
+    virtual void adaptNewRequest(); // make fresh adapted request
+    virtual void adaptNewResponse(); // make fresh adapted response
+    virtual libecap::Message *adapted(); // request or response
+    virtual void useAdapted(); // final answer: adapted msg is ready
+    virtual void useNone(); // final answer: no answer
 
     // BodyProducer API
     virtual void noteMoreBodySpaceAvailable(RefCount<BodyPipe> bp);
@@ -69,8 +69,8 @@ private:
        Adaptation::Message theCause;
        Adaptation::Message theAnswer;
        MessageRep theVirginRep;
-       MessageRep theCauseRep;
-       MessageRep theAnswerRep;
+       MessageRep *theCauseRep;
+       MessageRep *theAnswerRep;
 
        CBDATA_CLASS2(XactionRep);
 };