* Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
*/
-#include "squid-old.h"
+#include "squid.h"
/* MS Visual Studio Projects are monolithic, so we need the following
* #if to exclude the ESI code from compile process when not needed.
*/
#if (USE_SQUID_ESI == 1)
-#include "esi/Esi.h"
-#include "clientStream.h"
#include "client_side_request.h"
+#include "client_side.h"
+#include "clientStream.h"
#include "comm/Connection.h"
#include "errorpage.h"
-#include "esi/Segment.h"
-#include "esi/Element.h"
+#include "esi/Assign.h"
+#include "esi/Attempt.h"
#include "esi/Context.h"
+#include "esi/Element.h"
+#include "esi/Esi.h"
+#include "esi/Except.h"
+#include "esi/Expression.h"
+#include "esi/Segment.h"
+#include "esi/VarState.h"
#include "HttpHdrSc.h"
#include "HttpHdrScTarget.h"
#include "HttpReply.h"
-#include "esi/Attempt.h"
-#include "esi/Except.h"
-#include "client_side.h"
-#include "esi/VarState.h"
-#include "esi/Assign.h"
-#include "esi/Expression.h"
#include "HttpRequest.h"
-#include "MemBuf.h"
#include "ip/Address.h"
+#include "MemBuf.h"
+#include "profiler/Profiler.h"
+#include "protos.h"
/* quick reference on behaviour here.
* The ESI specification 1.0 requires the ESI processor to be able to
typedef ESIContext::esiKick_t esiKick_t;
-
/* some core operators */
/* esiComment */
static FREE esiRemoveFree;
static ESIElement * esiRemoveNew(void);
-
/* esiTry */
struct esiTry : public ESIElement {
return reading_;
}
-
ESIStreamContext::ESIStreamContext() : finished(false), include (NULL), localbuffer (new ESISegment), buffer (NULL)
{}
/* ESIContext */
static ESIContext *ESIContextNew(HttpReply *, clientStreamNode *, ClientHttpRequest *);
-
void *
ESIContext::operator new(size_t byteCount)
{
return;
}
-
if (context->flags.oktosend && context->flags.finished) {
StoreIOBuffer tempBuffer;
assert (!context->outbound.getRaw());
if (len == 0)
len = 1; /* tell the caller we sent something (because we sent headers */
-
cbdataReferenceDone (templock);
debugs (86,5,"ESIContext::send: this=" << this << " sent " << len);
debugs(86, 5, "ESIContext::addStackElement: About to add ESI Node " << element.getRaw());
if (!parserState.top()->addElement(element)) {
- debugs(86, 1, "ESIContext::addStackElement: failed to add esi node, probable error in ESI template");
+ debugs(86, DBG_IMPORTANT, "ESIContext::addStackElement: failed to add esi node, probable error in ESI template");
flags.error = 1;
} else {
/* added ok, push onto the stack */
- parserState.stack[parserState.stackdepth++] = element;
+ parserState.stack[parserState.stackdepth] = element;
+ ++parserState.stackdepth;
}
}
position = localbuf + strlen (localbuf);
for (i = 0; i < specifiedattcount && attr[i]; i += 2) {
- *position++ = ' ';
+ *position = ' ';
+ ++position;
/* TODO: handle thisNode gracefully */
assert (xstrncpy (position, attr[i], sizeof(localbuf) + (position - localbuf)));
position += strlen (position);
- *position++ = '=';
- *position++ = '\"';
+ *position = '=';
+ ++position;
+ *position = '\"';
+ ++position;
const char *chPtr = attr[i + 1];
char ch;
while ((ch = *chPtr++) != '\0') {
assert( xstrncpy(position, """, sizeof(localbuf) + (position-localbuf)) );
position += 6;
} else {
- *(position++) = ch;
+ *position = ch;
+ ++position;
}
}
position += strlen (position);
- *position++ = '\"';
+ *position = '\"';
+ ++position;
}
- *position++ = '>';
+ *position = '>';
+ ++position;
*position = '\0';
addLiteral (localbuf, position - localbuf);
localbuf[1] = '/';
assert (xstrncpy (&localbuf[2], el, sizeof(localbuf) - 3));
position = localbuf + strlen (localbuf);
- *position++ = '>';
+ *position = '>';
+ ++position;
*position = '\0';
addLiteral (localbuf, position - localbuf);
break;
if (!tempParser->parse("<div>", 5,0) ||
!tempParser->parse(s + 3, strlen(s) - 3, 0) ||
!tempParser->parse("</div>",6,1)) {
- debugs(86, 0, "ESIContext::parserComment: Parsing fragment '" << s + 3 << "' failed.");
+ debugs(86, DBG_CRITICAL, "ESIContext::parserComment: Parsing fragment '" << s + 3 << "' failed.");
setError();
char tempstr[1024];
snprintf(tempstr, 1023, "ESIContext::parserComment: Parse error at line %ld:\n%s\n",
tempParser->lineNumber(),
tempParser->errorString());
- debugs(86, 0, "" << tempstr << "");
+ debugs(86, DBG_CRITICAL, "" << tempstr << "");
setErrorMessage(tempstr);
}
len = strlen (s);
if (len > sizeof (localbuf) - 9) {
- debugs(86, 0, "ESIContext::parserComment: Truncating long comment");
+ debugs(86, DBG_CRITICAL, "ESIContext::parserComment: Truncating long comment");
len = sizeof (localbuf) - 9;
}
ESIElement::Pointer element (new esiLiteral (this, s, len));
if (!parserState.top()->addElement(element)) {
- debugs(86, 1, "ESIContext::addLiteral: failed to add esi node, probable error in ESI template");
+ debugs(86, DBG_IMPORTANT, "ESIContext::addLiteral: failed to add esi node, probable error in ESI template");
flags.error = 1;
}
}
snprintf (tempstr, 1023, "esiProcess: Parse error at line %ld:\n%s\n",
parserState.theParser->lineNumber(),
parserState.theParser->errorString());
- debugs(86, 0, "" << tempstr << "");
+ debugs(86, DBG_CRITICAL, "" << tempstr << "");
setErrorMessage(tempstr);
if (!parserState.stackdepth) {
debugs(86, 5, "empty parser stack, inserting the top level node");
assert (tree.getRaw());
- parserState.stack[parserState.stackdepth++] = tree;
+ parserState.stack[parserState.stackdepth] = tree;
+ ++parserState.stackdepth;
}
if (rep && !parserState.inited())
break;
case ESI_PROCESS_FAILED:
- debugs(86, 0, "esiProcess: tree Processed FAILED");
+ debugs(86, DBG_CRITICAL, "esiProcess: tree Processed FAILED");
setError();
setErrorMessage("esiProcess: ESI template Processing failed.");
extern ErrorState *clientBuildError (err_type, http_status, char const *, Ip::Address &, HttpRequest *);
-
/* This can ONLY be used before we have sent *any* data to the client */
void
ESIContext::fail ()
if (dynamic_cast<esiAttempt*>(element.getRaw())) {
if (attempt.getRaw()) {
- debugs(86, 1, "esiTryAdd: Failed for " << this << " - try allready has an attempt node (section 3.4)");
+ debugs(86, DBG_IMPORTANT, "esiTryAdd: Failed for " << this << " - try allready has an attempt node (section 3.4)");
return false;
}
if (dynamic_cast<esiExcept*>(element.getRaw())) {
if (except.getRaw()) {
- debugs(86, 1, "esiTryAdd: Failed for " << this << " - try already has an except node (section 3.4)");
+ debugs(86, DBG_IMPORTANT, "esiTryAdd: Failed for " << this << " - try already has an except node (section 3.4)");
return false;
}
return true;
}
- debugs(86, 1, "esiTryAdd: Failed to add element " << element.getRaw() << " to try " << this << ", incorrect element type (see section 3.4)");
+ debugs(86, DBG_IMPORTANT, "esiTryAdd: Failed to add element " << element.getRaw() << " to try " << this << ", incorrect element type (see section 3.4)");
return false;
}
assert (this);
if (!attempt.getRaw()) {
- debugs(86, 0, "esiTryProcess: Try has no attempt element - ESI template is invalid (section 3.4)");
+ debugs(86, DBG_CRITICAL, "esiTryProcess: Try has no attempt element - ESI template is invalid (section 3.4)");
return ESI_PROCESS_FAILED;
}
if (!except.getRaw()) {
- debugs(86, 0, "esiTryProcess: Try has no except element - ESI template is invalid (section 3.4)");
+ debugs(86, DBG_CRITICAL, "esiTryProcess: Try has no except element - ESI template is invalid (section 3.4)");
return ESI_PROCESS_FAILED;
}
/* Some elements require specific parents */
if (!(dynamic_cast<esiWhen*>(element.getRaw()) || dynamic_cast<esiOtherwise*>(element.getRaw()))) {
- debugs(86, 0, "esiChooseAdd: invalid child node for esi:choose (section 3.3)");
+ debugs(86, DBG_CRITICAL, "esiChooseAdd: invalid child node for esi:choose (section 3.3)");
return false;
}
if (dynamic_cast<esiOtherwise*>(element.getRaw())) {
if (otherwise.getRaw()) {
- debugs(86, 0, "esiChooseAdd: only one otherwise node allowed for esi:choose (section 3.3)");
+ debugs(86, DBG_CRITICAL, "esiChooseAdd: only one otherwise node allowed for esi:choose (section 3.3)");
return false;
}
parent->provideData (data, this);
}
-
esiChoose::esiChoose(esiChoose const &old) : chosenelement(-1), otherwise (NULL), parent (NULL)
{
for (size_t counter = 0; counter < old.elements.size(); ++counter) {
/* ignore mistyped attributes.
* TODO:? error on these for user feedback - config parameter needed
*/
- debugs(86, 1, "Found misttyped attribute on ESI When clause");
+ debugs(86, DBG_IMPORTANT, "Found misttyped attribute on ESI When clause");
}
}