--------------------- PatchSet 1515 Date: 2005/08/17 19:52:46 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Added a mostly protocol-agnostic unidirectional "message pipe" to allow parts of the code to asunchronously send potentially large protocol messages (in chunks). The MsgPipeData is the only interface part that assumes that HTTP messages are being passed around. The data type (protocol) can probably be parametrized later if needed. A pair of these pipes will be used by HttpStateData (and friends) to send virgin HTTP messages to ICAP client module and receive adapted HTTP messages back. This is similar to clientStream interface but does not depend on the "side" and does not stream the message through many stream "nodes". The pipe connects just two points: the sender and the receiver. Many things, including RefCounting and possibly MemPooling are still missing. Members: src/MsgPipe.cc:1.1->1.1.2.1 src/MsgPipe.h:1.1->1.1.2.1 src/MsgPipeData.h:1.1->1.1.2.1 src/MsgPipeSink.h:1.1->1.1.2.1 src/MsgPipeSource.h:1.1->1.1.2.1 --- /dev/null Wed Feb 14 13:33:00 2007 +++ squid3/src/MsgPipe.cc Wed Feb 14 13:34:50 2007 @@ -0,0 +1,17 @@ +#include "squid.h" +#include "MsgPipe.h" +#include "MsgPipeSource.h" +#include "MsgPipeSink.h" + +MsgPipe::MsgPipe(): data(NULL), source(NULL), sink(NULL) { +} + +#if 0 +void MsgPipe::sendSourceStart(); +void MsgPipe::sendSourceProgress(); +void MsgPipe::sendSourceFinish(); +void MsgPipe::sendSourceAbort(); + +void MsgPipe::sendSinkNeed(); +void MsgPipe::sendSinkAbort(); +#endif --- /dev/null Wed Feb 14 13:33:00 2007 +++ squid3/src/MsgPipe.h Wed Feb 14 13:34:50 2007 @@ -0,0 +1,69 @@ + +/* + * $Id: MsgPipe.h,v 1.1.2.1 2005/08/17 19:52:46 rousskov Exp $ + * + * + * 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 + * sinks; 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. + * + */ + +#ifndef SQUID_MSGPIPE_H +#define SQUID_MSGPIPE_H + + +// MsgPipe is a unidirectional communication channel for asynchronously +// transmitting potentially large messages. It aggregates the message +// being piped and pointers to the message sender and recepient. +// MsgPipe also provides convenience wrappers for asynchronous calls to +// recepient's and sender's note*() methods. + +class MsgPipeData; +class MsgPipeSource; +class MsgPipeSink; + +class MsgPipe +{ +public: + MsgPipe(); + + // the pipe source calls these to notify the sink + void sendSourceStart(); + void sendSourceProgress(); + void sendSourceFinish(); + void sendSourceAbort(); + + // the pipe sink calls these to notify the source + void sendSinkNeed(); + void sendSinkAbort(); + +public: + MsgPipeData *data; + MsgPipeSource *source; + MsgPipeSink *sink; +}; + +#endif /* SQUID_MSGPIPE_H */ --- /dev/null Wed Feb 14 13:33:00 2007 +++ squid3/src/MsgPipeData.h Wed Feb 14 13:34:50 2007 @@ -0,0 +1,64 @@ + +/* + * $Id: MsgPipeData.h,v 1.1.2.1 2005/08/17 19:52:46 rousskov Exp $ + * + * + * 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 + * sinks; 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. + * + */ + +#ifndef SQUID_MSGPIPEDATA_H +#define SQUID_MSGPIPEDATA_H + +#include "HttpReply.h" +#include "mem_hdr.h" + +// MsgPipeData contains information about the HTTP message being sent +// from the pipe source to the sink. Since the entire message body may be +// large, only partial information about the body is kept. For HTTP +// responses, request header information is also available as metadata. + +class HttpRequest; + +class MsgPipeData +{ +public: + MsgPipeData(); + +public: + typedef HttpReply Header; + typedef mem_hdr Body; + + // message being piped + Header *header; // parsed HTTP headers + Body *body; // a buffer for piping body piping + + // HTTP request header for piped responses (the cause of the response) + HttpRequest *cause; +}; + +#endif /* SQUID_MSGPIPEDATA_H */ --- /dev/null Wed Feb 14 13:33:00 2007 +++ squid3/src/MsgPipeSink.h Wed Feb 14 13:34:50 2007 @@ -0,0 +1,54 @@ + +/* + * $Id: MsgPipeSink.h,v 1.1.2.1 2005/08/17 19:52:46 rousskov Exp $ + * + * + * 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. + * + */ + +#ifndef SQUID_MSGPIPESINK_H +#define SQUID_MSGPIPESINK_H + + +// MsgPipeSink is an interface for the recepient of a given message +// over a given message pipe. Use MsgPipe to call sink methods. + +class MsgPipe; + +class MsgPipeSink +{ +public: + virtual ~MsgPipeSink() {} + + virtual void noteSourceStart(MsgPipe *p) = 0; + virtual void noteSourceProgress(MsgPipe *p) = 0; + virtual void noteSourceFinish(MsgPipe *p) = 0; + virtual void noteSourceAbort(MsgPipe *p) = 0; +}; + +#endif /* SQUID_MSGPIPESINK_H */ --- /dev/null Wed Feb 14 13:33:00 2007 +++ squid3/src/MsgPipeSource.h Wed Feb 14 13:34:50 2007 @@ -0,0 +1,52 @@ + +/* + * $Id: MsgPipeSource.h,v 1.1.2.1 2005/08/17 19:52:46 rousskov Exp $ + * + * + * 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 + * sinks; 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. + * + */ + +#ifndef SQUID_MSGPIPESOURCE_H +#define SQUID_MSGPIPESOURCE_H + + +// MsgPipeSource is an interface for the sender of a given message +// over a given message pipe. Use MsgPipe to call source methods. + +class MsgPipe; + +class MsgPipeSource +{ +public: + virtual ~MsgPipeSource() {} + + virtual void noteSinkNeed(MsgPipe *p) = 0; + virtual void noteSinkAbort(MsgPipe *p) = 0; +}; + +#endif /* SQUID_MSGPIPESOURCE_H */