1 #ifndef _SQUID_SSL_ERRORDETAILMANAGER_H
2 #define _SQUID_SSL_ERRORDETAILMANAGER_H
4 #include "base/RefCount.h"
5 #include "ssl/gadgets.h"
6 #include "ssl/support.h"
7 #include "SquidString.h"
21 class ErrorDetailEntry
24 Ssl::ssl_error_t error_no
; ///< The SSL error code
25 String name
; ///< a name for the error
26 String detail
; ///< for error page %D macro expansion; may contain macros
27 String descr
; ///< short error description (for use in debug messages or error pages)
31 * Used to hold an error-details.txt template in ram. An error-details,.txt is represented
32 * by a list of error detail entries (ErrorDetailEntry objects).
34 class ErrorDetailsList
: public RefCountable
37 typedef RefCount
<ErrorDetailsList
> Pointer
;
39 * Retrieves the error details for a given error to "entry" object
40 * \return true on success, false otherwise
42 bool getRecord(Ssl::ssl_error_t value
, ErrorDetailEntry
&entry
);
43 const char *getErrorDescr(Ssl::ssl_error_t value
); ///< an error description for an error if exist in list.
44 const char *getErrorDetail(Ssl::ssl_error_t value
); ///< an error details for an error if exist in list.
46 String errLanguage
; ///< The language of the error-details.txt template, if any
47 typedef std::map
<Ssl::ssl_error_t
, ErrorDetailEntry
> ErrorDetails
;
48 ErrorDetails theList
; ///< The list of error details entries
52 * It is used to load, manage and query multiple ErrorDetailLists
55 class ErrorDetailsManager
58 ErrorDetailsManager();
60 static ErrorDetailsManager
&GetInstance(); ///< Instance class
61 static void Shutdown(); ///< reset the ErrorDetailsManager instance
64 * Retrieve error details for an error. This method examine the Accept-Language
65 * of the request to retrieve the error details for requested language else return
66 * the default error details.
67 * \param vale the error code
68 * \param request the current HTTP request.
69 * \param entry where to store error details
70 * \return true on success, false otherwise
72 bool getErrorDetail(Ssl::ssl_error_t value
, const HttpRequest::Pointer
&request
, ErrorDetailEntry
&entry
);
73 const char *getDefaultErrorDescr(Ssl::ssl_error_t value
); ///< the default error description for a given error
74 const char *getDefaultErrorDetail(Ssl::ssl_error_t value
); ///< the default error details for a given error
77 /// Return cached error details list for a given language if exist
78 ErrorDetailsList::Pointer
getCachedDetails(const char *lang
);
79 /// cache the given error details list.
80 void cacheDetails(ErrorDetailsList::Pointer
&errorDetails
);
82 typedef std::map
<std::string
, ErrorDetailsList::Pointer
> Cache
;
83 Cache cache
; ///< the error details list cache
84 ErrorDetailsList::Pointer theDefaultErrorDetails
; ///< the default error details list
86 /// An instance of ErrorDetailsManager to be used by squid (ssl/ErrorDetails.*)
87 static ErrorDetailsManager
*TheDetailsManager
;
90 void errorDetailInitialize();
91 void errorDetailClean();