#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)
 creates an error of type other than ERR_RELAY_REMOTE More...
 
 ErrorState ()=delete
 
 ErrorState (HttpRequest *request, HttpReply *, const AccessLogEntryPointer &)
 creates an ERR_RELAY_REMOTE error More...
 
 ~ErrorState ()
 
HttpReplyBuildHttpReply (void)
 
void detailError (const ErrorDetail::Pointer &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 = Http::scNone
 
Auth::UserRequest::Pointer auth_user_request
 
HttpRequestPointer request
 
char * url = nullptr
 
int xerrno = 0
 
std::optional< SBufdnsError
 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...
 
ErrorDetail::Pointer detail
 
HttpReplyPointer response_
 

Private Types

typedef ErrorPage::Build Build
 

Private Member Functions

 ErrorState (err_type, const AccessLogEntryPointer &)
 initializations shared by public constructors More...
 
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 @Squid{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 88 of file errorpage.h.

Member Typedef Documentation

◆ Build

Definition at line 120 of file errorpage.h.

Constructor & Destructor Documentation

◆ ErrorState() [1/4]

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

◆ ErrorState() [2/4]

ErrorState::ErrorState ( )
delete

Referenced by NewForwarding().

◆ ErrorState() [3/4]

ErrorState::ErrorState ( HttpRequest request,
HttpReply errorReply,
const AccessLogEntryPointer anAle 
)

◆ ~ErrorState()

ErrorState::~ErrorState ( )

◆ ErrorState() [4/4]

ErrorState::ErrorState ( err_type  t,
const AccessLogEntryPointer anAle 
)
private

Definition at line 681 of file errorpage.cc.

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

References assert, compileBody(), Config, debugs, err_language, ERR_MAX, ERR_NONE, err_type_str, error_page_count, error_text, SquidConfig::errorDefaultLanguage, SquidConfig::errorDirectory, 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 158 of file errorpage.h.

References noteBuildError_().

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

References compile().

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

◆ compileLegacyCode()

void ErrorState::compileLegacyCode ( Build build)
private

Definition at line 912 of file errorpage.cc.

References SquidConfig::adminEmail, ErrorPage::Build::allowRecursion, MemBuf::append(), SBuf::append(), Packable::appendf(), assert, auth_user_request, HttpRequest::auth_user_request, ErrorDetail::brief(), 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, error_stylesheet, errorPageName(), HttpRequest::extacl_message, external_acl_message, FindListeningPortAddress(), Time::FormatHttpd(), Time::FormatRfc1123(), ftp, getMyHostname(), getMyPort(), RefCount< C >::getRaw(), AnyP::Uri::getScheme(), Http::Message::header, HttpRequest::hier, AnyP::Uri::host(), HierarchyLogEntry::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, SquidConfig::onoff, ErrorPage::Build::output, 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, squid_curtime, SQUIDSBUFPH, SQUIDSBUFPRINT, src_addr, strerror(), HierarchyLogEntry::tcpServer, String::termedBuf(), Ip::Address::toStr(), type, url, HttpRequest::url, urlCanonicalFakeHttps(), Ftp::UrlWith2f(), Auth::UserRequest::username(), ErrorDetail::verbose(), visible_appname_string, wordlistCat(), and xerrno.

Referenced by compile().

◆ compileLogformatCode()

◆ detailError()

void ErrorState::detailError ( const ErrorDetail::Pointer 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 149 of file errorpage.h.

References noteBuildError_().

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

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

Referenced by bypassBuildErrorXXX(), and noteBuildError().

◆ operator delete()

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

Definition at line 90 of file errorpage.h.

◆ operator new()

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

Definition at line 90 of file errorpage.h.

◆ toCbdata()

void * ErrorState::toCbdata ( )
inlinenoexcept

Definition at line 90 of file errorpage.h.

◆ validate()

void ErrorState::validate ( )

Member Data Documentation

◆ ale

AccessLogEntryPointer ErrorState::ale

Definition at line 199 of file errorpage.h.

Referenced by BuildHttpReply(), compileLogformatCode(), and NewForwarding().

◆ auth_user_request

◆ callback

ERCB* ErrorState::callback

Definition at line 185 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 192 of file errorpage.h.

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

◆ detail

ErrorDetail::Pointer ErrorState::detail

type-specific detail about the transaction error; overwrites xerrno;

Definition at line 205 of file errorpage.h.

Referenced by BuildHttpReply(), compileLegacyCode(), detailError(), and FwdState::updateAleWithFinalError().

◆ dnsError

std::optional<SBuf> ErrorState::dnsError

Definition at line 180 of file errorpage.h.

Referenced by compileLegacyCode(), Dump(), and PeerSelector::noteIps().

◆ err_language

char* ErrorState::err_language = nullptr

Definition at line 172 of file errorpage.h.

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

◆ err_msg

char* ErrorState::err_msg = nullptr

Definition at line 197 of file errorpage.h.

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

◆ 

◆ httpStatus

◆ inputLocation

SBuf ErrorState::inputLocation

Definition at line 117 of file errorpage.h.

Referenced by buildBody(), noteBuildError_(), and ErrorPage::ValidateStaticError().

◆ listing

MemBuf* ErrorState::listing = nullptr

Definition at line 193 of file errorpage.h.

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

◆ LogformatMagic

const SBuf ErrorState::LogformatMagic
staticprivate

Definition at line 212 of file errorpage.h.

Referenced by compile(), and compileLogformatCode().

◆ page_id

◆ redirect_url

char* ErrorState::redirect_url = nullptr

Definition at line 184 of file errorpage.h.

Referenced by ~ErrorState().

◆ reply

char* ErrorState::reply = nullptr

Definition at line 191 of file errorpage.h.

Referenced by Ftp::Client::failed(), and ftpSendReply().

◆ request [1/2]

◆ request [2/2]

char* ErrorState::request = nullptr

Definition at line 190 of file errorpage.h.

◆ request_hdrs

char* ErrorState::request_hdrs = nullptr

Definition at line 196 of file errorpage.h.

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

◆ response_

HttpReplyPointer ErrorState::response_

Definition at line 207 of file errorpage.h.

Referenced by ErrorState(), and BuildHttpReply().

◆ server_msg

wordlist* ErrorState::server_msg = nullptr

Definition at line 189 of file errorpage.h.

Referenced by Ftp::Gateway::completedListing(), and Ftp::Client::failed().

◆ src_addr

Ip::Address ErrorState::src_addr

Definition at line 183 of file errorpage.h.

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

◆ ttl

time_t ErrorState::ttl = 0

Definition at line 181 of file errorpage.h.

◆ type

◆ url

char* ErrorState::url = nullptr

Definition at line 178 of file errorpage.h.

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

◆ xerrno


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

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors