/*
- * DEBUG: section 04 Error Generation
- * AUTHOR: Duane Wessels
- *
- * SQUID Web Proxy Cache http://www.squid-cache.org/
- * ----------------------------------------------------------
- *
- * Squid is the result of efforts by numerous individuals from
- * the Internet community; see the CONTRIBUTORS file for full
- * details. Many organizations have provided support for Squid's
- * development; see the SPONSORS file for full details. Squid is
- * Copyrighted (C) 2001 by the Regents of the University of
- * California; see the COPYRIGHT file for full details. Squid
- * incorporates software developed and/or copyrighted by other
- * sources; see the CREDITS file for full details.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
*
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
*/
+
+/* DEBUG: section 04 Error Generation */
+
#include "squid.h"
#include "cache_cf.h"
+#include "clients/forward.h"
#include "comm/Connection.h"
#include "comm/Write.h"
#include "disk.h"
#include "err_detail_type.h"
#include "errorpage.h"
#include "fde.h"
-#include "ftp.h"
#include "html_quote.h"
#include "HttpHeaderTools.h"
#include "HttpReply.h"
* automagically to give you more control on the format
*/
static const struct {
- int type; /* and page_id */
+ int type; /* and page_id */
const char *text;
}
class ErrorPageFile: public TemplateFile
{
public:
- ErrorPageFile(const char *name, const err_type code): TemplateFile(name,code) { textBuf.init();}
+ ErrorPageFile(const char *name, const err_type code) : TemplateFile(name,code) {textBuf.init();}
/// The template text data read from disk
const char *text() { return textBuf.content(); }
private:
/// stores the data read from disk to a local buffer
- virtual bool parse(const char *buf, int len, bool eof) {
+ virtual bool parse(const char *buf, int len, bool) {
if (len)
textBuf.append(buf, len);
return true;
const char *
errorPageName(int pageId)
{
- if (pageId >= ERR_NONE && pageId < ERR_MAX) /* common case */
+ if (pageId >= ERR_NONE && pageId < ERR_MAX) /* common case */
return err_type_str[pageId];
if (pageId >= ERR_MAX && pageId - ERR_MAX < (ssize_t)ErrorDynamicPages.size())
return ErrorDynamicPages[pageId - ERR_MAX]->page_name;
- return "ERR_UNKNOWN"; /* should not happen */
+ return "ERR_UNKNOWN"; /* should not happen */
}
ErrorState *
}
ErrorState::ErrorState(err_type t, Http::StatusCode status, HttpRequest * req) :
- type(t),
- page_id(t),
- err_language(NULL),
- httpStatus(status),
+ type(t),
+ page_id(t),
+ err_language(NULL),
+ httpStatus(status),
#if USE_AUTH
- auth_user_request (NULL),
+ 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),
+ 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_OPENSSL
- detail(NULL),
+ detail(NULL),
#endif
- detailCode(ERR_DETAIL_NONE)
+ detailCode(ERR_DETAIL_NONE)
{
memset(&ftp, 0, sizeof(ftp));
}
}
- entry->lock("errorAppendEntry");
- entry->buffer();
- entry->replaceHttpReply( err->BuildHttpReply() );
- entry->flush();
- entry->complete();
- entry->negativeCache();
- entry->releaseRequest();
- entry->unlock("errorAppendEntry");
+ entry->storeErrorResponse(err->BuildHttpReply());
delete err;
}
* closing the FD, otherwise we do it ourselves.
*/
static void
-errorSendComplete(const Comm::ConnectionPointer &conn, char *bufnotused, size_t size, comm_err_t errflag, int xerrno, void *data)
+errorSendComplete(const Comm::ConnectionPointer &conn, char *, size_t size, Comm::Flag errflag, int, void *data)
{
ErrorState *err = static_cast<ErrorState *>(data);
debugs(4, 3, HERE << conn << ", size=" << size);
- if (errflag != COMM_ERR_CLOSING) {
+ if (errflag != Comm::ERR_CLOSING) {
if (err->callback) {
debugs(4, 3, "errorSendComplete: callback");
err->callback(conn->fd, err->callback_data, size);
str.Printf("Err: [none]\r\n");
}
#if USE_AUTH
- if (auth_user_request->denyMessage())
+ if (auth_user_request.getRaw() && auth_user_request->denyMessage())
str.Printf("Auth ErrMsg: %s\r\n", auth_user_request->denyMessage());
#endif
if (dnsError.size() > 0)
ErrorState::Convert(char token, bool building_deny_info_url, bool allowRecursion)
{
static MemBuf mb;
- const char *p = NULL; /* takes priority over mb if set */
+ const char *p = NULL; /* takes priority over mb if set */
int do_quote = 1;
int no_urlescape = 0; /* if true then item is NOT to be further URL-encoded */
char ntoabuf[MAX_IPSTRLEN];
case 'B':
if (building_deny_info_url) break;
- p = request ? ftpUrlWith2f(request) : "[no URL]";
+ p = request ? Ftp::UrlWith2f(request) : "[no URL]";
break;
case 'c':
}
if (!p)
- p = mb.buf; /* do not use mb after this assignment! */
+ p = mb.buf; /* do not use mb after this assignment! */
assert(p);
}
void
-ErrorState::DenyInfoLocation(const char *name, HttpRequest *aRequest, MemBuf &result)
+ErrorState::DenyInfoLocation(const char *name, HttpRequest *, MemBuf &result)
{
char const *m = name;
char const *p = m;
content->init();
while ((p = strchr(m, '%'))) {
- content->append(m, p - m); /* copy */
- const char *t = Convert(*++p, false, allowRecursion); /* convert */
- content->Printf("%s", t); /* copy */
- m = p + 1; /* advance */
+ content->append(m, p - m); /* copy */
+ const char *t = Convert(*++p, false, allowRecursion); /* convert */
+ content->Printf("%s", t); /* copy */
+ m = p + 1; /* advance */
}
if (*m)
- content->Printf("%s", m); /* copy tail */
+ content->Printf("%s", m); /* copy tail */
content->terminate();
return content;
}
+