if (io.flag) {
debugs(11, 1, "sentRequestBody error: FD " << io.fd << ": " << xstrerr(io.xerrno));
ErrorState *err;
- err = errorCon(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY, fwd->request);
+ err = new ErrorState(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY, fwd->request);
err->xerrno = io.xerrno;
fwd->fail(err);
abortTransaction("I/O error while sending request body");
if (entry->isEmpty()) {
debugs(11,9, HERE << "creating ICAP error entry after ICAP failure");
- ErrorState *err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
+ ErrorState *err = new ErrorState(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
err->xerrno = ERR_DETAIL_ICAP_RESPMOD_EARLY;
fwd->fail(err);
fwd->dontRetry(true);
if (page_id == ERR_NONE)
page_id = ERR_ACCESS_DENIED;
- ErrorState *err = errorCon(page_id, HTTP_FORBIDDEN, request);
+ ErrorState *err = new ErrorState(page_id, HTTP_FORBIDDEN, request);
err->xerrno = ERR_DETAIL_RESPMOD_BLOCK_EARLY;
fwd->fail(err);
fwd->dontRetry(true);
void
ServerStateData::sendBodyIsTooLargeError()
{
- ErrorState *err = errorCon(ERR_TOO_BIG, HTTP_FORBIDDEN, request);
+ ErrorState *err = new ErrorState(ERR_TOO_BIG, HTTP_FORBIDDEN, request);
err->xerrno = errno;
fwd->fail(err);
fwd->dontRetry(true);
void
CacheManager::Start(const Comm::ConnectionPointer &client, HttpRequest * request, StoreEntry * entry)
{
- ErrorState *err = NULL;
debugs(16, 3, "CacheManager::Start: '" << entry->url() << "'" );
Mgr::Command::Pointer cmd = ParseUrl(entry->url());
if (!cmd) {
- err = errorCon(ERR_INVALID_URL, HTTP_NOT_FOUND, request);
+ ErrorState *err = new ErrorState(ERR_INVALID_URL, HTTP_NOT_FOUND, request);
err->url = xstrdup(entry->url());
errorAppendEntry(entry, err);
entry->expires = squid_curtime;
if (CheckPassword(*cmd) != 0) {
/* build error message */
- ErrorState *errState;
- HttpReply *rep;
- errState = errorCon(ERR_CACHE_MGR_ACCESS_DENIED, HTTP_UNAUTHORIZED, request);
+ ErrorState errState(ERR_CACHE_MGR_ACCESS_DENIED, HTTP_UNAUTHORIZED, request);
/* warn if user specified incorrect password */
if (cmd->params.password.size()) {
actionName << "'" );
}
- rep = errState->BuildHttpReply();
-
- errorStateFree(errState);
+ HttpReply *rep = errState.BuildHttpReply();
#if HAVE_AUTH_MODULE_BASIC
/*
clientBuildError(err_type page_id, http_status status, char const *url,
Ip::Address &src_addr, HttpRequest * request)
{
- ErrorState *err = errorCon(page_id, status, request);
+ ErrorState *err = new ErrorState(page_id, status, request);
err->src_addr = src_addr;
if (url)
return "ERR_UNKNOWN"; /* should not happen */
}
-ErrorState *
-errorCon(err_type type, http_status status, HttpRequest * request)
+ErrorState::ErrorState(err_type t, http_status status, HttpRequest * req) :
+ type(t),
+ page_id(t),
+ err_language(NULL),
+ httpStatus(status),
+#if USE_AUTH
+ auth_user_request (NULL),
+#endif
+ request(NULL),
+ url(NULL),
+ xerrno(0),
+ port(0),
+ dnsError(),
+ ttl(0),
+ src_addr(),
+ redirect_url(NULL),
+ callback(NULL),
+ callback_data(NULL),
+ request_hdrs(NULL),
+ err_msg(NULL)
+#if USE_SSL
+ , detail(NULL)
+#endif
{
- ErrorState *err = new ErrorState;
- err->page_id = type; /* has to be reset manually if needed */
- err->err_language = NULL;
- err->type = type;
- err->httpStatus = status;
- if (err->page_id >= ERR_MAX && ErrorDynamicPages.items[err->page_id - ERR_MAX]->page_redirect != HTTP_STATUS_NONE)
- err->httpStatus = ErrorDynamicPages.items[err->page_id - ERR_MAX]->page_redirect;
-
- if (request != NULL) {
- err->request = HTTPMSGLOCK(request);
- err->src_addr = request->client_addr;
+ memset(&flags, 0, sizeof(flags));
+ memset(&ftp, 0, sizeof(ftp));
+
+ if (page_id >= ERR_MAX && ErrorDynamicPages.items[page_id - ERR_MAX]->page_redirect != HTTP_STATUS_NONE)
+ httpStatus = ErrorDynamicPages.items[page_id - ERR_MAX]->page_redirect;
+
+ if (req != NULL) {
+ request = HTTPMSGLOCK(req);
+ src_addr = req->client_addr;
request->detailError(type, ERR_DETAIL_NONE);
}
-
- return err;
}
void
*/
assert(EBIT_TEST(entry->flags, ENTRY_ABORTED));
assert(entry->mem_obj->nclients == 0);
- errorStateFree(err);
+ delete err;
return;
}
entry->negativeCache();
entry->releaseRequest();
entry->unlock();
- errorStateFree(err);
+ delete err;
}
void
}
}
- errorStateFree(err);
+ delete err;
}
-void
-errorStateFree(ErrorState * err)
+ErrorState::~ErrorState()
{
- HTTPMSGUNLOCK(err->request);
- safe_free(err->redirect_url);
- safe_free(err->url);
- safe_free(err->request_hdrs);
- wordlistDestroy(&err->ftp.server_msg);
- safe_free(err->ftp.request);
- safe_free(err->ftp.reply);
+ HTTPMSGUNLOCK(request);
+ safe_free(redirect_url);
+ safe_free(url);
+ safe_free(request_hdrs);
+ wordlistDestroy(&ftp.server_msg);
+ safe_free(ftp.request);
+ safe_free(ftp.reply);
#if USE_AUTH
- err->auth_user_request = NULL;
+ auth_user_request = NULL;
#endif
- safe_free(err->err_msg);
+ safe_free(err_msg);
#if USE_ERR_LOCALES
- if (err->err_language != Config.errorDefaultLanguage)
+ if (err_language != Config.errorDefaultLanguage)
#endif
- safe_free(err->err_language);
+ safe_free(err_language);
#if USE_SSL
- delete err->detail;
+ delete detail;
#endif
- cbdataFree(err);
}
int
class ErrorState
{
public:
+ ErrorState(err_type type, http_status, HttpRequest * request);
+ ErrorState(); // not implemented.
+ ~ErrorState();
+
/**
* Allocates and initializes an error response
*/
*/
SQUIDCEXTERN void errorAppendEntry(StoreEntry *entry, ErrorState *err);
-/// \ingroup ErrorPageAPI
-SQUIDCEXTERN void errorStateFree(ErrorState * err);
-
/// \ingroup ErrorPageAPI
SQUIDCEXTERN err_type errorReservePageId(const char *page_name);
-/**
- \ingroup ErrorPageAPI
- *
- * This function creates a ErrorState object.
- */
-SQUIDCEXTERN ErrorState *errorCon(err_type type, http_status, HttpRequest * request);
SQUIDCEXTERN const char *errorPageName(int pageId); ///< error ID to string
/**
HTTPMSGUNLOCK(request);
- if (err)
- errorStateFree(err);
+ delete err;
entry->unregisterAbort();
if (page_id == ERR_NONE)
page_id = ERR_FORWARDING_DENIED;
- ErrorState *anErr = errorCon(page_id, HTTP_FORBIDDEN, request);
-
+ ErrorState *anErr = new ErrorState(page_id, HTTP_FORBIDDEN, request);
errorAppendEntry(entry, anErr); // frees anErr
-
return;
}
}
if (shutting_down) {
/* more yuck */
- ErrorState *anErr = errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request);
+ ErrorState *anErr = new ErrorState(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request);
errorAppendEntry(entry, anErr); // frees anErr
return;
}
if (serverDestinations.size() > 0) {
// Ditch error page if it was created before.
// A new one will be created if there's another problem
- if (err) {
- errorStateFree(err);
- err = NULL;
- }
+ delete err;
+ err = NULL;
// Update the logging information about this new server connection.
// Done here before anything else so the errors get logged for
} else {
debugs(17, 3, HERE << "Connection failed: " << entry->url());
if (!err) {
- ErrorState *anErr = NULL;
- anErr = errorCon(ERR_CANNOT_FORWARD, HTTP_INTERNAL_SERVER_ERROR, request);
+ ErrorState *anErr = new ErrorState(ERR_CANNOT_FORWARD, HTTP_INTERNAL_SERVER_ERROR, request);
anErr->xerrno = errno;
fail(anErr);
} // else use actual error from last connection attempt
{
debugs(17, 3, HERE << err_type_str[errorState->type] << " \"" << httpStatusString(errorState->httpStatus) << "\"\n\t" << entry->url() );
- if (err)
- errorStateFree(err);
-
+ delete err;
err = errorState;
if (!errorState->request)
doneWithRetries();
if (self != NULL && !err && shutting_down) {
- ErrorState *anErr = errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request);
+ ErrorState *anErr = new ErrorState(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request);
errorAppendEntry(entry, anErr);
}
if ((ssl = SSL_new(sslContext)) == NULL) {
debugs(83, 1, "fwdInitiateSSL: Error allocating handle: " << ERR_error_string(ERR_get_error(), NULL) );
- ErrorState *anErr = errorCon(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
+ ErrorState *anErr = new ErrorState(ERR_SOCKET_FAILURE, HTTP_INTERNAL_SERVER_ERROR, request);
anErr->xerrno = errno;
fail(anErr);
self = NULL; // refcounted
assert(fd == serverDestinations[0]->fd);
if (entry->isEmpty()) {
- ErrorState *anErr = errorCon(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT, request);
+ ErrorState *anErr = new ErrorState(ERR_CONNECT_FAIL, HTTP_GATEWAY_TIMEOUT, request);
anErr->xerrno = ETIMEDOUT;
fail(anErr);
if (serverDestinations[0]->getPeer() && request->flags.sslBumped == true) {
debugs(50, 4, "fwdConnectStart: Ssl bumped connections through parrent proxy are not allowed");
- ErrorState *anErr = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, request);
+ ErrorState *anErr = new ErrorState(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, request);
fail(anErr);
self = NULL; // refcounted
return;
default:
debugs(17, 1, "fwdDispatch: Cannot retrieve '" << entry->url() << "'" );
- ErrorState *anErr = errorCon(ERR_UNSUP_REQ, HTTP_BAD_REQUEST, request);
+ ErrorState *anErr = new ErrorState(ERR_UNSUP_REQ, HTTP_BAD_REQUEST, request);
fail(anErr);
/*
* Force a persistent connection to be closed because
ErrorState *
FwdState::makeConnectingError(const err_type type) const
{
- return errorCon(type, request->flags.need_validation ?
- HTTP_GATEWAY_TIMEOUT : HTTP_SERVICE_UNAVAILABLE, request);
+ return new ErrorState(type, request->flags.need_validation ?
+ HTTP_GATEWAY_TIMEOUT : HTTP_SERVICE_UNAVAILABLE, request);
}
static void
if ((state == SENT_USER || state == SENT_PASS) && ctrl.replycode >= 400) {
if (ctrl.replycode == 421 || ctrl.replycode == 426) {
// 421/426 - Service Overload - retry permitted.
- err = errorCon(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request);
+ err = new ErrorState(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request);
} else if (ctrl.replycode >= 430 && ctrl.replycode <= 439) {
// 43x - Invalid or Credential Error - retry challenge required.
- err = errorCon(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
+ err = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
} else if (ctrl.replycode >= 530 && ctrl.replycode <= 539) {
// 53x - Credentials Missing - retry challenge required
if (password_url) // but they were in the URI! major fail.
- err = errorCon(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request);
+ err = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request);
else
- err = errorCon(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
+ err = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
}
}
HttpReply *newrep = err->BuildHttpReply();
- errorStateFree(err);
+ delete err;
#if HAVE_AUTH_MODULE_BASIC
/* add Authenticate header */
{
assert(entry);
entry->lock();
- ErrorState *ferr = errorCon(ERR_DIR_LISTING, HTTP_OK, request);
- ferr->ftp.listing = &listing;
- ferr->ftp.cwd_msg = xstrdup(cwd_message.size()? cwd_message.termedBuf() : "");
- ferr->ftp.server_msg = ctrl.message;
+ ErrorState ferr(ERR_DIR_LISTING, HTTP_OK, request);
+ ferr.ftp.listing = &listing;
+ ferr.ftp.cwd_msg = xstrdup(cwd_message.size()? cwd_message.termedBuf() : "");
+ ferr.ftp.server_msg = ctrl.message;
ctrl.message = NULL;
- entry->replaceHttpReply( ferr->BuildHttpReply() );
- errorStateFree(ferr);
+ entry->replaceHttpReply( ferr.BuildHttpReply() );
EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT);
entry->flush();
entry->unlock();
void
FtpStateData::failedErrorMessage(err_type error, int xerrno)
{
- ErrorState *ftperr;
+ ErrorState *ftperr = NULL;
const char *command, *reply;
/* Translate FTP errors into HTTP errors */
- ftperr = NULL;
-
switch (error) {
case ERR_NONE:
if (ctrl.replycode > 500)
if (password_url)
- ftperr = errorCon(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request);
+ ftperr = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_FORBIDDEN, fwd->request);
else
- ftperr = errorCon(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
+ ftperr = new ErrorState(ERR_FTP_FORBIDDEN, HTTP_UNAUTHORIZED, fwd->request);
else if (ctrl.replycode == 421)
- ftperr = errorCon(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request);
+ ftperr = new ErrorState(ERR_FTP_UNAVAILABLE, HTTP_SERVICE_UNAVAILABLE, fwd->request);
break;
case SENT_RETR:
if (ctrl.replycode == 550)
- ftperr = errorCon(ERR_FTP_NOT_FOUND, HTTP_NOT_FOUND, fwd->request);
+ ftperr = new ErrorState(ERR_FTP_NOT_FOUND, HTTP_NOT_FOUND, fwd->request);
break;
break;
case ERR_READ_TIMEOUT:
- ftperr = errorCon(error, HTTP_GATEWAY_TIMEOUT, fwd->request);
+ ftperr = new ErrorState(error, HTTP_GATEWAY_TIMEOUT, fwd->request);
break;
default:
- ftperr = errorCon(error, HTTP_BAD_GATEWAY, fwd->request);
+ ftperr = new ErrorState(error, HTTP_BAD_GATEWAY, fwd->request);
break;
}
if (ftperr == NULL)
- ftperr = errorCon(ERR_FTP_FAILURE, HTTP_BAD_GATEWAY, fwd->request);
+ ftperr = new ErrorState(ERR_FTP_FAILURE, HTTP_BAD_GATEWAY, fwd->request);
ftperr->xerrno = xerrno;
ftperr->ftp.reply = xstrdup(reply);
entry->replaceHttpReply( ftperr->BuildHttpReply() );
- errorStateFree(ftperr);
+ delete ftperr;
}
/// \ingroup ServerProtocolFTPInternal
static void
ftpSendReply(FtpStateData * ftpState)
{
- ErrorState *err;
int code = ftpState->ctrl.replycode;
http_status http_code;
err_type err_code = ERR_NONE;
if (ftpState->request)
ftpState->request->detailError(err_code, code);
- err = errorCon(err_code, http_code, ftpState->request);
+ ErrorState err(err_code, http_code, ftpState->request);
if (ftpState->old_request)
- err->ftp.request = xstrdup(ftpState->old_request);
+ err.ftp.request = xstrdup(ftpState->old_request);
else
- err->ftp.request = xstrdup(ftpState->ctrl.last_command);
+ err.ftp.request = xstrdup(ftpState->ctrl.last_command);
if (ftpState->old_reply)
- err->ftp.reply = xstrdup(ftpState->old_reply);
+ err.ftp.reply = xstrdup(ftpState->old_reply);
else if (ftpState->ctrl.last_reply)
- err->ftp.reply = xstrdup(ftpState->ctrl.last_reply);
+ err.ftp.reply = xstrdup(ftpState->ctrl.last_reply);
else
- err->ftp.reply = xstrdup("");
+ err.ftp.reply = xstrdup("");
- ftpState->entry->replaceHttpReply( err->BuildHttpReply() );
- errorStateFree(err);
+ ftpState->entry->replaceHttpReply( err.BuildHttpReply() );
ftpSendQuit(ftpState);
}
HttpReply *
FtpStateData::ftpAuthRequired(HttpRequest * request, const char *realm)
{
- ErrorState *err = errorCon(ERR_CACHE_ACCESS_DENIED, HTTP_UNAUTHORIZED, request);
- HttpReply *newrep = err->BuildHttpReply();
- errorStateFree(err);
+ ErrorState err(ERR_CACHE_ACCESS_DENIED, HTTP_UNAUTHORIZED, request);
+ HttpReply *newrep = err.BuildHttpReply();
#if HAVE_AUTH_MODULE_BASIC
/* add Authenticate header */
newrep->header.putAuth("Basic", realm);
GopherStateData *gopherState = static_cast<GopherStateData *>(io.data);
debugs(10, 4, HERE << io.conn << ": '" << gopherState->entry->url() << "'" );
- gopherState->fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, gopherState->fwd->request));
+ gopherState->fwd->fail(new ErrorState(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, gopherState->fwd->request));
if (Comm::IsConnOpen(io.conn))
io.conn->close();
CommIoCbPtrFun(gopherReadReply, gopherState));
comm_read(conn, buf, read_sz, call);
} else {
- ErrorState *err;
- err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, gopherState->fwd->request);
+ ErrorState *err = new ErrorState(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, gopherState->fwd->request);
err->xerrno = errno;
gopherState->fwd->fail(err);
gopherState->serverConn->close();
}
} else if (len == 0 && entry->isEmpty()) {
- gopherState->fwd->fail(errorCon(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE, gopherState->fwd->request));
+ gopherState->fwd->fail(new ErrorState(ERR_ZERO_SIZE_OBJECT, HTTP_SERVICE_UNAVAILABLE, gopherState->fwd->request));
gopherState->serverConn->close();
} else if (len == 0) {
/* Connection closed; retrieval done. */
if (errflag) {
ErrorState *err;
- err = errorCon(ERR_WRITE_ERROR, HTTP_SERVICE_UNAVAILABLE, gopherState->fwd->request);
+ err = new ErrorState(ERR_WRITE_ERROR, HTTP_SERVICE_UNAVAILABLE, gopherState->fwd->request);
err->xerrno = errno;
err->port = gopherState->fwd->request->port;
err->url = xstrdup(entry->url());
debugs(11, 4, HERE << serverConnection << ": '" << entry->url() << "'" );
if (entry->store_status == STORE_PENDING) {
- fwd->fail(errorCon(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, fwd->request));
+ fwd->fail(new ErrorState(ERR_READ_TIMEOUT, HTTP_GATEWAY_TIMEOUT, fwd->request));
}
serverConnection->close();
if (ignoreErrno(io.xerrno)) {
flags.do_next_read = 1;
} else {
- ErrorState *err;
- err = errorCon(ERR_READ_ERROR, HTTP_BAD_GATEWAY, fwd->request);
+ ErrorState *err = new ErrorState(ERR_READ_ERROR, HTTP_BAD_GATEWAY, fwd->request);
err->xerrno = io.xerrno;
fwd->fail(err);
flags.do_next_read = 0;
assert(error != ERR_NONE);
entry->reset();
- fwd->fail(errorCon(error, HTTP_BAD_GATEWAY, fwd->request));
+ fwd->fail(new ErrorState(error, HTTP_BAD_GATEWAY, fwd->request));
flags.do_next_read = 0;
serverConnection->close();
return false; // quit on error
return;
if (io.flag) {
- ErrorState *err;
- err = errorCon(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY, fwd->request);
+ ErrorState *err = new ErrorState(ERR_WRITE_ERROR, HTTP_BAD_GATEWAY, fwd->request);
err->xerrno = io.xerrno;
fwd->fail(err);
serverConnection->close();
ServerStateData::handleRequestBodyProducerAborted();
if (entry->isEmpty()) {
debugs(11, 3, "request body aborted: " << serverConnection);
- ErrorState *err;
// We usually get here when ICAP REQMOD aborts during body processing.
// We might also get here if client-side aborts, but then our response
// should not matter because either client-side will provide its own or
// there will be no response at all (e.g., if the the client has left).
- err = errorCon(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, fwd->request);
+ ErrorState *err = new ErrorState(ERR_ICAP_FAILURE, HTTP_INTERNAL_SERVER_ERROR, fwd->request);
err->xerrno = ERR_DETAIL_SRV_REQMOD_REQ_BODY;
fwd->fail(err);
}
} else {
debugObj(76, 1, "internalStart: unknown request:\n",
request, (ObjPackMethod) & httpRequestPack);
- err = errorCon(ERR_INVALID_REQ, HTTP_NOT_FOUND, request);
+ err = new ErrorState(ERR_INVALID_REQ, HTTP_NOT_FOUND, request);
errorAppendEntry(entry, err);
}
}
Mgr::Forwarder::handleError()
{
debugs(16, DBG_CRITICAL, "ERROR: uri " << entry->url() << " exceeds buffer size");
- sendError(errorCon(ERR_INVALID_URL, HTTP_REQUEST_URI_TOO_LARGE, httpRequest));
+ sendError(new ErrorState(ERR_INVALID_URL, HTTP_REQUEST_URI_TOO_LARGE, httpRequest));
mustStop("long URI");
}
void
Mgr::Forwarder::handleTimeout()
{
- sendError(errorCon(ERR_LIFETIME_EXP, HTTP_REQUEST_TIMEOUT, httpRequest));
+ sendError(new ErrorState(ERR_LIFETIME_EXP, HTTP_REQUEST_TIMEOUT, httpRequest));
Ipc::Forwarder::handleTimeout();
}
Mgr::Forwarder::handleException(const std::exception& e)
{
if (entry != NULL && httpRequest != NULL && Comm::IsConnOpen(conn))
- sendError(errorCon(ERR_INVALID_RESP, HTTP_INTERNAL_SERVER_ERROR, httpRequest));
+ sendError(new ErrorState(ERR_INVALID_RESP, HTTP_INTERNAL_SERVER_ERROR, httpRequest));
Ipc::Forwarder::handleException(e);
}
entry->buffer();
entry->replaceHttpReply(error->BuildHttpReply());
entry->expires = squid_curtime;
- errorStateFree(error);
+ delete error;
entry->flush();
entry->complete();
}
LOCAL_ARRAY(char, url, MAX_URL);
snprintf(url, MAX_URL, "%s", aggrAction->command().params.httpUri.termedBuf());
HttpRequest *req = HttpRequest::CreateFromUrl(url);
- ErrorState *err = errorCon(ERR_INVALID_URL, HTTP_NOT_FOUND, req);
+ ErrorState err(ERR_INVALID_URL, HTTP_NOT_FOUND, req);
#if HAVE_UNIQUE_PTR
- std::unique_ptr<HttpReply> reply(err->BuildHttpReply());
+ std::unique_ptr<HttpReply> reply(err.BuildHttpReply());
#else
- std::auto_ptr<HttpReply> reply(err->BuildHttpReply());
+ std::auto_ptr<HttpReply> reply(err.BuildHttpReply());
#endif
replyBuf.reset(reply->pack());
- errorStateFree(err);
} else {
#if HAVE_UNIQUE_PTR
std::unique_ptr<HttpReply> reply(new HttpReply);
AsyncJob::Start(cs);
} else {
debugs(26, 4, HERE << "terminate with error.");
- ErrorState *err = errorCon(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, tunnelState->request);
+ ErrorState *err = new ErrorState(ERR_CONNECT_FAIL, HTTP_SERVICE_UNAVAILABLE, tunnelState->request);
*tunnelState->status_ptr = HTTP_SERVICE_UNAVAILABLE;
err->xerrno = xerrno;
// on timeout is this still: err->xerrno = ETIMEDOUT;
ch.my_addr = request->my_addr;
if (ch.fastCheck() == ACCESS_DENIED) {
debugs(26, 4, HERE << "MISS access forbidden.");
- err = errorCon(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN, request);
+ err = new ErrorState(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN, request);
*status_ptr = HTTP_FORBIDDEN;
errorSend(http->getConn()->clientConnection, err);
return;
if (peer_paths == NULL || peer_paths->size() < 1) {
debugs(26, 3, HERE << "No paths found. Aborting CONNECT");
ErrorState *err;
- err = errorCon(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, tunnelState->request);
+ err = new ErrorState(ERR_CANNOT_FORWARD, HTTP_SERVICE_UNAVAILABLE, tunnelState->request);
*tunnelState->status_ptr = HTTP_SERVICE_UNAVAILABLE;
err->callback = tunnelErrorComplete;
err->callback_data = tunnelState;
if (urlres_r == NULL) {
debugs(52, 3, "urnStart: Bad uri-res URL " << urlres);
- ErrorState *err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND, r);
+ ErrorState *err = new ErrorState(ERR_URN_RESOLVE, HTTP_NOT_FOUND, r);
err->url = urlres;
urlres = NULL;
errorAppendEntry(entry, err);
if (rep->sline.status != HTTP_OK) {
debugs(52, 3, "urnHandleReply: failed.");
- err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request);
+ err = new ErrorState(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request);
err->url = xstrdup(e->url());
errorAppendEntry(e, err);
delete rep;
if (urls == NULL) { /* unkown URN error */
debugs(52, 3, "urnTranslateDone: unknown URN " << e->url() );
- err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request);
+ err = new ErrorState(ERR_URN_RESOLVE, HTTP_NOT_FOUND, urnState->request);
err->url = xstrdup(e->url());
errorAppendEntry(e, err);
urnHandleReplyError(urnState, urlres_e);
CommIoCbPtrFun(whoisReadReply, this));
comm_read(conn, aBuffer, BUFSIZ, call);
} else {
- ErrorState *err;
- err = errorCon(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, fwd->request);
+ ErrorState *err = new ErrorState(ERR_READ_ERROR, HTTP_INTERNAL_SERVER_ERROR, fwd->request);
err->xerrno = errno;
fwd->fail(err);
conn->close();