#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...
 
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 bool parse ()
 post-process the loaded template More...
 
virtual void setDefault ()
 recover from loadDefault() failure to load or parse() a 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

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

Definition at line 280 of file errorpage.h.

Constructor & Destructor Documentation

◆ TemplateFile()

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

Definition at line 350 of file errorpage.cc.

References assert.

◆ ~TemplateFile()

virtual TemplateFile::~TemplateFile ( )
inlinevirtual

Definition at line 284 of file errorpage.h.

Member Function Documentation

◆ language()

const char * TemplateFile::language ( )
inline

Definition at line 313 of file errorpage.h.

References errLanguage, and String::termedBuf().

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

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

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

Referenced by Ssl::ErrorDetailsManager::ErrorDetailsManager().

◆ loaded()

bool TemplateFile::loaded ( ) const
inline

Definition at line 287 of file errorpage.h.

References wasLoaded.

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

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

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

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

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

Referenced by loadDefault(), and tryLoadTemplate().

◆ parse()

virtual bool TemplateFile::parse ( )
inlineprotectedvirtual

Reimplemented in Ssl::ErrorDetailFile.

Definition at line 321 of file errorpage.h.

Referenced by loadFromFile().

◆ setDefault()

virtual void TemplateFile::setDefault ( )
inlineprotectedvirtual

Reimplemented in ErrorPageFile.

Definition at line 324 of file errorpage.h.

Referenced by loadDefault().

◆ tryLoadTemplate()

bool TemplateFile::tryLoadTemplate ( const char *  lang)
protected

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

Returns
true on success false otherwise

Definition at line 392 of file errorpage.cc.

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

Referenced by loadDefault(), and loadFor().

Member Data Documentation

◆ errLanguage

String TemplateFile::errLanguage
protected

Definition at line 335 of file errorpage.h.

Referenced by language(), and loadFor().

◆ filename

SBuf TemplateFile::filename

Definition at line 315 of file errorpage.h.

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

◆ silent

bool TemplateFile::silent

Definition at line 317 of file errorpage.h.

Referenced by loadFromFile().

◆ template_

SBuf TemplateFile::template_
protected

Definition at line 333 of file errorpage.h.

Referenced by ErrorPageFile::setDefault().

◆ templateCode

err_type TemplateFile::templateCode
protected

Definition at line 337 of file errorpage.h.

Referenced by loadDefault(), and loadFromFile().

◆ templateName

String TemplateFile::templateName
protected

Definition at line 336 of file errorpage.h.

Referenced by loadDefault(), ErrorPageFile::setDefault(), and tryLoadTemplate().

◆ wasLoaded

bool TemplateFile::wasLoaded
protected

Definition at line 334 of file errorpage.h.

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


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors