]> git.ipfire.org Git - thirdparty/squid.git/blame - src/ssl/ErrorDetailManager.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / ssl / ErrorDetailManager.h
CommitLineData
bbc27441 1/*
bde978a6 2 * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
bbc27441
AJ
3 *
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.
7 */
8
02259ff8
CT
9#ifndef _SQUID_SSL_ERRORDETAILMANAGER_H
10#define _SQUID_SSL_ERRORDETAILMANAGER_H
11
8bf217bd 12#include "base/RefCount.h"
f1d156fa 13#include "HttpRequest.h"
3d41e53a 14#include "SquidString.h"
602d9612 15#include "ssl/support.h"
3d41e53a 16
02259ff8 17#include <map>
02259ff8 18#include <string>
02259ff8 19
3d41e53a
FC
20class HttpRequest;
21
02259ff8
CT
22namespace Ssl
23{
24
dc49061a
A
25class ErrorDetailEntry
26{
02259ff8
CT
27public:
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)
32};
33
34/**
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).
37 */
38class ErrorDetailsList : public RefCountable
39{
40public:
41 typedef RefCount<ErrorDetailsList> Pointer;
42 /**
43 * Retrieves the error details for a given error to "entry" object
44 * \return true on success, false otherwise
45 */
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.
49
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
53};
54
55/**
56 * It is used to load, manage and query multiple ErrorDetailLists
57 * objects.
58 */
dc49061a
A
59class ErrorDetailsManager
60{
02259ff8
CT
61public:
62 ErrorDetailsManager();
63
64 static ErrorDetailsManager &GetInstance(); ///< Instance class
65 static void Shutdown(); ///< reset the ErrorDetailsManager instance
66
67 /**
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
75 */
b248c2a3 76 bool getErrorDetail(Ssl::ssl_error_t value, const HttpRequest::Pointer &request, ErrorDetailEntry &entry);
02259ff8
CT
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
79
80private:
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);
85
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
89
90 /// An instance of ErrorDetailsManager to be used by squid (ssl/ErrorDetails.*)
91 static ErrorDetailsManager *TheDetailsManager;
92};
93
02259ff8
CT
94void errorDetailInitialize();
95void errorDetailClean();
96} //namespace Ssl
97#endif
f53969cc 98