34 if (!parser.
hasNamed(fieldName, strlen(fieldName), &fieldValue))
61 bool parse()
override;
69 const ErrorDetails::const_iterator it = theList.find(value);
70 return it != theList.end() ? &it->second :
nullptr;
77 if (!TheDetailsManager)
81 return *TheDetailsManager;
86 delete TheDetailsManager;
87 TheDetailsManager =
nullptr;
101 it = cache.find(
SBuf(lang));
102 if (it != cache.end()) {
103 debugs(83, 8,
"Found template details in cache for language: " << lang);
114 if (cache.find(lang) == cache.end())
115 cache[lang] = errorDetails;
130 errDetails = getCachedDetails(lang);
133 debugs(83, 8,
"Creating new ErrDetailList to read from disk");
138 debugs(83, 8,
"Found details on disk for language " << detailTmpl.
language());
140 cacheDetails(errDetails);
146 if (
const auto entry = errDetails->
findRecord(value))
153 return findDefaultDetail(value);
159 return theDefaultErrorDetails->findRecord(value);
179 auto buf = template_;
183 auto *s = buf.c_str();
184 const auto e = s +
size;
187 for (; (*s ==
'\n' || *s ==
' ' || *s ==
'\t' || *s ==
'#') && s < e; ++s) {
189 while (s<e && *s !=
'\n')
197 if (!parser.
parse(s, e - s, interpreter)) {
203 if (!errorName.
size()) {
209 if (ssl_error != SSL_ERROR_NONE) {
211 if (theDetails->findRecord(ssl_error)) {
217 theDetails->theList.try_emplace(ssl_error,
StringToSBuf(errorName), parser);
236 debugs(83, 9,
Raw(
"unparsed data", buf.rawContent(), buf.length()));
static SBuf SlowlyParseQuotedField(const char *const description, const HttpHeader &parser, const char *const fieldName)
ErrorDetailEntry constructor helper that extracts a quoted HTTP field value.
size_t detailEntryEnd(const char *s, size_t len)
#define Here()
source code location of the caller
SBuf StringToSBuf(const String &s)
create a new SBuf from a String by copying contents
std::ostream & CurrentException(std::ostream &os)
prints active (i.e., thrown but not yet handled) exception
ErrorDetailEntry(const SBuf &aName, const HttpHeader &)
extracts quoted detail and descr fields from the given header
manages error detail templates
ErrorDetailFile(ErrorDetailsList::Pointer const details)
ErrorDetailsList::Pointer theDetails
bool parse() override
post-process the loaded template
SBuf errLanguage
The language of the error-details.txt template, if any.
const ErrorDetailEntry * findRecord(Security::ErrorCode) const
static void Shutdown()
reset the ErrorDetailsManager instance
ErrorDetailsList::Pointer getCachedDetails(const char *lang) const
Return cached error details list for a given language if exist.
const ErrorDetailEntry * findDefaultDetail(Security::ErrorCode) const
static ErrorDetailsManager * TheDetailsManager
An instance of ErrorDetailsManager to be used by squid (ssl/ErrorDetails.*)
static ErrorDetailsManager & GetInstance()
Instance class.
void cacheDetails(const ErrorDetailsList::Pointer &errorDetails) const
cache the given error details list.
const ErrorDetailEntry * findDetail(Security::ErrorCode value, const HttpRequest::Pointer &request) const
char const * termedBuf() const
const char * language()
The language used for the template.
bool loadFor(const HttpRequest *request)
an std::runtime_error with thrower location info
#define debugs(SECTION, LEVEL, CONTENT)
bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos)
SBuf SlowlyParseQuotedString(const char *description, const char *start, size_t length)
int ErrorCode
Squid-defined error code (<0), an error code returned by X.509 API, or zero.
bool ErrorIsOptional(const char *name)
Security::ErrorCode GetErrorCode(const char *name)
The Security::ErrorCode code of the error described by "name".
void errorDetailInitialize()
SBuf ToSBuf(Args &&... args)
slowly stream-prints all arguments into a freshly allocated SBuf