]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/errorpage.h
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / errorpage.h
index 002db460d65822a8375ccaa3fb3c61b8e5e62d2e..3218000cdcb229794a51bcf38cf0b1ed72a9a4e3 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -13,8 +13,8 @@
 
 #include "cbdata.h"
 #include "comm/forward.h"
-#include "err_detail_type.h"
-#include "err_type.h"
+#include "error/Detail.h"
+#include "error/forward.h"
 #include "http/forward.h"
 #include "http/StatusCode.h"
 #include "ip/Address.h"
@@ -23,9 +23,6 @@
 #include "SquidString.h"
 /* auth/UserRequest.h is empty unless USE_AUTH is defined */
 #include "auth/UserRequest.h"
-#if USE_OPENSSL
-#include "ssl/ErrorDetail.h"
-#endif
 
 /// error page callback
 typedef void ERCB(int fd, void *, size_t);
@@ -91,8 +88,13 @@ class ErrorState
     CBDATA_CLASS(ErrorState);
 
 public:
+    /// creates an error of type other than ERR_RELAY_REMOTE
     ErrorState(err_type type, Http::StatusCode, HttpRequest * request, const AccessLogEntryPointer &al);
     ErrorState() = delete; // not implemented.
+
+    /// creates an ERR_RELAY_REMOTE error
+    ErrorState(HttpRequest * request, HttpReply *);
+
     ~ErrorState();
 
     /// Creates a general request forwarding error with the right http_status.
@@ -104,7 +106,7 @@ public:
     HttpReply *BuildHttpReply(void);
 
     /// set error type-specific detail code
-    void detailError(int dCode) {detailCode = dCode;}
+    void detailError(const ErrorDetail::Pointer &dCode) { detail = dCode; }
 
     /// ensures that a future BuildHttpReply() is likely to succeed
     void validate();
@@ -115,6 +117,9 @@ public:
 private:
     typedef ErrorPage::Build Build;
 
+    /// initializations shared by public constructors
+    explicit ErrorState(err_type type);
+
     /// locates the right error page template for this error and compiles it
     SBuf buildBody();
 
@@ -163,7 +168,7 @@ public:
     err_type type = ERR_NONE;
     int page_id = ERR_NONE;
     char *err_language = nullptr;
-    Http::StatusCode httpStatus;
+    Http::StatusCode httpStatus = Http::scNone;
 #if USE_AUTH
     Auth::UserRequest::Pointer auth_user_request;
 #endif
@@ -192,12 +197,13 @@ public:
 
     AccessLogEntryPointer ale; ///< transaction details (or nil)
 
-#if USE_OPENSSL
-    Ssl::ErrorDetail *detail = nullptr;
-#endif
+    // TODO: Replace type, xerrno and detail with Error while adding a virtual
+    // Error::Detail::sysError() method to extract errno in detailError().
     /// type-specific detail about the transaction error;
-    /// overwrites xerrno; overwritten by detail, if any.
-    int detailCode = ERR_DETAIL_NONE;
+    /// overwrites xerrno;
+    ErrorDetail::Pointer detail;
+
+    HttpReplyPointer response_;
 
 private:
     void noteBuildError_(const char *msg, const char *near, const bool forceBypass);
@@ -345,5 +351,7 @@ protected:
  */
 bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos);
 
+std::ostream &operator <<(std::ostream &, const ErrorState *);
+
 #endif /* SQUID_ERRORPAGE_H */