#include "squid.h"
#include "BodyPipe.h"
+#include "TextException.h"
CBDATA_CLASS_INIT(BodyPipe);
BodyPipe::enableAutoConsumption() {
mustAutoConsume = true;
debugs(91,5, HERE << "enabled auto consumption" << status());
- if (!theConsumer && theBuf.hasContent()){
- theConsumer = new BodySink;
- scheduleBodyDataNotification();
- }
+ if (!theConsumer && theBuf.hasContent())
+ startAutoConsumption();
+}
+
+// start auto consumption by creating body sink
+void
+BodyPipe::startAutoConsumption()
+{
+ Must(mustAutoConsume);
+ Must(!theConsumer);
+ theConsumer = new BodySink;
+ debugs(91,7, HERE << "starting auto consumption" << status());
+ scheduleBodyDataNotification();
}
MemBuf &
thePutSize += size;
debugs(91,7, HERE << "added " << size << " bytes" << status());
+ if (mustAutoConsume && !theConsumer && size > 0)
+ startAutoConsumption();
+
// We should not consume here even if mustAutoConsume because the
// caller may not be ready for the data to be consumed during this call.
scheduleBodyDataNotification();
void
BodyPipe::scheduleBodyDataNotification()
{
- if (theConsumer || mustAutoConsume) {
+ if (theConsumer) {
AsyncCall::Pointer call = asyncCall(91, 7,
"BodyConsumer::noteMoreBodyDataAvailable",
BodyConsumerDialer(theConsumer,
void postConsume(size_t size);
void postAppend(size_t size);
+ void startAutoConsumption(); // delayed start of enabled consumption
+
private:
int64_t theBodySize; // expected total content length, if known
Producer *theProducer; // content producer, if any