#include <errorpage.h>

Inheritance diagram for TemplateFile:
Collaboration diagram for TemplateFile:

Public Member Functions

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

Public Attributes

bool silent
 Whether to print error messages on cache.log file or not. It is user defined. More...

Protected Member Functions

virtual bool parse (const char *buf, int len, bool eof)=0
 Used to parse (if parsing required) the template data . More...
bool tryLoadTemplate (const char *lang)

Protected Attributes

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

loads text templates used for error pages and details; supports translation of templates

Definition at line 243 of file errorpage.h.

Constructor & Destructor Documentation

◆ TemplateFile()

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

Definition at line 251 of file errorpage.cc.

References assert.

◆ ~TemplateFile()

virtual TemplateFile::~TemplateFile ( )

Definition at line 247 of file errorpage.h.

Member Function Documentation

◆ language()

const char* TemplateFile::language ( )

◆ loadDefault()

bool 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

test error_directory configured location

test error_default_language location

Definition at line 257 of file errorpage.cc.

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

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

◆ loaded()

bool TemplateFile::loaded ( ) const

Definition at line 250 of file errorpage.h.

References ErrorState::request.

Referenced by loadDefault(), loadFor(), and loadFromFile().

◆ 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 414 of file errorpage.cc.

References Http::ACCEPT_LANGUAGE, Config, DBG_IMPORTANT, debugs, errLanguage, SquidConfig::errorLogMissingLanguages, HttpHeader::getList(), Http::Message::header, HERE(), loaded(), strHdrAcptLangGetItem(), and tryLoadTemplate().

Referenced by ErrorState::BuildContent(), 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 319 of file errorpage.cc.

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

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

◆ parse()

virtual bool TemplateFile::parse ( const char *  buf,
int  len,
bool  eof 
protectedpure virtual

Implemented in ErrorPageFile, and Ssl::ErrorDetailFile.

Referenced by loadDefault(), and loadFromFile().

◆ 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 294 of file errorpage.cc.

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

Referenced by loadDefault(), and loadFor().

Member Data Documentation

◆ errLanguage

String TemplateFile::errLanguage

Definition at line 291 of file errorpage.h.

Referenced by loadFor().

◆ silent

bool TemplateFile::silent

Definition at line 277 of file errorpage.h.

Referenced by loadFromFile().

◆ templateCode

err_type TemplateFile::templateCode

Definition at line 293 of file errorpage.h.

Referenced by loadDefault(), and loadFromFile().

◆ templateName

String TemplateFile::templateName

Definition at line 292 of file errorpage.h.

Referenced by loadDefault(), and tryLoadTemplate().

◆ wasLoaded

bool TemplateFile::wasLoaded

Definition at line 290 of file errorpage.h.

Referenced by loadFromFile().

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






Web Site Translations