/*
- * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2022 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
icapReply = new HttpReply;
icapReply->protoPrefix = "ICAP/"; // TODO: make an IcapReply class?
- debugs(93,7, HERE << "initialized." << status());
+ debugs(93,7, "initialized." << status());
}
// initiator wants us to start
disableRetries();
disableRepeats("ICAP service is not available");
- debugs(93, 7, HERE << "will not wait for the service to be available" <<
+ debugs(93, 7, "will not wait for the service to be available" <<
status());
throw TexcHere("ICAP service is not available");
comment = "to be available";
}
- debugs(93, 7, HERE << "will wait for the service " << comment << status());
+ debugs(93, 7, "will wait for the service " << comment << status());
state.serviceWaiting = true; // after callWhenReady() which may throw
state.waitedForService = true;
}
requestBuf.init();
makeRequestHeaders(requestBuf);
- debugs(93, 9, HERE << "will write" << status() << ":\n" <<
+ debugs(93, 9, "will write" << status() << ":\n" <<
(requestBuf.terminate(), requestBuf.content()));
// write headers
void Adaptation::Icap::ModXact::handleCommWrote(size_t sz)
{
- debugs(93, 5, HERE << "Wrote " << sz << " bytes");
+ debugs(93, 5, "Wrote " << sz << " bytes");
if (state.writing == State::writingHeaders)
handleCommWroteHeaders();
void Adaptation::Icap::ModXact::writeMore()
{
- debugs(93, 5, HERE << "checking whether to write more" << status());
+ debugs(93, 5, "checking whether to write more" << status());
if (writer != NULL) // already writing something
return;
void Adaptation::Icap::ModXact::writePreviewBody()
{
- debugs(93, 8, HERE << "will write Preview body from " <<
+ debugs(93, 8, "will write Preview body from " <<
virgin.body_pipe << status());
Must(state.writing == State::writingPreview);
Must(virgin.body_pipe != NULL);
else
stopWriting(true); // ICAP server reply implies no post-preview writing
- debugs(93, 6, HERE << "decided on writing after " << kind << " preview" <<
+ debugs(93, 6, "decided on writing after " << kind << " preview" <<
status());
}
writeSomeBody("prime virgin body", size);
if (virginBodyEndReached(virginBodyWriting)) {
- debugs(93, 5, HERE << "wrote entire body");
+ debugs(93, 5, "wrote entire body");
stopWriting(true);
}
}
{
Must(!writer && state.writing < state.writingAlmostDone);
Must(virgin.body_pipe != NULL);
- debugs(93, 8, HERE << "will write up to " << size << " bytes of " <<
+ debugs(93, 8, "will write up to " << size << " bytes of " <<
label);
MemBuf writeBuf; // TODO: suggest a min size based on size and lastChunk
const size_t chunkSize = min(writableSize, size);
if (chunkSize) {
- debugs(93, 7, HERE << "will write " << chunkSize <<
+ debugs(93, 7, "will write " << chunkSize <<
"-byte chunk of " << label);
openChunk(writeBuf, chunkSize, false);
virginBodyWriting.progress(chunkSize);
virginConsume();
} else {
- debugs(93, 7, HERE << "has no writable " << label << " content");
+ debugs(93, 7, "has no writable " << label << " content");
}
const bool wroteEof = virginBodyEndReached(virginBodyWriting);
}
if (lastChunk) {
- debugs(93, 8, HERE << "will write last-chunk of " << label);
+ debugs(93, 8, "will write last-chunk of " << label);
addLastRequestChunk(writeBuf);
}
- debugs(93, 7, HERE << "will write " << writeBuf.contentSize()
+ debugs(93, 7, "will write " << writeBuf.contentSize()
<< " raw bytes of " << label);
if (writeBuf.hasContent()) {
void Adaptation::Icap::ModXact::virginConsume()
{
- debugs(93, 9, HERE << "consumption guards: " << !virgin.body_pipe << isRetriable <<
+ debugs(93, 9, "consumption guards: " << !virgin.body_pipe << isRetriable <<
isRepeatable << canStartBypass << protectGroupBypass);
if (!virgin.body_pipe)
// down. Not postponing may increase the number of ICAP errors
// if the ICAP service fails. We may also use "potential" space to
// postpone more aggressively. Should the trade-off be configurable?
- debugs(93, 8, HERE << "postponing consumption from " << bp.status());
+ debugs(93, 8, "postponing consumption from " << bp.status());
return;
}
const uint64_t end = virginConsumed + have;
uint64_t offset = end;
- debugs(93, 9, HERE << "max virgin consumption offset=" << offset <<
+ debugs(93, 9, "max virgin consumption offset=" << offset <<
" acts " << virginBodyWriting.active() << virginBodySending.active() <<
" consumed=" << virginConsumed <<
" from " << virgin.body_pipe->status());
Must(virginConsumed <= offset && offset <= end);
if (const size_t size = static_cast<size_t>(offset - virginConsumed)) {
- debugs(93, 8, HERE << "consuming " << size << " out of " << have <<
+ debugs(93, 8, "consuming " << size << " out of " << have <<
" virgin body bytes");
bp.consume(size);
virginConsumed += size;
if (writer != NULL) {
if (nicely) {
- debugs(93, 7, HERE << "will wait for the last write" << status());
+ debugs(93, 7, "will wait for the last write" << status());
state.writing = State::writingAlmostDone; // may already be set
checkConsuming();
return;
}
- debugs(93, 3, HERE << "will NOT wait for the last write" << status());
+ debugs(93, 3, "will NOT wait for the last write" << status());
// Comm does not have an interface to clear the writer callback nicely,
// but without clearing the writer we cannot recycle the connection.
ignoreLastWrite = true;
}
- debugs(93, 7, HERE << "will no longer write" << status());
+ debugs(93, 7, "will no longer write" << status());
if (virginBodyWriting.active()) {
virginBodyWriting.disable();
virginConsume();
if (!virginBodySending.active())
return;
- debugs(93, 7, HERE << "will no longer backup" << status());
+ debugs(93, 7, "will no longer backup" << status());
virginBodySending.disable();
virginConsume();
}
void Adaptation::Icap::ModXact::readMore()
{
if (reader != NULL || doneReading()) {
- debugs(93,3,HERE << "returning from readMore because reader or doneReading()");
+ debugs(93,3, "returning from readMore because reader or doneReading()");
return;
}
// do not fill readBuf if we have no space to store the result
if (adapted.body_pipe != NULL &&
!adapted.body_pipe->buf().hasPotentialSpace()) {
- debugs(93,3,HERE << "not reading because ICAP reply pipe is full");
+ debugs(93,3, "not reading because ICAP reply pipe is full");
return;
}
if (readBuf.length() < SQUID_TCP_SO_RCVBUF)
scheduleRead();
else
- debugs(93,3,HERE << "cannot read with a full buffer");
+ debugs(93,3, "cannot read with a full buffer");
}
// comm module read a portion of the ICAP response for us
Must(virginBodySending.active());
const size_t sizeMax = virginContentSize(virginBodySending);
- debugs(93,5, HERE << "will echo up to " << sizeMax << " bytes from " <<
+ debugs(93,5, "will echo up to " << sizeMax << " bytes from " <<
virgin.body_pipe->status());
- debugs(93,5, HERE << "will echo up to " << sizeMax << " bytes to " <<
+ debugs(93,5, "will echo up to " << sizeMax << " bytes to " <<
adapted.body_pipe->status());
if (sizeMax > 0) {
const size_t size = adapted.body_pipe->putMoreData(virginContentData(virginBodySending), sizeMax);
- debugs(93,5, HERE << "echoed " << size << " out of " << sizeMax <<
+ debugs(93,5, "echoed " << size << " out of " << sizeMax <<
" bytes");
virginBodySending.progress(size);
disableRepeats("echoed content");
}
if (virginBodyEndReached(virginBodySending)) {
- debugs(93, 5, HERE << "echoed all" << status());
+ debugs(93, 5, "echoed all" << status());
stopSending(true);
} else {
- debugs(93, 5, HERE << "has " <<
+ debugs(93, 5, "has " <<
virgin.body_pipe->buf().contentSize() << " bytes " <<
"and expects more to echo" << status());
// TODO: timeout if virgin or adapted pipes are broken
// stop (or do not start) sending adapted message body
void Adaptation::Icap::ModXact::stopSending(bool nicely)
{
- debugs(93, 7, HERE << "Enter stop sending ");
+ debugs(93, 7, "Enter stop sending ");
if (doneSending())
return;
- debugs(93, 7, HERE << "Proceed with stop sending ");
+ debugs(93, 7, "Proceed with stop sending ");
if (state.sending != State::sendingUndecided) {
- debugs(93, 7, HERE << "will no longer send" << status());
+ debugs(93, 7, "will no longer send" << status());
if (adapted.body_pipe != NULL) {
virginBodySending.disable();
// we may leave debts if we were echoing and the virgin
stopProducingFor(adapted.body_pipe, nicely && !leftDebts);
}
} else {
- debugs(93, 7, HERE << "will not start sending" << status());
+ debugs(93, 7, "will not start sending" << status());
Must(!adapted.body_pipe);
}
if (!virgin.body_pipe || !state.doneConsumingVirgin())
return;
- debugs(93, 7, HERE << "will stop consuming" << status());
+ debugs(93, 7, "will stop consuming" << status());
stopConsumingFrom(virgin.body_pipe);
}
}
try {
- debugs(93, 3, HERE << "bypassing " << inCall << " exception: " <<
+ debugs(93, 3, "bypassing " << inCall << " exception: " <<
e.what() << ' ' << status());
bypassFailure();
} catch (const TextException &bypassTe) {
reuseConnection = false; // be conservative
cancelRead(); // may not work; and we cannot stop connecting either
if (!doneWithIo())
- debugs(93, 7, HERE << "Warning: bypass failed to stop I/O" << status());
+ debugs(93, 7, "Warning: bypass failed to stop I/O" << status());
}
service().noteFailure(); // we are bypassing, but this is still a failure
void Adaptation::Icap::ModXact::disableBypass(const char *reason, bool includingGroupBypass)
{
if (canStartBypass) {
- debugs(93,7, HERE << "will never start bypass because " << reason);
+ debugs(93,7, "will never start bypass because " << reason);
canStartBypass = false;
}
if (protectGroupBypass && includingGroupBypass) {
- debugs(93,7, HERE << "not protecting group bypass because " << reason);
+ debugs(93,7, "not protecting group bypass because " << reason);
protectGroupBypass = false;
}
}
Must(state.parsingHeaders());
if (state.parsing == State::psIcapHeader) {
- debugs(93, 5, HERE << "parse ICAP headers");
+ debugs(93, 5, "parse ICAP headers");
parseIcapHead();
}
if (state.parsing == State::psHttpHeader) {
- debugs(93, 5, HERE << "parse HTTP headers");
+ debugs(93, 5, "parse HTTP headers");
parseHttpHead();
}
static SBuf close("close", 5);
if (httpHeaderHasConnDir(&icapReply->header, close)) {
- debugs(93, 5, HERE << "found connection close");
+ debugs(93, 5, "found connection close");
reuseConnection = false;
}
if (state.writing == State::writingPaused) {
Must(preview.enabled());
Must(state.allowedPreview206);
- debugs(93, 7, HERE << "206 inside preview");
+ debugs(93, 7, "206 inside preview");
} else {
Must(state.writing > State::writingPaused);
Must(state.allowedPostview206);
- debugs(93, 7, HERE << "206 outside preview");
+ debugs(93, 7, "206 outside preview");
}
state.parsing = State::psHttpHeader;
state.sending = State::sendingAdapted;
// TODO: use Http::Message::clone()!
Http::Message *oldHead = virgin.header;
- debugs(93, 7, HERE << "cloning virgin message " << oldHead);
+ debugs(93, 7, "cloning virgin message " << oldHead);
MemBuf httpBuf;
httpBuf.clean();
- debugs(93, 7, HERE << "cloned virgin message " << oldHead << " to " <<
+ debugs(93, 7, "cloned virgin message " << oldHead << " to " <<
adapted.header);
// setup adapted body pipe if needed
if (oldHead->body_pipe != NULL) {
- debugs(93, 7, HERE << "will echo virgin body from " <<
+ debugs(93, 7, "will echo virgin body from " <<
oldHead->body_pipe);
if (!virginBodySending.active())
virginBodySending.plan(); // will throw if not possible
makeAdaptedBodyPipe("echoed virgin response");
if (oldHead->body_pipe->bodySizeKnown())
adapted.body_pipe->setBodySize(oldHead->body_pipe->bodySize());
- debugs(93, 7, HERE << "will echo virgin body to " <<
+ debugs(93, 7, "will echo virgin body to " <<
adapted.body_pipe);
} else {
- debugs(93, 7, HERE << "no virgin body to echo");
+ debugs(93, 7, "no virgin body to echo");
stopSending(true);
}
}
setOutcome(xoPartEcho);
- debugs(93, 7, HERE << "will echo virgin body suffix from " <<
+ debugs(93, 7, "will echo virgin body suffix from " <<
virgin.header->body_pipe << " offset " << pos );
// check that use-original-body=N does not point beyond buffered data
if (virgin.header->body_pipe->bodySizeKnown())
adapted.body_pipe->expectProductionEndAfter(virgin.header->body_pipe->bodySize() - pos);
- debugs(93, 7, HERE << "will echo virgin body suffix to " <<
+ debugs(93, 7, "will echo virgin body suffix to " <<
adapted.body_pipe);
// Start echoing data
void Adaptation::Icap::ModXact::decideOnParsingBody()
{
if (expectHttpBody()) {
- debugs(93, 5, HERE << "expecting a body");
+ debugs(93, 5, "expecting a body");
state.parsing = State::psBody;
replyHttpBodySize = 0;
bodyParser = new Http1::TeChunkedParser;
makeAdaptedBodyPipe("adapted response from the ICAP server");
Must(state.sending == State::sendingAdapted);
} else {
- debugs(93, 5, HERE << "not expecting a body");
+ debugs(93, 5, "not expecting a body");
if (trailerParser)
state.parsing = State::psIcapTrailer;
else
return;
}
- debugs(93,3,HERE << this << " needsMoreData = " << bodyParser->needsMoreData());
+ debugs(93,3, this << " needsMoreData = " << bodyParser->needsMoreData());
if (bodyParser->needsMoreData()) {
- debugs(93,3,HERE << this);
+ debugs(93,3, this);
Must(mayReadMore());
readMore();
}
// internal cleanup
void Adaptation::Icap::ModXact::swanSong()
{
- debugs(93, 5, HERE << "swan sings" << status());
+ debugs(93, 5, "swan sings" << status());
stopWriting(false);
stopSending(false);
void Adaptation::Icap::ModXact::decideOnPreview()
{
if (!TheConfig.preview_enable) {
- debugs(93, 5, HERE << "preview disabled by squid.conf");
+ debugs(93, 5, "preview disabled by squid.conf");
return;
}
else if (virginBody.knownSize())
ad = min(static_cast<uint64_t>(ad), virginBody.size()); // not more than we have
- debugs(93, 5, HERE << "should offer " << ad << "-byte preview " <<
+ debugs(93, 5, "should offer " << ad << "-byte preview " <<
"(service wanted " << wantedSize << ")");
preview.enable(ad);
// expectingBody returns true for zero-sized bodies, but we will not
// get a pipe for that body, so we treat the message as bodyless
if (method != Http::METHOD_NONE && msg->expectingBody(method, size) && size) {
- debugs(93, 6, HERE << "expects virgin body from " <<
+ debugs(93, 6, "expects virgin body from " <<
virgin.body_pipe << "; size: " << size);
virginBody.expect(size);
// make sure TheBackupLimit is in-sync with the buffer size
Must(TheBackupLimit <= static_cast<size_t>(msg->body_pipe->buf().max_capacity));
} else {
- debugs(93, 6, HERE << "does not expect virgin body");
+ debugs(93, 6, "does not expect virgin body");
Must(msg->body_pipe == NULL);
checkConsuming();
}
Must(!adapted.header->body_pipe);
adapted.header->body_pipe = new BodyPipe(this);
adapted.body_pipe = adapted.header->body_pipe;
- debugs(93, 7, HERE << "will supply " << what << " via " <<
+ debugs(93, 7, "will supply " << what << " via " <<
adapted.body_pipe << " pipe");
}
void Adaptation::Icap::ModXactLauncher::swanSong()
{
- debugs(93, 5, HERE << "swan sings");
+ debugs(93, 5, "swan sings");
updateHistory(false);
Adaptation::Icap::Launcher::swanSong();
}