--------------------- PatchSet 4041 Date: 2007/02/14 04:48:10 Author: rousskov Branch: squid3-icap Tag: (none) Log: - Moved HttpRequest::body_reader to HttpMsg::body_pipe so that all HTTP message bodies can be communicated via pipes. This is needed for the server side to supply response bodies to ICAP and for the ICAP side to supply adapted message bodies to others. - When cleaning HttpRequest or HttpReply, reset body_pipe to NULL instead of asserting that it is already NULL. BodyPipes are owned and maintained by other objects and HttpMsg is used only as a mechanism to pass the pipe pointer from the body producer to the consumer. To maintain guarantees similar to the old code, the BodyPipe destructor asserts that both the producer and the consumer are gone when the pipe is destructed. Members: src/HttpMsg.cc:1.4.4.9->1.4.4.10 src/HttpMsg.h:1.1.2.9->1.1.2.10 src/HttpReply.cc:1.21.4.15->1.21.4.16 src/HttpRequest.cc:1.16.4.11->1.16.4.12 src/HttpRequest.h:1.13.4.8->1.13.4.9 Index: squid3/src/HttpMsg.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpMsg.cc,v retrieving revision 1.4.4.9 retrieving revision 1.4.4.10 diff -u -r1.4.4.9 -r1.4.4.10 --- squid3/src/HttpMsg.cc 18 Oct 2006 21:26:10 -0000 1.4.4.9 +++ squid3/src/HttpMsg.cc 14 Feb 2007 04:48:10 -0000 1.4.4.10 @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.cc,v 1.4.4.9 2006/10/18 21:26:10 rousskov Exp $ + * $Id: HttpMsg.cc,v 1.4.4.10 2007/02/14 04:48:10 rousskov Exp $ * * DEBUG: section 74 HTTP Message * AUTHOR: Alex Rousskov @@ -45,6 +45,7 @@ HttpMsg::~HttpMsg() { assert(lock_count == 0); + assert(!body_pipe); } HttpMsgParseState &operator++ (HttpMsgParseState &aState) Index: squid3/src/HttpMsg.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpMsg.h,v retrieving revision 1.1.2.9 retrieving revision 1.1.2.10 diff -u -r1.1.2.9 -r1.1.2.10 --- squid3/src/HttpMsg.h 18 Oct 2006 21:26:10 -0000 1.1.2.9 +++ squid3/src/HttpMsg.h 14 Feb 2007 04:48:10 -0000 1.1.2.10 @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.h,v 1.1.2.9 2006/10/18 21:26:10 rousskov Exp $ + * $Id: HttpMsg.h,v 1.1.2.10 2007/02/14 04:48:10 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -37,6 +37,7 @@ #include "typedefs.h" #include "HttpHeader.h" #include "HttpVersion.h" +#include "BodyPipe.h" // common parts of HttpRequest and HttpReply @@ -72,6 +73,8 @@ HttpMsgParseState pstate; /* the current parsing state */ + BodyPipe::Pointer body_pipe; // optional pipeline to receive message body + // returns true and sets hdr_sz on success // returns false and sets *error to zero when needs more data // returns false and sets *error to a positive http_status code on error Index: squid3/src/HttpReply.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpReply.cc,v retrieving revision 1.21.4.15 retrieving revision 1.21.4.16 diff -u -r1.21.4.15 -r1.21.4.16 --- squid3/src/HttpReply.cc 3 Oct 2006 03:50:29 -0000 1.21.4.15 +++ squid3/src/HttpReply.cc 14 Feb 2007 04:48:10 -0000 1.21.4.16 @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.21.4.15 2006/10/03 03:50:29 rousskov Exp $ + * $Id: HttpReply.cc,v 1.21.4.16 2007/02/14 04:48:10 rousskov Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -114,6 +114,10 @@ void HttpReply::clean() { + // we used to assert that the pipe is NULL, but now the message only + // points to a pipe that is owned and initiated by another object. + body_pipe = NULL; + httpBodyClean(&body); hdrCacheClean(); header.clean(); Index: squid3/src/HttpRequest.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpRequest.cc,v retrieving revision 1.16.4.11 retrieving revision 1.16.4.12 diff -u -r1.16.4.11 -r1.16.4.12 --- squid3/src/HttpRequest.cc 3 Oct 2006 03:50:29 -0000 1.16.4.11 +++ squid3/src/HttpRequest.cc 14 Feb 2007 04:48:10 -0000 1.16.4.12 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.cc,v 1.16.4.11 2006/10/03 03:50:29 rousskov Exp $ + * $Id: HttpRequest.cc,v 1.16.4.12 2007/02/14 04:48:10 rousskov Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -86,7 +86,7 @@ my_addr = no_addr; my_port = 0; client_port = 0; - body_reader = NULL; + body_pipe = NULL; // hier errType = ERR_NONE; peer_login = NULL; // not allocated/deallocated by this class @@ -102,8 +102,9 @@ void HttpRequest::clean() { - if (body_reader != NULL) - fatal ("request being destroyed with body reader intact\n"); + // we used to assert that the pipe is NULL, but now the request only + // points to a pipe that is owned and initiated by another object. + body_pipe = NULL; if (auth_user_request) { auth_user_request->unlock(); Index: squid3/src/HttpRequest.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpRequest.h,v retrieving revision 1.13.4.8 retrieving revision 1.13.4.9 diff -u -r1.13.4.8 -r1.13.4.9 --- squid3/src/HttpRequest.h 29 Sep 2006 23:27:09 -0000 1.13.4.8 +++ squid3/src/HttpRequest.h 14 Feb 2007 04:48:10 -0000 1.13.4.9 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.h,v 1.13.4.8 2006/09/29 23:27:09 dwsquid Exp $ + * $Id: HttpRequest.h,v 1.13.4.9 2007/02/14 04:48:10 rousskov Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -37,7 +37,6 @@ #include "HttpMsg.h" #include "client_side.h" #include "HierarchyLogEntry.h" -#include "BodyReader.h" #include "HttpRequestMethod.h" /* Http Request */ @@ -109,8 +108,6 @@ unsigned short client_port; - BodyReader::Pointer body_reader; - HierarchyLogEntry hier; err_type errType;