From: wessels <> Date: Thu, 26 Jan 2006 00:47:26 +0000 (+0000) Subject: The purpose of this change is to add ICAP RESPMOD support for FTP responses. X-Git-Tag: SQUID_3_0_PRE4~338 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cd304fc2bc15a007ca16bb39102256cc3b90a90b;p=thirdparty%2Fsquid.git The purpose of this change is to add ICAP RESPMOD support for FTP responses. I created a "ServerStateData" class which has common elements of both HttpStateData and FtpStateData. It becomes a base class for both of them. ICAP now uses the ServerStateData methods. --- diff --git a/src/Server.cc b/src/Server.cc new file mode 100644 index 0000000000..d7da35b5e3 --- /dev/null +++ b/src/Server.cc @@ -0,0 +1,87 @@ +/* + * $Id: Server.cc,v 1.1 2006/01/25 17:47:26 wessels Exp $ + * + * DEBUG: + * 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. + * + */ + +#include "squid.h" +#include "Server.h" +#include "Store.h" +#include "HttpRequest.h" +#include "HttpReply.h" +#if ICAP_CLIENT +#include "ICAP/ICAPClientRespmodPrecache.h" +#endif + +ServerStateData::ServerStateData(FwdState *theFwdState) +{ + fwd = theFwdState; + entry = fwd->entry; + storeLockObject(entry); + request = requestLink(fwd->request); +} + +ServerStateData::~ServerStateData() +{ + storeUnlockObject(entry); + + if (request) + request->unlock(); + + if (reply) + reply->unlock(); + + fwd = NULL; // refcounted + +#if ICAP_CLIENT + + if (icap) { + delete icap; + cbdataReferenceDone(icap); + } + +#endif +} + +/* + * Initiate an ICAP transaction. Return 0 if all is well, or -1 upon error. + * Caller will handle error condition by generating a Squid error message + * or take other action. + */ +int +ServerStateData::doIcap(ICAPServiceRep::Pointer service) +{ + debug(11,5)("ServerStateData::doIcap() called\n"); + assert(NULL == icap); + icap = new ICAPClientRespmodPrecache(service); + (void) cbdataReference(icap); + return 0; +} diff --git a/src/Server.h b/src/Server.h new file mode 100644 index 0000000000..75a8d0ebf1 --- /dev/null +++ b/src/Server.h @@ -0,0 +1,88 @@ + +/* + * $Id: Server.h,v 1.1 2006/01/25 17:47:26 wessels Exp $ + * + * 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. + * + */ + +/* + * ServerStateData is a class for common elements of Server-side modules + * such as http.cc and ftp.cc. It was invented to make ICAP code simpler. + */ + +#ifndef SQUID_SERVER_H +#define SQUID_SERVER_H + +#include "StoreIOBuffer.h" +#include "forward.h" + +#if ICAP_CLIENT +#include "ICAP/ICAPServiceRep.h" + +class ICAPClientRespmodPrecache; + +class ICAPAccessCheck; +#endif + +class ServerStateData +{ + +public: + ServerStateData(FwdState *); + virtual ~ServerStateData(); + +#if ICAP_CLIENT + + virtual void takeAdaptedHeaders(HttpReply *) = 0; + virtual void takeAdaptedBody(MemBuf *) = 0; + virtual void doneAdapting() = 0; + virtual void abortAdapting() = 0; + virtual void icapSpaceAvailable() = 0; + virtual void icapAclCheckDone(ICAPServiceRep::Pointer) = 0; +#endif + +public: + // should be protected + StoreEntry *entry; + FwdState::Pointer fwd; + HttpRequest *request; + HttpReply *reply; + +protected: +#if ICAP_CLIENT + + ICAPClientRespmodPrecache *icap; + bool icapAccessCheckPending; + int doIcap(ICAPServiceRep::Pointer); +#endif + +}; + +#endif /* SQUID_SERVER_H */