Inheritance diagram for ErrorPageFile:
Collaboration diagram for ErrorPageFile:

Public Member Functions

 ErrorPageFile (const char *name, const err_type code)
const char * text ()
 The template text data read from disk. More...
bool loaded () const
 return true if the data loaded from disk without any problem More...
void loadDefault ()
bool loadFor (const HttpRequest *request)
bool loadFromFile (const char *path)
const char * language ()
 The language used for the template. More...

Public Attributes

SBuf filename
 where the template was loaded from More...
bool silent
 Whether to print error messages on cache.log file or not. It is user defined. More...

Protected Member Functions

virtual void setDefault () override
 recover from loadDefault() failure to load or parse() a template More...
virtual bool parse ()
 post-process the loaded template More...
bool tryLoadTemplate (const char *lang)

Protected Attributes

SBuf template_
 raw template contents More...
bool wasLoaded
 True if the template data read from disk without any problem. More...
String errLanguage
 The error language of the template. More...
String templateName
 The name of the template. More...
err_type templateCode
 The internal code for this template. More...

Detailed Description

manages an error page template

Definition at line 212 of file

Constructor & Destructor Documentation

◆ ErrorPageFile()

ErrorPageFile::ErrorPageFile ( const char *  name,
const err_type  code 

Definition at line 215 of file

Member Function Documentation

◆ language()

const char* TemplateFile::language ( )

◆ loadDefault()

void TemplateFile::loadDefault ( )

Load the page_name template from a file which probably exist at: (a) admin specified custom directory (error_directory) (b) default language translation directory (error_default_language) (c) English sub-directory where errors should ALWAYS exist If all of the above fail, setDefault() is called.

test error_directory configured location

test error_default_language location

Definition at line 358 of file

References Config, DBG_CRITICAL, debugs, SquidConfig::errorDefaultLanguage, SquidConfig::errorDirectory, TemplateFile::loaded(), TemplateFile::loadFromFile(), MAXPATHLEN, TemplateFile::setDefault(), TCP_RESET, TemplateFile::templateCode, TemplateFile::templateName, String::termedBuf(), TemplateFile::tryLoadTemplate(), and TemplateFile::wasLoaded.

Referenced by Ssl::ErrorDetailsManager::ErrorDetailsManager(), and errorInitialize().

◆ loaded()

bool TemplateFile::loaded ( ) const

◆ loadFor()

bool TemplateFile::loadFor ( const HttpRequest request)

Load an error template for a given HTTP request. This function examines the Accept-Language header and select the first available template. If the default template selected (eg because of a "Accept-Language: *"), or not available template found this function return false.

Definition at line 521 of file

References Http::ACCEPT_LANGUAGE, Config, DBG_IMPORTANT, debugs, TemplateFile::errLanguage, SquidConfig::errorLogMissingLanguages, HERE(), TemplateFile::loaded(), request(), strHdrAcptLangGetItem(), and TemplateFile::tryLoadTemplate().

Referenced by ErrorState::buildBody(), and Ssl::ErrorDetailsManager::getErrorDetail().

◆ loadFromFile()

bool TemplateFile::loadFromFile ( const char *  path)

Load the file given by "path". It uses the "parse()" method. On success return true and sets the "defined" member

Definition at line 419 of file

References DBG_CRITICAL, debugs, FD_READ_METHOD(), file_close(), file_open(), TemplateFile::filename, TemplateFile::loaded(), MYNAME, O_TEXT, TemplateFile::parse(), TemplateFile::silent, TCP_RESET, TemplateFile::templateCode, TemplateFile::wasLoaded, and xstrerr().

Referenced by errorInitialize(), TemplateFile::loadDefault(), and TemplateFile::tryLoadTemplate().

◆ parse()

virtual bool TemplateFile::parse ( )

Reimplemented in Ssl::ErrorDetailFile.

Definition at line 320 of file errorpage.h.

Referenced by TemplateFile::loadFromFile().

◆ setDefault()

virtual void ErrorPageFile::setDefault ( )

Reimplemented from TemplateFile.

Definition at line 221 of file

References SBuf::append(), TemplateFile::template_, TemplateFile::templateName, and String::termedBuf().

◆ text()

const char* ErrorPageFile::text ( )

Definition at line 218 of file

Referenced by ErrorState::buildBody(), and errorInitialize().

◆ tryLoadTemplate()

bool TemplateFile::tryLoadTemplate ( const char *  lang)

Try to load the "page_name" template for a given language "lang" from squid errors directory

true on success false otherwise

Definition at line 394 of file

References assert, debugs, DEFAULT_SQUID_ERROR_DIR, HERE(), TemplateFile::loadFromFile(), MAXPATHLEN, TemplateFile::templateName, and String::termedBuf().

Referenced by TemplateFile::loadDefault(), and TemplateFile::loadFor().

Member Data Documentation

◆ errLanguage

String TemplateFile::errLanguage

Definition at line 334 of file errorpage.h.

Referenced by TemplateFile::language(), and TemplateFile::loadFor().

◆ filename

SBuf TemplateFile::filename

Definition at line 314 of file errorpage.h.

Referenced by ErrorState::buildBody(), errorInitialize(), and TemplateFile::loadFromFile().

◆ silent

bool TemplateFile::silent

Definition at line 316 of file errorpage.h.

Referenced by TemplateFile::loadFromFile().

◆ template_

SBuf TemplateFile::template_

Definition at line 332 of file errorpage.h.

Referenced by setDefault().

◆ templateCode

err_type TemplateFile::templateCode

Definition at line 336 of file errorpage.h.

Referenced by TemplateFile::loadDefault(), and TemplateFile::loadFromFile().

◆ templateName

String TemplateFile::templateName

◆ wasLoaded

bool TemplateFile::wasLoaded

The documentation for this class was generated from the following file:






Web Site Translations