/*
- * 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.
#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"
#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);
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.
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();
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();
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
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);
*/
bool strHdrAcptLangGetItem(const String &hdr, char *lang, int langLen, size_t &pos);
+std::ostream &operator <<(std::ostream &, const ErrorState *);
+
#endif /* SQUID_ERRORPAGE_H */