]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/esi/Context.h
5 * SQUID Web Proxy Cache http://www.squid-cache.org/
6 * ----------------------------------------------------------
8 * Squid is the result of efforts by numerous individuals from
9 * the Internet community; see the CONTRIBUTORS file for full
10 * details. Many organizations have provided support for Squid's
11 * development; see the SPONSORS file for full details. Squid is
12 * Copyrighted (C) 2001 by the Regents of the University of
13 * California; see the COPYRIGHT file for full details. Squid
14 * incorporates software developed and/or copyrighted by other
15 * sources; see the CREDITS file for full details.
17 * This program is free software; you can redistribute it and/or modify
18 * it under the terms of the GNU General Public License as published by
19 * the Free Software Foundation; either version 2 of the License, or
20 * (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
31 * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
34 #ifndef SQUID_ESICONTEXT_H
35 #define SQUID_ESICONTEXT_H
37 #include "esi/Element.h"
38 #include "clientStream.h"
42 class ClientHttpRequest
;
44 #include "esi/Parser.h"
48 class ESIContext
: public esiTreeParent
, public ESIParserClient
52 typedef RefCount
<ESIContext
> Pointer
;
53 void *operator new (size_t byteCount
);
54 void operator delete (void *address
);
55 ESIContext():reading_(true) {}
66 /* when esi processing completes */
67 void provideData(ESISegment::Pointer
, ESIElement
*source
);
68 void fail (ESIElement
*source
, char const*anError
= NULL
);
73 void setErrorMessage(char const *);
75 void addStackElement (ESIElement::Pointer element
);
76 void addLiteral (const char *s
, int len
);
78 void finishChildren ();
80 clientStreamNode
*thisNode
; /* our stream node */
81 /* the request we are processing. HMM: cbdataReferencing this will result
82 * in a circular reference, so we don't. Note: we are automatically freed
83 * when it is, so thats ok. */
84 ClientHttpRequest
*http
;
91 /* an error has occured, send full body replies
92 * regardless. Note that we don't fail midstream
93 * because we buffer until we can not fail
97 int finishedtemplate
:1; /* we've read the entire template */
98 int clientwantsdata
:1; /* we need to satisfy a read request */
99 int kicked
:1; /* note on reentering the kick routine */
100 int detached
:1; /* our downstream has detached */
103 err_type errorpage
; /* if we error what page to use */
104 http_status errorstatus
; /* if we error, what code to return */
105 char *errormessage
; /* error to pass to error page */
106 HttpReply
*rep
; /* buffered until we pass data downstream */
107 ESISegment::Pointer buffered
; /* unprocessed data - for whatever reason */
108 ESISegment::Pointer incoming
;
109 /* processed data we are waiting to send, or for
110 * potential errors to be resolved
112 ESISegment::Pointer outbound
;
113 ESISegment::Pointer outboundtail
; /* our write segment */
114 /* the offset to the next character to send -
115 * non zero if we haven't sent the entire segment
118 size_t outbound_offset
;
119 int64_t readpos
; /* the logical position we are reading from */
120 int64_t pos
; /* the logical position of outbound_offset in the data stream */
126 ESIElement::Pointer stack
[10]; /* a stack of esi elements that are open */
127 int stackdepth
; /* self explanatory */
128 ESIParser::Pointer theParser
;
129 ESIElement::Pointer
top();
130 void init (ESIParserClient
*);
133 void freeResources();
135 int parsing
:1; /* libexpat is not reentrant on the same context */
141 parserState
; /* todo factor this off somewhere else; */
142 ESIVarState
*varState
;
143 ESIElement::Pointer tree
;
146 RefCount
<ESIContext
> cbdataLocker
;
147 bool failed() const {return flags
.error
!= 0;}
152 CBDATA_CLASS(ESIContext
);
154 void freeResources();
155 void fixupOutboundTail();
159 void appendOutboundData(ESISegment::Pointer theData
);
160 esiProcessResult_t
process ();
162 void parseOneBuffer();
163 void updateCachedAST();
164 bool hasCachedAST() const;
166 virtual void start(const char *el
, const char **attr
, size_t attrCount
);
167 virtual void end(const char *el
);
168 virtual void parserDefault (const char *s
, int len
);
169 virtual void parserComment (const char *s
);
173 #endif /* SQUID_ESICONTEXT_H */