#include <errorpage.h>
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 () | |
HttpReply * | BuildHttpReply (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 ErrorState * | NewForwarding (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< SBuf > | dnsError |
DNS lookup error message. More... | |
time_t | ttl = 0 |
Ip::Address | src_addr |
char * | redirect_url = nullptr |
ERCB * | callback |
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
|
private |
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 | ||
) |
Definition at line 689 of file errorpage.cc.
References HttpRequest::client_addr, ERR_MAX, ErrorDynamicPages, httpStatus, page_id, request, Http::scNone, and src_addr.
◆ ErrorState() [2/4]
|
delete |
Referenced by NewForwarding().
◆ ErrorState() [3/4]
ErrorState::ErrorState | ( | HttpRequest * | request, |
HttpReply * | errorReply, | ||
const AccessLogEntryPointer & | anAle | ||
) |
Definition at line 703 of file errorpage.cc.
References HttpRequest::client_addr, httpStatus, Must, request, response_, HttpReply::sline, src_addr, and Http::StatusLine::status().
◆ ~ErrorState()
ErrorState::~ErrorState | ( | ) |
Definition at line 790 of file errorpage.cc.
References Config, err_language, err_msg, SquidConfig::errorDefaultLanguage, ftp, redirect_url, request_hdrs, safe_free, url, and wordlistDestroy().
◆ ErrorState() [4/4]
|
private |
Definition at line 681 of file errorpage.cc.
Member Function Documentation
◆ 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()
HttpReply * ErrorState::BuildHttpReply | ( | void | ) |
Allocates and initializes an error response
Definition at line 1277 of file errorpage.cc.
References ale, HttpReply::body, buildBody(), compile(), Config, Http::CONTENT_LANGUAGE, detail, err_language, HttpRequest::error, SquidConfig::errorDirectory, errorPageName(), RefCount< C >::getRaw(), Http::Message::header, Http::Message::http_ver, httpHeaderPutStrf(), httpStatus, ErrorPage::IsDenyInfoUri(), Http::LOCATION, HttpRequest::method, Http::METHOD_GET, Http::METHOD_HEAD, SysErrorDetail::NewIfAny(), page_id, Http::ProtocolVersion(), HttpHeader::putStr(), request, response_, Http::scFound, Http::scTemporaryRedirect, HttpBody::set(), HttpReply::setHeaders(), type, Error::update(), AccessLogEntry::updateError(), HttpHeader::updateOrAddStr(), Http::VARY, Http::X_SQUID_ERROR, and xerrno.
Referenced by Ftp::Gateway::completedListing(), errorAppendEntry(), errorSend(), Ftp::Gateway::ftpAuthRequired(), ftpSendReply(), Ftp::Gateway::loginFailed(), Mgr::Inquirer::start(), and CacheManager::start().
◆ bypassBuildErrorXXX()
|
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
-
msg description of what went wrong near approximate start of the problematic input
Definition at line 158 of file errorpage.h.
References noteBuildError_().
Referenced by compileLegacyCode().
◆ compile()
|
private |
replaces all legacy and logformat codes in the given input
- Parameters
-
input the template text to be converted building_deny_info_url whether input is a deny_info URL parameter allowRecursion whether 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()
|
private |
compiles error page or error detail template (i.e. anything but deny_url)
- Parameters
-
input the template text to be compiled allowRecursion whether to compile codes which produce codes
Definition at line 1398 of file errorpage.cc.
References compile().
Referenced by buildBody(), compileLegacyCode(), and validate().
◆ compileLegacyCode()
|
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()
|
private |
Definition at line 876 of file errorpage.cc.
References ale, SBuf::append(), Format::AssembleOne(), assert, SBuf::cmp(), MemBuf::content(), MemBuf::contentSize(), ErrorPage::Build::input, SBuf::length(), LogformatMagic, noteBuildError(), ErrorPage::Build::output, MemBuf::reset(), and TexcHere.
Referenced by compile().
◆ detailError()
|
inline |
Definition at line 111 of file errorpage.h.
References detail.
Referenced by ClientHttpRequest::calloutsError(), ftpSendReply(), Security::PeerConnector::sslCrtvdHandleReply(), and FwdState::updateAleWithFinalError().
◆ Dump()
CacheManager / Debug dump of the ErrorState object. Writes output into the given MemBuf.
- Return values
-
0 successful completion.
Definition at line 806 of file errorpage.cc.
References MemBuf::append(), Packable::appendf(), auth_user_request, MemBuf::buf, MemBuf::clean(), Auth::UserRequest::denyMessage(), dnsError, errorPageName(), Time::FormatRfc1123(), ftp, getMyHostname(), RefCount< C >::getRaw(), Http::Message::header, HttpRequest::hier, HierarchyLogEntry::host, Http::Message::http_ver, HttpRequestMethod::image(), AnyP::ProtocolVersion::major, MAX_IPSTRLEN, HttpRequest::method, AnyP::ProtocolVersion::minor, HttpHeader::packInto(), AnyP::Uri::path(), AnyP::ProtocolVersion::protocol, AnyP::ProtocolType_str, request, MemBuf::reset(), rfc1738_escape_part, squid_curtime, SQUIDSBUFPH, SQUIDSBUFPRINT, src_addr, strerror(), Ip::Address::toStr(), type, HttpRequest::url, wordlistCat(), and xerrno.
Referenced by compileLegacyCode().
◆ NewForwarding()
|
static |
Definition at line 674 of file errorpage.cc.
References ErrorState(), ale, HttpRequest::flags, RefCount< C >::getRaw(), RequestFlags::needValidation, request, Http::scGatewayTimeout, Http::scServiceUnavailable, and type.
Referenced by ConnStateData::BorrowPinnedConnection(), ConnStateData::borrowPinnedConnection(), and Security::PeerConnector::noteNegotiationError().
◆ noteBuildError()
|
inlineprivate |
React to a compile() error, throwing if buildContext allows.
- Parameters
-
msg description of what went wrong near approximate start of the problematic input
Definition at line 149 of file errorpage.h.
References noteBuildError_().
Referenced by compileLogformatCode().
◆ noteBuildError_()
|
private |
react to a compile() error
- Parameters
-
msg description of what went wrong near approximate start of the problematic input forceBypass whether 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()
|
inline |
Definition at line 90 of file errorpage.h.
◆ operator new()
|
inline |
Definition at line 90 of file errorpage.h.
◆ toCbdata()
|
inlinenoexcept |
Definition at line 90 of file errorpage.h.
◆ validate()
void ErrorState::validate | ( | ) |
Definition at line 1265 of file errorpage.cc.
References assert, compile(), compileBody(), ERR_NONE, error_page_count, error_text, ErrorPage::IsDenyInfoUri(), and page_id.
Referenced by ErrorPage::ValidateStaticError().
Member Data Documentation
◆ ale
AccessLogEntryPointer ErrorState::ale |
Definition at line 199 of file errorpage.h.
Referenced by BuildHttpReply(), compileLogformatCode(), and NewForwarding().
◆ auth_user_request
Auth::UserRequest::Pointer ErrorState::auth_user_request |
Definition at line 175 of file errorpage.h.
Referenced by ClientHttpRequest::calloutsError(), ClientRequestContext::clientAccessCheckDone(), compileLegacyCode(), and Dump().
◆ 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 |
Definition at line 186 of file errorpage.h.
Referenced by errorSendComplete(), TunnelStateData::sendError(), and clientReplyContext::setReplyToError().
◆ 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().
◆
struct { ... } ErrorState::ftp |
Referenced by ~ErrorState(), compileLegacyCode(), Ftp::Gateway::completedListing(), Dump(), Ftp::Client::failed(), and ftpSendReply().
◆ httpStatus
Http::StatusCode ErrorState::httpStatus = Http::scNone |
Definition at line 173 of file errorpage.h.
Referenced by ErrorState(), BuildHttpReply(), FwdState::fail(), Ftp::Client::failed(), HappyConnOpener::handleConnOpenerAnswer(), TunnelStateData::retryOrBail(), TunnelStateData::sendError(), clientReplyContext::setReplyToError(), and ClientRequestContext::sslBumpAccessCheck().
◆ 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
|
staticprivate |
Definition at line 212 of file errorpage.h.
Referenced by compile(), and compileLogformatCode().
◆ page_id
Definition at line 171 of file errorpage.h.
Referenced by ErrorState(), buildBody(), BuildHttpReply(), compileLegacyCode(), errorAppendEntry(), noteBuildError_(), operator<<(), and validate().
◆ 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]
HttpRequestPointer ErrorState::request |
Definition at line 177 of file errorpage.h.
Referenced by ErrorState(), buildBody(), BuildHttpReply(), compileLegacyCode(), Dump(), errorAppendEntry(), FwdState::fail(), Ftp::Client::failed(), ftpSendReply(), and NewForwarding().
◆ 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
Definition at line 170 of file errorpage.h.
Referenced by BuildHttpReply(), compileLegacyCode(), Dump(), FwdState::fail(), Ftp::Client::failed(), NewForwarding(), FwdState::reactToZeroSizeObject(), ClientRequestContext::sslBumpAccessCheck(), and FwdState::updateAleWithFinalError().
◆ url
char* ErrorState::url = nullptr |
Definition at line 178 of file errorpage.h.
Referenced by ~ErrorState(), compileLegacyCode(), CacheManager::start(), and urnHandleReply().
◆ xerrno
int ErrorState::xerrno = 0 |
Definition at line 179 of file errorpage.h.
Referenced by BuildHttpReply(), compileLegacyCode(), Dump(), Ftp::Client::failed(), HappyConnOpener::handleConnOpenerAnswer(), Client::sentRequestBody(), and FwdState::updateAleWithFinalError().
The documentation for this class was generated from the following files:
- src/errorpage.h
- src/errorpage.cc