=== modified file 'src/HttpMsg.cc' --- src/HttpMsg.cc 2011-03-26 02:03:49 +0000 +++ src/HttpMsg.cc 2011-03-30 10:26:31 +0000 @@ -375,21 +375,14 @@ delete this; } - void HttpParserInit(HttpParser *hdr, const char *buf, int bufsiz) { + hdr->reset(); hdr->state = 1; - hdr->request_parse_status = HTTP_STATUS_NONE; hdr->buf = buf; hdr->bufsiz = bufsiz; - hdr->req_start = hdr->req_end = -1; - hdr->hdr_start = hdr->hdr_end = -1; debugs(74, 5, "httpParseInit: Request buffer is " << buf); - hdr->m_start = hdr->m_end = -1; - hdr->u_start = hdr->u_end = -1; - hdr->v_start = hdr->v_end = -1; - hdr->v_maj = hdr->v_min = 0; } #if MSGDODEBUG @@ -439,6 +432,21 @@ HttpParserInit(this, buf, len); } +void +HttpParser::reset() +{ + state = 0; + request_parse_status = HTTP_STATUS_NONE; + buf = NULL; // NP: we do not own the buffer, merely reference to it. + bufsiz = 0; + req_start = req_end = -1; + hdr_start = hdr_end = -1; + m_start = m_end = -1; + u_start = u_end = -1; + v_start = v_end = -1; + v_maj = v_min = 0; +} + int HttpParser::parseRequestFirstLine() { === modified file 'src/HttpMsg.h' --- src/HttpMsg.h 2011-03-26 02:03:49 +0000 +++ src/HttpMsg.h 2011-03-30 10:24:36 +0000 @@ -136,9 +136,13 @@ class HttpParser { public: - HttpParser() {}; + HttpParser() { reset(); }; HttpParser(const char *buf, int len); + /// Set this parser back to an empty state. + /// Will DROP any reference to a buffer (does not free). + void reset(); + /** * Attempt to parse the first line of a new request message. *