]>
Commit | Line | Data |
---|---|---|
aa839030 | 1 | /* |
63be0a78 | 2 | * DEBUG: section 4 Error Generation |
3 | * AUTHOR: Duane Wessels | |
aa839030 | 4 | * |
5 | * SQUID Web Proxy Cache http://www.squid-cache.org/ | |
6 | * ---------------------------------------------------------- | |
7 | * | |
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. | |
16 | * | |
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. | |
26ac0430 | 21 | * |
aa839030 | 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. | |
26ac0430 | 26 | * |
aa839030 | 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. | |
30 | * | |
31 | * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org> | |
32 | */ | |
33 | ||
34 | #ifndef SQUID_ERRORPAGE_H | |
35 | #define SQUID_ERRORPAGE_H | |
36 | ||
37 | #include "squid.h" | |
38 | #include "cbdata.h" | |
9837e5f0 | 39 | #include "ip/IpAddress.h" |
aa839030 | 40 | |
63be0a78 | 41 | /** |
42 | \defgroup ErrorPageAPI Error Pages API | |
43 | \ingroup Components | |
44 | \section ErrorPageStringCodes Error Page % codes for text insertion. | |
45 | * | |
46 | \verbatim | |
47 | a - User identity x | |
48 | B - URL with FTP %2f hack x | |
49 | c - Squid error code x | |
50 | d - seconds elapsed since request received x | |
51 | e - errno x | |
52 | E - strerror() x | |
53 | f - FTP request line x | |
54 | F - FTP reply line x | |
55 | g - FTP server message x | |
56 | h - cache hostname x | |
57 | H - server host name x | |
58 | i - client IP address x | |
59 | I - server IP address x | |
8e1a6bde | 60 | l - HREF link for CSS stylesheet inclusion x |
63be0a78 | 61 | L - HREF link for more info/contact x |
62 | M - Request Method x | |
63 | m - Error message returned by auth helper x | |
64 | o - Message returned external acl helper x | |
65 | p - URL port # x | |
66 | P - Protocol x | |
67 | R - Full HTTP Request x | |
68 | S - squid signature from ERR_SIGNATURE x | |
69 | s - caching proxy software with version x | |
70 | t - local time x | |
71 | T - UTC x | |
72 | U - URL without password x | |
73 | u - URL with password x | |
74 | w - cachemgr email address x | |
75 | W - error data (to be included in the mailto links) | |
76 | z - dns server error message x | |
77 | Z - Preformatted error message x | |
78 | \endverbatim | |
79 | */ | |
80 | ||
9554bbf2 | 81 | class AuthUserRequest; |
c70281f8 AJ |
82 | class HttpReply; |
83 | class MemBuf; | |
9554bbf2 | 84 | |
63be0a78 | 85 | /// \ingroup ErrorPageAPI |
aa839030 | 86 | class ErrorState |
87 | { | |
c70281f8 AJ |
88 | public: |
89 | /** | |
90 | * Allocates and initializes an error response | |
91 | */ | |
92 | HttpReply *BuildHttpReply(void); | |
93 | ||
94 | private: | |
95 | /** | |
96 | * Locates error page template to be used for this error | |
97 | * and constructs the HTML page content from it. | |
98 | */ | |
99 | MemBuf *BuildContent(void); | |
100 | ||
101 | /** | |
102 | * Convert an error template into an error page. | |
103 | */ | |
104 | const char *Convert(char token); | |
105 | ||
106 | /** | |
107 | * CacheManager / Debug dump of the ErrorState object. | |
108 | * Writes output into the given MemBuf. | |
109 | \retval 0 successful completion. | |
110 | */ | |
111 | int Dump(MemBuf * mb); | |
2cc81f1f | 112 | |
113 | public: | |
aa839030 | 114 | err_type type; |
115 | int page_id; | |
ccb24616 | 116 | char *err_language; |
aa839030 | 117 | http_status httpStatus; |
76f142cd | 118 | AuthUserRequest *auth_user_request; |
aa839030 | 119 | HttpRequest *request; |
120 | char *url; | |
121 | int xerrno; | |
122 | u_short port; | |
123 | char *dnsserver_msg; | |
124 | time_t ttl; | |
125 | ||
ad61a2b4 | 126 | IpAddress src_addr; |
aa839030 | 127 | char *redirect_url; |
128 | ERCB *callback; | |
129 | void *callback_data; | |
130 | ||
26ac0430 | 131 | struct { |
3d0ac046 HN |
132 | unsigned int flag_cbdata:1; |
133 | } flags; | |
aa839030 | 134 | |
26ac0430 | 135 | struct { |
aa839030 | 136 | wordlist *server_msg; |
137 | char *request; | |
138 | char *reply; | |
3d0ac046 | 139 | } ftp; |
aa839030 | 140 | |
aa839030 | 141 | char *request_hdrs; |
142 | char *err_msg; /* Preformatted error message from the cache */ | |
2cc81f1f | 143 | |
144 | private: | |
aa839030 | 145 | CBDATA_CLASS2(ErrorState); |
146 | }; | |
147 | ||
63be0a78 | 148 | /** |
149 | \ingroup ErrorPageAPI | |
150 | * | |
151 | * This function finds the error messages formats, and stores | |
152 | * them in error_text[] | |
153 | * | |
154 | \par Global effects: | |
155 | * error_text[] - is modified | |
156 | */ | |
aa839030 | 157 | SQUIDCEXTERN void errorInitialize(void); |
63be0a78 | 158 | |
159 | /// \ingroup ErrorPageAPI | |
aa839030 | 160 | SQUIDCEXTERN void errorClean(void); |
63be0a78 | 161 | |
63be0a78 | 162 | /** |
163 | \ingroup ErrorPageAPI | |
164 | * | |
165 | * This function generates a error page from the info contained | |
166 | * by err and then sends it to the client. | |
167 | * The callback function errorSendComplete() is called after | |
168 | * the page has been written to the client socket (fd). | |
169 | * errorSendComplete() deallocates err. We need to add | |
170 | * err to the cbdata because comm_write() requires it | |
171 | * for all callback data pointers. | |
172 | * | |
173 | \note normally errorSend() should only be called from | |
174 | * routines in ssl.c and pass.c, where we don't have any | |
175 | * StoreEntry's. In client_side.c we must allocate a StoreEntry | |
176 | * for errors and use errorAppendEntry() to account for | |
177 | * persistent/pipeline connections. | |
178 | * | |
179 | \param fd socket where page object is to be written | |
180 | \param err This object is destroyed after use in this function. | |
181 | */ | |
182 | SQUIDCEXTERN void errorSend(int fd, ErrorState *err); | |
183 | ||
184 | /** | |
185 | \ingroup ErrorPageAPI | |
186 | * | |
187 | * This function generates a error page from the info contained | |
188 | * by err and then stores the text in the specified store | |
189 | * entry. | |
190 | * This function should only be called by "server | |
191 | * side routines" which need to communicate errors to the | |
192 | * client side. It should also be called from client_side.c | |
193 | * because we now support persistent connections, and | |
194 | * cannot assume that we can immediately write to the socket | |
195 | * for an error. | |
196 | * | |
197 | \param entry ?? | |
198 | \param err This object is destroyed after use in this function. | |
199 | */ | |
200 | SQUIDCEXTERN void errorAppendEntry(StoreEntry *entry, ErrorState *err); | |
201 | ||
202 | /// \ingroup ErrorPageAPI | |
aa839030 | 203 | SQUIDCEXTERN void errorStateFree(ErrorState * err); |
63be0a78 | 204 | |
205 | /// \ingroup ErrorPageAPI | |
aa839030 | 206 | SQUIDCEXTERN err_type errorReservePageId(const char *page_name); |
aa839030 | 207 | |
63be0a78 | 208 | /** |
209 | \ingroup ErrorPageAPI | |
210 | * | |
211 | * This function creates a ErrorState object. | |
212 | */ | |
213 | SQUIDCEXTERN ErrorState *errorCon(err_type type, http_status, HttpRequest * request); | |
aa839030 | 214 | |
215 | #endif /* SQUID_ERRORPAGE_H */ |