errorpage.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 /* DEBUG: section 04 Error Generation */
10 
11 #ifndef SQUID_ERRORPAGE_H
12 #define SQUID_ERRORPAGE_H
13 
14 #include "cbdata.h"
15 #include "comm/forward.h"
16 #include "err_detail_type.h"
17 #include "err_type.h"
18 #include "http/forward.h"
19 #include "http/StatusCode.h"
20 #include "ip/Address.h"
21 #include "SquidString.h"
22 /* auth/UserRequest.h is empty unless USE_AUTH is defined */
23 #include "auth/UserRequest.h"
24 #if USE_OPENSSL
25 #include "ssl/ErrorDetail.h"
26 #endif
27 
29 typedef void ERCB(int fd, void *, size_t);
30 
74 class MemBuf;
75 class StoreEntry;
76 class wordlist;
77 
80 {
82 
83 public:
85  ErrorState() = delete; // not implemented.
86  ~ErrorState();
87 
90 
95 
97  void detailError(int dCode) {detailCode = dCode;}
98 
99 private:
104  MemBuf *BuildContent(void);
105 
112  MemBuf *ConvertText(const char *text, bool allowRecursion);
113 
118  void DenyInfoLocation(const char *name, HttpRequest *request, MemBuf &result);
119 
130  const char *Convert(char token, bool building_deny_info_url, bool allowRecursion);
131 
137  int Dump(MemBuf * mb);
138 
139 public:
142  char *err_language = nullptr;
144 #if USE_AUTH
146 #endif
148  char *url = nullptr;
149  int xerrno = 0;
150  unsigned short port = 0;
152  time_t ttl = 0;
153 
155  char *redirect_url = nullptr;
157  void *callback_data = nullptr;
158 
159  struct {
160  wordlist *server_msg = nullptr;
161  char *request = nullptr;
162  char *reply = nullptr;
163  char *cwd_msg = nullptr;
164  MemBuf *listing = nullptr;
165  } ftp;
166 
167  char *request_hdrs = nullptr;
168  char *err_msg = nullptr; /* Preformatted error message from the cache */
169 
170 #if USE_OPENSSL
172 #endif
176 };
177 
187 void errorInitialize(void);
188 
190 void errorClean(void);
191 
213 
230 void errorAppendEntry(StoreEntry *entry, ErrorState *err);
231 
233 err_type errorReservePageId(const char *page_name);
234 
235 const char *errorPageName(int pageId);
236 
244 {
245 public:
246  TemplateFile(const char *name, const err_type code);
247  virtual ~TemplateFile() {}
248 
250  bool loaded() const {return wasLoaded;}
251 
258  bool loadDefault();
259 
266  bool loadFor(const HttpRequest *request);
267 
272  bool loadFromFile(const char *path);
273 
275  const char *language() {return errLanguage.termedBuf();}
276 
277  bool silent;
278 
279 protected:
281  virtual bool parse(const char *buf, int len, bool eof) = 0;
282 
288  bool tryLoadTemplate(const char *lang);
289 
290  bool wasLoaded;
294 };
295 
309 bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos);
310 
311 #endif /* SQUID_ERRORPAGE_H */
312 
bool loaded() const
return true if the data loaded from disk without any problem
Definition: errorpage.h:250
char * reply
Definition: errorpage.h:162
String errLanguage
The error language of the template.
Definition: errorpage.h:291
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
int page_id
Definition: errorpage.h:141
ERCB * callback
Definition: errorpage.h:156
char * url
Definition: errorpage.h:148
MemBuf * ConvertText(const char *text, bool allowRecursion)
Definition: errorpage.cc:1248
Auth::UserRequest::Pointer auth_user_request
Definition: errorpage.h:145
char * err_msg
Definition: errorpage.h:168
int conn
the current server connection FD
Definition: Transport.cc:26
void * callback_data
Definition: errorpage.h:157
bool wasLoaded
True if the template data read from disk without any problem.
Definition: errorpage.h:290
void errorSend(const Comm::ConnectionPointer &conn, ErrorState *err)
Definition: errorpage.cc:608
bool silent
Whether to print error messages on cache.log file or not. It is user defined.
Definition: errorpage.h:277
int detailCode
Definition: errorpage.h:175
err_type templateCode
The internal code for this template.
Definition: errorpage.h:293
bool tryLoadTemplate(const char *lang)
Definition: errorpage.cc:294
MemBuf * listing
Definition: errorpage.h:164
void errorClean(void)
Definition: errorpage.cc:215
unsigned short port
Definition: errorpage.h:150
StatusCode
Definition: StatusCode.h:20
MemBuf * BuildContent(void)
Definition: errorpage.cc:1201
wordlist * server_msg
Definition: errorpage.h:160
char const * termedBuf() const
Definition: SquidString.h:91
ErrorState()=delete
#define CBDATA_CLASS(type)
Definition: cbdata.h:302
const char * errorPageName(int pageId)
error ID to string
Definition: errorpage.cc:540
virtual ~TemplateFile()
Definition: errorpage.h:247
TemplateFile(const char *name, const err_type code)
Definition: errorpage.cc:251
Http::StatusCode httpStatus
Definition: errorpage.h:143
err_type errorReservePageId(const char *page_name)
Definition: errorpage.cc:524
struct ErrorState::@60 ftp
int unsigned int const char *desc STUB void int len
Definition: stub_fd.cc:20
unsigned char code
Definition: html_quote.c:20
void const char * buf
Definition: stub_helper.cc:16
bool loadDefault()
Definition: errorpage.cc:257
static ErrorState * NewForwarding(err_type, HttpRequestPointer &)
Creates a general request forwarding error with the right http_status.
Definition: errorpage.cc:552
char * cwd_msg
Definition: errorpage.h:163
err_type type
Definition: errorpage.h:140
String dnsError
DNS lookup error message.
Definition: errorpage.h:151
HttpRequestPointer request
Definition: errorpage.h:147
time_t ttl
Definition: errorpage.h:152
Definition: MemBuf.h:23
bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos)
Definition: errorpage.cc:360
void errorAppendEntry(StoreEntry *entry, ErrorState *err)
Definition: errorpage.cc:575
int Dump(MemBuf *mb)
Definition: errorpage.cc:669
char * request_hdrs
Definition: errorpage.h:167
bool loadFor(const HttpRequest *request)
Definition: errorpage.cc:414
HttpReply * BuildHttpReply(void)
Definition: errorpage.cc:1111
void detailError(int dCode)
set error type-specific detail code
Definition: errorpage.h:97
const char * language()
The language used for the template.
Definition: errorpage.h:275
const char * Convert(char token, bool building_deny_info_url, bool allowRecursion)
Definition: errorpage.cc:739
void errorInitialize(void)
Definition: errorpage.cc:157
int xerrno
Definition: errorpage.h:149
virtual bool parse(const char *buf, int len, bool eof)=0
Used to parse (if parsing required) the template data .
void ERCB(int fd, void *, size_t)
error page callback
Definition: errorpage.h:29
Ip::Address src_addr
Definition: errorpage.h:154
char * redirect_url
Definition: errorpage.h:155
Ssl::ErrorDetail * detail
Definition: errorpage.h:171
const char * text
Definition: errorpage.cc:79
void DenyInfoLocation(const char *name, HttpRequest *request, MemBuf &result)
Definition: errorpage.cc:1088
String templateName
The name of the template.
Definition: errorpage.h:292
bool loadFromFile(const char *path)
Definition: errorpage.cc:319
err_type
Definition: err_type.h:12
char * err_language
Definition: errorpage.h:142

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors