#include <errorpage.h>

Collaboration diagram for ErrorState:

Public Member Functions

void * operator new (size_t size)
 
void operator delete (void *address)
 
void * toCbdata () noexcept
 
 ErrorState (err_type type, Http::StatusCode, HttpRequest *request, const AccessLogEntryPointer &al)
 
 ErrorState ()=delete
 
 ~ErrorState ()
 
HttpReplyBuildHttpReply (void)
 
void detailError (int dCode)
 set error type-specific detail code More...
 
void validate ()
 ensures that a future BuildHttpReply() is likely to succeed More...
 

Static Public Member Functions

static ErrorStateNewForwarding (err_type, HttpRequestPointer &, const AccessLogEntryPointer &)
 Creates a general request forwarding error with the right http_status. More...
 

Public Attributes

SBuf inputLocation
 the source of the error template (for reporting purposes) More...
 
err_type type = ERR_NONE
 
int page_id = ERR_NONE
 
char * err_language = nullptr
 
Http::StatusCode httpStatus
 
Auth::UserRequest::Pointer auth_user_request
 
HttpRequestPointer request
 
char * url = nullptr
 
int xerrno = 0
 
unsigned short port = 0
 
String dnsError
 DNS lookup error message. More...
 
time_t ttl = 0
 
Ip::Address src_addr
 
char * redirect_url = nullptr
 
ERCBcallback
 
void * callback_data = nullptr
 
struct {
   wordlist *   server_msg = nullptr
 
   char *   request = nullptr
 
   char *   reply = nullptr
 
   char *   cwd_msg = nullptr
 
   MemBuf *   listing = nullptr
 
ftp
 
char * request_hdrs = nullptr
 
char * err_msg = nullptr
 
AccessLogEntryPointer ale
 transaction details (or nil) More...
 
Ssl::ErrorDetaildetail = nullptr
 
int detailCode = ERR_DETAIL_NONE
 

Private Types

typedef ErrorPage::Build Build
 

Private Member Functions

SBuf buildBody ()
 locates the right error page template for this error and compiles it More...
 
SBuf compileBody (const char *text, bool allowRecursion)
 
void compileLegacyCode (Build &build)
 compile a single-letter code like D More...
 
void compileLogformatCode (Build &build)
 compile {code} sequence containing a single logformat code More...
 
SBuf compile (const char *input, bool building_deny_info_url, bool allowRecursion)
 
void noteBuildError (const char *msg, const char *near)
 
void bypassBuildErrorXXX (const char *msg, const char *near)
 
int Dump (MemBuf *mb)
 
void noteBuildError_ (const char *msg, const char *near, const bool forceBypass)
 

Static Private Attributes

static cbdata_type CBDATA_ErrorState = CBDATA_UNKNOWN
 
static const SBuf LogformatMagic
 marks each embedded logformat entry More...
 

Detailed Description

Definition at line 89 of file errorpage.h.

Member Typedef Documentation

◆ Build

Definition at line 116 of file errorpage.h.

Constructor & Destructor Documentation

◆ ErrorState() [1/2]

ErrorState::ErrorState ( err_type  type,
Http::StatusCode  status,
HttpRequest request,
const AccessLogEntryPointer al 
)

Definition at line 674 of file errorpage.cc.

References HttpRequest::client_addr, ERR_MAX, httpStatus, page_id, request, Http::scNone, and src_addr.

◆ ErrorState() [2/2]

ErrorState::ErrorState ( )
delete

◆ ~ErrorState()

ErrorState::~ErrorState ( )

Member Function Documentation

◆ buildBody()

SBuf ErrorState::buildBody ( )
private

error_directory option in squid.conf overrides translations. Custom errors are always found either in error_directory or the templates directory. Otherwise locate the Accept-Language header

If client-specific error templates are not enabled or available. fall back to the old style squid.conf settings.

Definition at line 1348 of file errorpage.cc.

References assert, compileBody(), Config, debugs, err_language, ERR_MAX, ERR_NONE, err_type_str, SquidConfig::errorDefaultLanguage, SquidConfig::errorDirectory, errorPageName(), TemplateFile::filename, RefCount< C >::getRaw(), inputLocation, TemplateFile::language(), TemplateFile::loadFor(), page_id, request, safe_free, ErrorPageFile::text(), and xstrdup.

Referenced by BuildHttpReply(), and compileLegacyCode().

◆ BuildHttpReply()

◆ bypassBuildErrorXXX()

void ErrorState::bypassBuildErrorXXX ( const char *  msg,
const char *  near 
)
inlineprivate

Note a compile() error but do not throw for backwards compatibility with older configurations that may have such errors. Should eventually be replaced with noteBuildError().

Parameters
msgdescription of what went wrong
nearapproximate start of the problematic input

Definition at line 151 of file errorpage.h.

Referenced by compileLegacyCode().

◆ compile()

SBuf ErrorState::compile ( const char *  input,
bool  building_deny_info_url,
bool  allowRecursion 
)
private

replaces all legacy and logformat codes in the given input

Parameters
inputthe template text to be converted
building_deny_info_urlwhether input is a deny_info URL parameter
allowRecursionwhether to compile codes which produce codes
Returns
the given input with all codes substituted

Definition at line 1390 of file errorpage.cc.

References ErrorPage::Build::allowRecursion, SBuf::append(), assert, ErrorPage::Build::building_deny_info_url, SBuf::cmp(), compileLegacyCode(), compileLogformatCode(), ErrorPage::Build::input, SBuf::length(), LogformatMagic, and ErrorPage::Build::output.

Referenced by BuildHttpReply(), compileBody(), and validate().

◆ compileBody()

SBuf ErrorState::compileBody ( const char *  text,
bool  allowRecursion 
)
private

compiles error page or error detail template (i.e. anything but deny_url)

Parameters
inputthe template text to be compiled
allowRecursionwhether to compile codes which produce codes

Definition at line 1384 of file errorpage.cc.

References compile().

Referenced by buildBody(), compileLegacyCode(), and validate().

◆ compileLegacyCode()

void ErrorState::compileLegacyCode ( Build build)
private

Definition at line 891 of file errorpage.cc.

References addr, SquidConfig::adminEmail, ErrorPage::Build::allowRecursion, MemBuf::append(), SBuf::append(), Packable::appendf(), assert, HttpRequest::auth_user_request, auth_user_request, MemBuf::buf, buildBody(), ErrorPage::Build::building_deny_info_url, bypassBuildErrorXXX(), compileBody(), Config, MemBuf::content(), MemBuf::contentSize(), DBG_CRITICAL, debugs, Auth::UserRequest::denyMessage(), detail, dnsError, Dump(), HttpRequest::effectiveRequestUri(), SquidConfig::emailErrData, err_msg, ERR_SQUID_SIGNATURE, SquidConfig::errHtmlText, Ssl::ErrorDetail::errorName(), errorPageName(), HttpRequest::extacl_message, external_acl_message, FindListeningPortAddress(), Time::FormatHttpd(), ftp, getMyHostname(), getMyPort(), RefCount< C >::getRaw(), AnyP::Uri::getScheme(), Http::Message::header, HttpRequest::hier, HierarchyLogEntry::host, AnyP::Uri::host(), html_quote(), Http::Message::http_ver, AnyP::UriScheme::image(), HttpRequestMethod::image(), ErrorPage::Build::input, SBuf::length(), AnyP::ProtocolVersion::major, MAX_IPSTRLEN, HttpRequest::method, AnyP::ProtocolVersion::minor, mkrfc1123(), NULL, SquidConfig::onoff, ErrorPage::Build::output, p, HttpHeader::packInto(), page_id, AnyP::Uri::path(), AnyP::Uri::port(), AnyP::ProtocolVersion::protocol, AnyP::ProtocolType_str, SBuf::rawContent(), Comm::Connection::remote, request, request_hdrs, MemBuf::reset(), rfc1738_escape_part, String::size(), squid_curtime, SQUIDSBUFPH, SQUIDSBUFPRINT, src_addr, strerror(), HierarchyLogEntry::tcpServer, String::termedBuf(), Ip::Address::toStr(), Ssl::ErrorDetail::toString(), type, HttpRequest::url, url, urlCanonicalFakeHttps(), Ftp::UrlWith2f(), Ssl::ErrorDetail::useRequest(), Auth::UserRequest::username(), visible_appname_string, wordlistCat(), and xerrno.

Referenced by compile().

◆ compileLogformatCode()

◆ detailError()

void ErrorState::detailError ( int  dCode)
inline

◆ Dump()

◆ NewForwarding()

◆ noteBuildError()

void ErrorState::noteBuildError ( const char *  msg,
const char *  near 
)
inlineprivate

React to a compile() error, throwing if buildContext allows.

Parameters
msgdescription of what went wrong
nearapproximate start of the problematic input

Definition at line 142 of file errorpage.h.

Referenced by compileLogformatCode().

◆ noteBuildError_()

void ErrorState::noteBuildError_ ( const char *  msg,
const char *  near,
const bool  forceBypass 
)
private

react to a compile() error

Parameters
msgdescription of what went wrong
nearapproximate start of the problematic input
forceBypasswhether detection of this error was introduced late, after old configurations containing this error could have been successfully validated and deployed (i.e. the admin may not be able to fix this newly detected but old problem quickly)

Definition at line 1426 of file errorpage.cc.

References DBG_CRITICAL, DBG_DATA, debugs, inputLocation, page_id, reconfiguring, starting_up, TexcHere, and ToSBuf().

◆ operator delete()

void ErrorState::operator delete ( void *  address)
inline

Definition at line 91 of file errorpage.h.

◆ operator new()

void* ErrorState::operator new ( size_t  size)
inline

Definition at line 91 of file errorpage.h.

◆ toCbdata()

void* ErrorState::toCbdata ( )
inlinenoexcept

Definition at line 91 of file errorpage.h.

◆ validate()

void ErrorState::validate ( )

Member Data Documentation

◆ ale

AccessLogEntryPointer ErrorState::ale

Definition at line 193 of file errorpage.h.

Referenced by compileLogformatCode().

◆ auth_user_request

Auth::UserRequest::Pointer ErrorState::auth_user_request

Definition at line 168 of file errorpage.h.

Referenced by ClientHttpRequest::calloutsError(), compileLegacyCode(), and Dump().

◆ callback

ERCB* ErrorState::callback

Definition at line 179 of file errorpage.h.

Referenced by errorSendComplete(), and TunnelStateData::sendError().

◆ callback_data

void* ErrorState::callback_data = nullptr

◆ cwd_msg

char* ErrorState::cwd_msg = nullptr

Definition at line 186 of file errorpage.h.

◆ detail

◆ detailCode

int ErrorState::detailCode = ERR_DETAIL_NONE

type-specific detail about the transaction error; overwrites xerrno; overwritten by detail, if any.

Definition at line 200 of file errorpage.h.

Referenced by BuildHttpReply().

◆ dnsError

String ErrorState::dnsError

Definition at line 174 of file errorpage.h.

Referenced by compileLegacyCode(), and Dump().

◆ err_language

char* ErrorState::err_language = nullptr

Definition at line 165 of file errorpage.h.

Referenced by buildBody(), BuildHttpReply(), and ~ErrorState().

◆ err_msg

char* ErrorState::err_msg = nullptr

Definition at line 191 of file errorpage.h.

Referenced by compileLegacyCode(), ESIContext::fail(), and ~ErrorState().

◆ ftp

◆ httpStatus

◆ inputLocation

SBuf ErrorState::inputLocation

◆ listing

MemBuf* ErrorState::listing = nullptr

Definition at line 187 of file errorpage.h.

Referenced by Ftp::Gateway::completedListing().

◆ LogformatMagic

const SBuf ErrorState::LogformatMagic
staticprivate

Definition at line 205 of file errorpage.h.

Referenced by compile(), and compileLogformatCode().

◆ page_id

◆ port

unsigned short ErrorState::port = 0

Definition at line 173 of file errorpage.h.

◆ redirect_url

char* ErrorState::redirect_url = nullptr

Definition at line 178 of file errorpage.h.

Referenced by ~ErrorState().

◆ reply

char* ErrorState::reply = nullptr

Definition at line 185 of file errorpage.h.

Referenced by Ftp::Client::failed().

◆ request [1/2]

◆ request [2/2]

char* ErrorState::request = nullptr

Definition at line 184 of file errorpage.h.

◆ request_hdrs

char* ErrorState::request_hdrs = nullptr

Definition at line 190 of file errorpage.h.

Referenced by compileLegacyCode(), and ~ErrorState().

◆ server_msg

wordlist* ErrorState::server_msg = nullptr

Definition at line 183 of file errorpage.h.

Referenced by Ftp::Client::failed().

◆ src_addr

Ip::Address ErrorState::src_addr

Definition at line 177 of file errorpage.h.

Referenced by compileLegacyCode(), Dump(), and ErrorState().

◆ ttl

time_t ErrorState::ttl = 0

Definition at line 175 of file errorpage.h.

◆ type

err_type ErrorState::type = ERR_NONE

◆ url

char* ErrorState::url = nullptr

Definition at line 171 of file errorpage.h.

Referenced by compileLegacyCode(), CacheManager::start(), urnHandleReply(), and ~ErrorState().

◆ xerrno


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors