]>
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
);
53 ESIContext():reading_(true) {}
64 /* when esi processing completes */
65 void provideData(ESISegment::Pointer
, ESIElement
*source
);
66 void fail (ESIElement
*source
, char const*anError
= NULL
);
71 void setErrorMessage(char const *);
73 void addStackElement (ESIElement::Pointer element
);
74 void addLiteral (const char *s
, int len
);
76 void finishChildren ();
78 clientStreamNode
*thisNode
; /* our stream node */
79 /* the request we are processing. HMM: cbdataReferencing this will result
80 * in a circular reference, so we don't. Note: we are automatically freed
81 * when it is, so thats ok. */
82 ClientHttpRequest
*http
;
89 /* an error has occured, send full body replies
90 * regardless. Note that we don't fail midstream
91 * because we buffer until we can not fail
95 int finishedtemplate
:1; /* we've read the entire template */
96 int clientwantsdata
:1; /* we need to satisfy a read request */
97 int kicked
:1; /* note on reentering the kick routine */
98 int detached
:1; /* our downstream has detached */
101 err_type errorpage
; /* if we error what page to use */
102 http_status errorstatus
; /* if we error, what code to return */
103 char *errormessage
; /* error to pass to error page */
104 HttpReply
*rep
; /* buffered until we pass data downstream */
105 ESISegment::Pointer buffered
; /* unprocessed data - for whatever reason */
106 ESISegment::Pointer incoming
;
107 /* processed data we are waiting to send, or for
108 * potential errors to be resolved
110 ESISegment::Pointer outbound
;
111 ESISegment::Pointer outboundtail
; /* our write segment */
112 /* the offset to the next character to send -
113 * non zero if we haven't sent the entire segment
116 size_t outbound_offset
;
117 int64_t readpos
; /* the logical position we are reading from */
118 int64_t pos
; /* the logical position of outbound_offset in the data stream */
124 ESIElement::Pointer stack
[10]; /* a stack of esi elements that are open */
125 int stackdepth
; /* self explanatory */
126 ESIParser::Pointer theParser
;
127 ESIElement::Pointer
top();
128 void init (ESIParserClient
*);
131 void freeResources();
133 int parsing
:1; /* libexpat is not reentrant on the same context */
139 parserState
; /* todo factor this off somewhere else; */
140 ESIVarState
*varState
;
141 ESIElement::Pointer tree
;
144 RefCount
<ESIContext
> cbdataLocker
;
145 bool failed() const {return flags
.error
!= 0;}
151 void freeResources();
152 void fixupOutboundTail();
156 void appendOutboundData(ESISegment::Pointer theData
);
157 esiProcessResult_t
process ();
159 void parseOneBuffer();
160 void updateCachedAST();
161 bool hasCachedAST() const;
163 virtual void start(const char *el
, const char **attr
, size_t attrCount
);
164 virtual void end(const char *el
);
165 virtual void parserDefault (const char *s
, int len
);
166 virtual void parserComment (const char *s
);
169 CBDATA_CLASS(ESIContext
);
172 #endif /* SQUID_ESICONTEXT_H */