]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/esi/Context.h
3 * SQUID Web Proxy Cache http://www.squid-cache.org/
4 * ----------------------------------------------------------
6 * Squid is the result of efforts by numerous individuals from
7 * the Internet community; see the CONTRIBUTORS file for full
8 * details. Many organizations have provided support for Squid's
9 * development; see the SPONSORS file for full details. Squid is
10 * Copyrighted (C) 2001 by the Regents of the University of
11 * California; see the COPYRIGHT file for full details. Squid
12 * incorporates software developed and/or copyrighted by other
13 * sources; see the CREDITS file for full details.
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
29 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
32 #ifndef SQUID_ESICONTEXT_H
33 #define SQUID_ESICONTEXT_H
35 #include "esi/Parser.h"
36 #include "esi/Element.h"
37 #include "clientStream.h"
39 #include "HttpStatusCode.h"
42 class ClientHttpRequest
;
46 class ESIContext
: public esiTreeParent
, public ESIParserClient
50 typedef RefCount
<ESIContext
> Pointer
;
51 void *operator new (size_t byteCount
);
52 void operator delete (void *address
);
57 errorstatus(HTTP_STATUS_NONE
),
64 cachedASTInUse(false),
67 memset(&flags
, 0, sizeof(flags
));
79 /* when esi processing completes */
80 void provideData(ESISegment::Pointer
, ESIElement
*source
);
81 void fail (ESIElement
*source
, char const*anError
= NULL
);
86 void setErrorMessage(char const *);
88 void addStackElement (ESIElement::Pointer element
);
89 void addLiteral (const char *s
, int len
);
91 void finishChildren ();
93 clientStreamNode
*thisNode
; /* our stream node */
94 /* the request we are processing. HMM: cbdataReferencing this will result
95 * in a circular reference, so we don't. Note: we are automatically freed
96 * when it is, so thats ok. */
97 ClientHttpRequest
*http
;
104 /* an error has occured, send full body replies
105 * regardless. Note that we don't fail midstream
106 * because we buffer until we can not fail
110 int finishedtemplate
:1; /* we've read the entire template */
111 int clientwantsdata
:1; /* we need to satisfy a read request */
112 int kicked
:1; /* note on reentering the kick routine */
113 int detached
:1; /* our downstream has detached */
116 err_type errorpage
; /* if we error what page to use */
117 http_status errorstatus
; /* if we error, what code to return */
118 char *errormessage
; /* error to pass to error page */
119 HttpReply
*rep
; /* buffered until we pass data downstream */
120 ESISegment::Pointer buffered
; /* unprocessed data - for whatever reason */
121 ESISegment::Pointer incoming
;
122 /* processed data we are waiting to send, or for
123 * potential errors to be resolved
125 ESISegment::Pointer outbound
;
126 ESISegment::Pointer outboundtail
; /* our write segment */
127 /* the offset to the next character to send -
128 * non zero if we haven't sent the entire segment
131 size_t outbound_offset
;
132 int64_t readpos
; /* the logical position we are reading from */
133 int64_t pos
; /* the logical position of outbound_offset in the data stream */
139 ESIElement::Pointer stack
[10]; /* a stack of esi elements that are open */
140 int stackdepth
; /* self explanatory */
141 ESIParser::Pointer theParser
;
142 ESIElement::Pointer
top();
143 void init (ESIParserClient
*);
146 void freeResources();
148 int parsing
:1; /* libexpat is not reentrant on the same context */
154 parserState
; /* todo factor this off somewhere else; */
155 ESIVarState
*varState
;
156 ESIElement::Pointer tree
;
159 RefCount
<ESIContext
> cbdataLocker
;
160 bool failed() const {return flags
.error
!= 0;}
166 void freeResources();
167 void fixupOutboundTail();
171 void appendOutboundData(ESISegment::Pointer theData
);
172 esiProcessResult_t
process ();
174 void parseOneBuffer();
175 void updateCachedAST();
176 bool hasCachedAST() const;
178 virtual void start(const char *el
, const char **attr
, size_t attrCount
);
179 virtual void end(const char *el
);
180 virtual void parserDefault (const char *s
, int len
);
181 virtual void parserComment (const char *s
);
184 CBDATA_CLASS(ESIContext
);
187 #endif /* SQUID_ESICONTEXT_H */