3 #include "MsgPipeData.h"
4 #include "HttpRequest.h"
6 #include "ICAPClientRespmodPrecache.h"
7 #include "ICAPClient.h"
8 #include "ICAPServiceRep.h"
10 CBDATA_CLASS_INIT(ICAPClientRespmodPrecache
);
12 ICAPClientRespmodPrecache::ICAPClientRespmodPrecache(ICAPServiceRep::Pointer aService
):
13 ICAPClientVector(aService
, "ICAPClientRespmodPrecache"), serverState(NULL
)
17 void ICAPClientRespmodPrecache::startRespMod(ServerStateData
*aServerState
, HttpRequest
*request
, HttpReply
*reply
)
19 serverState
= cbdataReference(aServerState
);
20 startMod(serverState
, request
, reply
);
23 // ICAP client starts sending adapted response
24 // ICAP client has received new HTTP headers (if any) at this point
25 void ICAPClientRespmodPrecache::noteSourceStart(MsgPipe
*p
)
27 debugs(93,3, HERE
<< "ICAPClientRespmodPrecache::noteSourceStart() called");
29 HttpReply
*reply
= dynamic_cast<HttpReply
*>(adapted
->data
->header
);
31 * The ICAP reply MUST have a new HTTP reply header, or else
32 * it is an invalid ICAP message. Invalid ICAP messages should
33 * be handled prior to this point.
35 assert(reply
); // check that ICAP xaction created the right object
36 assert(reply
== adapted
->data
->header
);
39 * Examine the HTTP reply headers to find out if there is an associated
40 * body. We should probably check the ICAP Encapsulated header values
44 bool expect_body
= reply
->expectingBody(virgin
->data
->cause
->method
, dummy
);
46 if (!serverState
->takeAdaptedHeaders(reply
)) // deletes us
50 noteSourceProgress(p
);
55 // ICAP client sends more data
56 void ICAPClientRespmodPrecache::noteSourceProgress(MsgPipe
*p
)
58 debug(93,3)("ICAPClientRespmodPrecache::noteSourceProgress() called\n");
59 //tell ServerStateData to store a fresh portion of the adapted response
63 if (p
->data
->body
->hasContent()) {
64 if (!serverState
->takeAdaptedBody(p
->data
->body
))
67 // HttpStateData::takeAdaptedBody does not detect when we have enough,
68 // so we always notify source that there more buffer space is available
69 if (p
->data
->body
->hasPotentialSpace())
70 adapted
->sendSinkNeed();
75 ICAPClientRespmodPrecache::tellSpaceAvailable()
77 serverState
->icapSpaceAvailable();
81 ICAPClientRespmodPrecache::tellDoneAdapting()
83 serverState
->finishAdapting(); // deletes us
87 ICAPClientRespmodPrecache::tellAbortAdapting()
89 debug(93,3)("ICAPClientReqmodPrecache::tellAbortAdapting() called\n");
90 // tell ClientHttpRequest that we are aborting ICAP processing prematurely
91 serverState
->abortAdapting(); // deletes us