2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
9 #ifndef _SQUID_SSL_ERRORDETAILMANAGER_H
10 #define _SQUID_SSL_ERRORDETAILMANAGER_H
12 #include "base/RefCount.h"
13 #include "HttpRequest.h"
14 #include "SquidString.h"
15 #include "ssl/support.h"
25 class ErrorDetailEntry
28 Ssl::ssl_error_t error_no
; ///< The SSL error code
29 String name
; ///< a name for the error
30 String detail
; ///< for error page %D macro expansion; may contain macros
31 String descr
; ///< short error description (for use in debug messages or error pages)
35 * Used to hold an error-details.txt template in ram. An error-details,.txt is represented
36 * by a list of error detail entries (ErrorDetailEntry objects).
38 class ErrorDetailsList
: public RefCountable
41 typedef RefCount
<ErrorDetailsList
> Pointer
;
43 * Retrieves the error details for a given error to "entry" object
44 * \return true on success, false otherwise
46 bool getRecord(Ssl::ssl_error_t value
, ErrorDetailEntry
&entry
);
47 const char *getErrorDescr(Ssl::ssl_error_t value
); ///< an error description for an error if exist in list.
48 const char *getErrorDetail(Ssl::ssl_error_t value
); ///< an error details for an error if exist in list.
50 String errLanguage
; ///< The language of the error-details.txt template, if any
51 typedef std::map
<Ssl::ssl_error_t
, ErrorDetailEntry
> ErrorDetails
;
52 ErrorDetails theList
; ///< The list of error details entries
56 * It is used to load, manage and query multiple ErrorDetailLists
59 class ErrorDetailsManager
62 ErrorDetailsManager();
64 static ErrorDetailsManager
&GetInstance(); ///< Instance class
65 static void Shutdown(); ///< reset the ErrorDetailsManager instance
68 * Retrieve error details for an error. This method examine the Accept-Language
69 * of the request to retrieve the error details for requested language else return
70 * the default error details.
71 * \param vale the error code
72 * \param request the current HTTP request.
73 * \param entry where to store error details
74 * \return true on success, false otherwise
76 bool getErrorDetail(Ssl::ssl_error_t value
, const HttpRequest::Pointer
&request
, ErrorDetailEntry
&entry
);
77 const char *getDefaultErrorDescr(Ssl::ssl_error_t value
); ///< the default error description for a given error
78 const char *getDefaultErrorDetail(Ssl::ssl_error_t value
); ///< the default error details for a given error
81 /// Return cached error details list for a given language if exist
82 ErrorDetailsList::Pointer
getCachedDetails(const char *lang
);
83 /// cache the given error details list.
84 void cacheDetails(ErrorDetailsList::Pointer
&errorDetails
);
86 typedef std::map
<std::string
, ErrorDetailsList::Pointer
> Cache
;
87 Cache cache
; ///< the error details list cache
88 ErrorDetailsList::Pointer theDefaultErrorDetails
; ///< the default error details list
90 /// An instance of ErrorDetailsManager to be used by squid (ssl/ErrorDetails.*)
91 static ErrorDetailsManager
*TheDetailsManager
;
94 void errorDetailInitialize();
95 void errorDetailClean();