--------------------- PatchSet 1846 Date: 2005/09/18 04:12:42 Author: dwsquid Branch: squid3-icap Tag: (none) Log: membuf merge fixes Members: src/ChunkedCodingParser.cc:1.1.2.4->1.1.2.5 src/HttpMsg.h:1.1.2.3->1.1.2.4 src/ICAPAnchor.cc:1.1.2.27->1.1.2.28 src/ICAPClientSideHook.cc:1.1.2.2->1.1.2.3 src/ICAPXaction.cc:1.1.2.23->1.1.2.24 src/MsgPipeData.h:1.1.2.10->1.1.2.11 src/StoreIOBuffer.h:1.4.12.3->1.4.12.4 src/http.cc:1.49.2.24->1.49.2.25 Index: squid3/src/ChunkedCodingParser.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ChunkedCodingParser.cc,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -r1.1.2.4 -r1.1.2.5 --- squid3/src/ChunkedCodingParser.cc 1 Sep 2005 20:58:10 -0000 1.1.2.4 +++ squid3/src/ChunkedCodingParser.cc 18 Sep 2005 04:12:42 -0000 1.1.2.5 @@ -2,6 +2,7 @@ #include "Parsing.h" #include "TextException.h" #include "ChunkedCodingParser.h" +#include "MemBuf.h" ChunkedCodingParser::Step ChunkedCodingParser::psChunkBeg = &ChunkedCodingParser::parseChunkBeg; ChunkedCodingParser::Step ChunkedCodingParser::psChunkBody = &ChunkedCodingParser::parseChunkBody; Index: squid3/src/HttpMsg.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/HttpMsg.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -u -r1.1.2.3 -r1.1.2.4 --- squid3/src/HttpMsg.h 16 Sep 2005 15:35:36 -0000 1.1.2.3 +++ squid3/src/HttpMsg.h 18 Sep 2005 04:12:42 -0000 1.1.2.4 @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.h,v 1.1.2.3 2005/09/16 15:35:36 dwsquid Exp $ + * $Id: HttpMsg.h,v 1.1.2.4 2005/09/18 04:12:42 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -49,12 +49,7 @@ virtual void reset() = 0; // will have body when http*Clean()s are gone - // 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 - virtual bool parse(MemBuf *buf, bool eof, http_status *error) = 0; - - void packInto(Packer * p) const; + void packInto(Packer * p, bool full_uri) const; public: HttpVersion http_ver; @@ -70,7 +65,17 @@ int content_length; protocol_t protocol; + HttpMsgParseState pstate; /* the current parsing state */ + // 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 + bool parse(MemBuf *buf, bool eol, http_status *error); + int httpMsgParseStep(const char *buf, int atEnd); + int httpMsgParseError(); + + protected: + virtual bool sanityCheckStartLine(MemBuf *buf, http_status *error) = 0; virtual void packFirstLineInto(Packer * p, bool full_uri) const = 0; virtual bool parseFirstLine(const char *blk_start, const char *blk_end) = 0; virtual void hdrCacheInit(); Index: squid3/src/ICAPAnchor.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPAnchor.cc,v retrieving revision 1.1.2.27 retrieving revision 1.1.2.28 diff -u -r1.1.2.27 -r1.1.2.28 --- squid3/src/ICAPAnchor.cc 10 Sep 2005 03:59:09 -0000 1.1.2.27 +++ squid3/src/ICAPAnchor.cc 18 Sep 2005 04:12:42 -0000 1.1.2.28 @@ -44,7 +44,7 @@ virgin->data->cause = requestLink(request); virgin->data->header = reply; virgin->data->body = new MemBuf; - memBufInit(virgin->data->body, ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax); + virgin->data->body->init(ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax); adapted = new MsgPipe("adapted"); leakTouch(adapted.getRaw(), leaky); Index: squid3/src/ICAPClientSideHook.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPClientSideHook.cc,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -u -r1.1.2.2 -r1.1.2.3 --- squid3/src/ICAPClientSideHook.cc 10 Sep 2005 03:59:09 -0000 1.1.2.2 +++ squid3/src/ICAPClientSideHook.cc 18 Sep 2005 04:12:42 -0000 1.1.2.3 @@ -46,7 +46,7 @@ virgin->data->cause = NULL; virgin->data->header = requestLink(request); virgin->data->body = new MemBuf; - memBufInit(virgin->data->body, ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax); + virgin->data->body->init(ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax); adapted = new MsgPipe("adapted"); leakTouch(adapted.getRaw(), leaky); @@ -55,7 +55,7 @@ adapted->data = new MsgPipeData; adapted->data->body = new MemBuf; - memBufInit(adapted->data->body, ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax); + adapted->data->body->init(ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax); #else ICAPInitXaction(virgin, adapted); Index: squid3/src/ICAPXaction.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/ICAPXaction.cc,v retrieving revision 1.1.2.23 retrieving revision 1.1.2.24 diff -u -r1.1.2.23 -r1.1.2.24 --- squid3/src/ICAPXaction.cc 10 Sep 2005 03:59:09 -0000 1.1.2.23 +++ squid3/src/ICAPXaction.cc 18 Sep 2005 04:12:42 -0000 1.1.2.24 @@ -130,14 +130,14 @@ adapted->data = new MsgPipeData; adapted->data->header = httpReplyCreate(); // who is deleting? refcount? adapted->data->body = new MemBuf; // XXX: make body a non-pointer? - memBufInit(adapted->data->body, ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax); + adapted->data->body->init(ICAPMsgPipeBufSizeMin, ICAPMsgPipeBufSizeMax); // headers are initialized when we parse them // writing end // nothing to do because we are using temporary write buffers // reading end - memBufDefInit(&readBuf); + readBuf.init(); // encoding // nothing to do because we are using temporary buffers @@ -215,7 +215,7 @@ startReading(); // wait for early errors from the ICAP server MemBuf requestBuf; - memBufDefInit(&requestBuf); + requestBuf.init(); makeRequestHeaders(&requestBuf); // write headers only; comm module will free the requestBuf state.isWriting = &ICAPXaction_noteCommWroteHeaders; @@ -246,7 +246,7 @@ MemBuf writeBuf; // TODO: suggest a min size based on body and lastChunk - memBufDefInit(&writeBuf); + writeBuf.init(); if (body->hasContent()) { debugs(93, 7, "ICAPXaction will write " << body->contentSize() << @@ -271,7 +271,7 @@ state.isWriting = &ICAPXaction_noteCommWroteBody; comm_old_write_mbuf(connection, &writeBuf, state.isWriting, this); } else { - memBufClean(&writeBuf); + writeBuf.clean(); } } @@ -279,7 +279,7 @@ { MsgPipeData::Body *body = virgin->data->body; const mb_size_t chunkSize = body->contentSize(); // may be zero - memBufPrintf(buf, "%x\r\n", chunkSize); + buf->Printf("%x\r\n", chunkSize); if (chunkSize > 0) { buf->append(body->content(), chunkSize); @@ -578,7 +578,7 @@ { debugs(93, 5, "ICAPXaction::doStop"); - memBufClean(&readBuf); + readBuf.clean(); if (icapReply) httpReplyDestroy(icapReply); @@ -620,12 +620,12 @@ void ICAPXaction::makeRequestHeaders(MemBuf *buf) { // start building ICAP request header; XXX: REQMOD for REQMOD - memBufPrintf(buf, "RESPMOD %s ICAP/1.0\r\n", service->uri); - memBufPrintf(buf, "Host: %s:%d\r\n", service->host, service->port); - memBufPrintf(buf, "Encapsulated:"); + buf->Printf("RESPMOD %s ICAP/1.0\r\n", service->uri); + buf->Printf("Host: %s:%d\r\n", service->host, service->port); + buf->Printf("Encapsulated:"); MemBuf httpBuf; - memBufDefInit(&httpBuf); + httpBuf.init(); // build HTTP request header, if any @@ -637,7 +637,7 @@ encapsulateHead(buf, "res-hdr", &httpBuf, prime); // XXX: req-hdr for REQMOD // update ICAP header; XXX: req-body for REQMOD or null-body! - memBufPrintf(buf, "res-body=%d", httpBuf.contentSize()); + buf->Printf("res-body=%d", httpBuf.contentSize()); // finish ICAP header buf->append(crlf, 2); // CRLF terminator @@ -645,18 +645,18 @@ // start ICAP request body with encapsulated HTTP headers buf->append(httpBuf.content(), httpBuf.contentSize()); - memBufClean(&httpBuf); + httpBuf.clean(); } void ICAPXaction::encapsulateHead(MemBuf *icapBuf, const char *section, MemBuf *httpBuf, const HttpMsg *head) { // update ICAP header - memBufPrintf(icapBuf, "%s=%d,", section, httpBuf->contentSize()); + icapBuf->Printf("%s=%d,", section, httpBuf->contentSize()); // pack HTTP head Packer p; packerToMemInit(&p, httpBuf); - head->packInto(&p); + head->packInto(&p, true); packerClean(&p); } @@ -701,12 +701,12 @@ const char *ICAPXaction::status() const { static MemBuf status; - memBufReset(&status); + status.reset(); status.append("[", 1); if (notify != notifyUnknown) - memBufPrintf(&status, "N(%d)", notify); + status.Printf("N(%d)", notify); if (state.doneReceiving) status.append("R", 1); Index: squid3/src/MsgPipeData.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/Attic/MsgPipeData.h,v retrieving revision 1.1.2.10 retrieving revision 1.1.2.11 diff -u -r1.1.2.10 -r1.1.2.11 --- squid3/src/MsgPipeData.h 8 Sep 2005 07:40:15 -0000 1.1.2.10 +++ squid3/src/MsgPipeData.h 18 Sep 2005 04:12:42 -0000 1.1.2.11 @@ -1,6 +1,6 @@ /* - * $Id: MsgPipeData.h,v 1.1.2.10 2005/09/08 07:40:15 rousskov Exp $ + * $Id: MsgPipeData.h,v 1.1.2.11 2005/09/18 04:12:42 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -35,8 +35,7 @@ #define SQUID_MSGPIPEDATA_H #include "HttpMsg.h" - -class MemBuf; +#include "MemBuf.h" // MsgPipeData contains information about the HTTP message being sent // from the pipe source to the sink. Since the entire message body may be @@ -57,7 +56,7 @@ assert(NULL == header); if (body) { - memBufClean(body); + body->clean(); delete body; } }; Index: squid3/src/StoreIOBuffer.h =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/StoreIOBuffer.h,v retrieving revision 1.4.12.3 retrieving revision 1.4.12.4 diff -u -r1.4.12.3 -r1.4.12.4 --- squid3/src/StoreIOBuffer.h 26 Aug 2005 20:28:41 -0000 1.4.12.3 +++ squid3/src/StoreIOBuffer.h 18 Sep 2005 04:12:42 -0000 1.4.12.4 @@ -1,6 +1,6 @@ /* - * $Id: StoreIOBuffer.h,v 1.4.12.3 2005/08/26 20:28:41 dwsquid Exp $ + * $Id: StoreIOBuffer.h,v 1.4.12.4 2005/09/18 04:12:42 dwsquid Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -37,8 +37,7 @@ /* TODO: move this and the range() method into a .cci */ #include "Range.h" - -//class MemBuf; +#include "MemBuf.h" class StoreIOBuffer { Index: squid3/src/http.cc =================================================================== RCS file: /cvsroot/squid-sf//squid3/src/http.cc,v retrieving revision 1.49.2.24 retrieving revision 1.49.2.25 diff -u -r1.49.2.24 -r1.49.2.25 --- squid3/src/http.cc 18 Sep 2005 03:42:58 -0000 1.49.2.24 +++ squid3/src/http.cc 18 Sep 2005 04:12:42 -0000 1.49.2.25 @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.49.2.24 2005/09/18 03:42:58 dwsquid Exp $ + * $Id: http.cc,v 1.49.2.25 2005/09/18 04:12:42 dwsquid Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -98,7 +98,7 @@ storeUnlockObject(httpState->entry); - if (!httpState->reply_hdr->isClean()) { + if (!httpState->reply_hdr->isNull()) { httpState->reply_hdr->clean(); } @@ -705,12 +705,12 @@ debug(11, 3) ("httpProcessReplyHeader: key '%s'\n", entry->getMD5Text()); - if (reply_hdr.isNull()) - reply_hdr.init(); + if (reply_hdr->isNull()) + reply_hdr->init(); assert(!flags.headers_parsed); - reply_hdr.append(buf, size); + reply_hdr->append(buf, size); http_status error = HTTP_STATUS_NONE;