]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
My recent HttpReply changes created an awkward situation. Both
authorwessels <>
Tue, 8 Nov 2005 05:00:38 +0000 (05:00 +0000)
committerwessels <>
Tue, 8 Nov 2005 05:00:38 +0000 (05:00 +0000)
HttpReply and its base class HttpMsg had methods named parse() but
had different number and type of arugments.

This patch moves HttpReply::parse() to HttpMsg::parseCharBuf()

both parse() and parseCharBuf() use httpMsgParseStep()

src/HttpMsg.cc
src/HttpMsg.h
src/HttpReply.cc
src/HttpReply.h
src/client_side_reply.cc
src/http.cc
src/store_client.cc
src/urn.cc

index bee1ce4a687d6c16b098210ee5558ab42dd32d96..07b77984d40ddb227e231c320fc6ed1c7a2057ef 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpMsg.cc,v 1.18 2005/09/17 04:53:44 wessels Exp $
+ * $Id: HttpMsg.cc,v 1.19 2005/11/07 22:00:38 wessels Exp $
  *
  * DEBUG: section 74    HTTP Message
  * AUTHOR: Alex Rousskov
@@ -201,7 +201,28 @@ bool HttpMsg::parse(MemBuf *buf, bool eof, http_status *error)
     return true;
 }
 
-
+/*
+ * parse() takes character buffer of HTTP headers (buf),
+ * which may not be NULL-terminated, and fills in an HttpMsg
+ * structure.  The parameter 'end' specifies the offset to
+ * the end of the reply headers.  The caller may know where the
+ * end is, but is unable to NULL-terminate the buffer.  This function
+ * returns true on success.
+ */
+bool
+HttpMsg::parseCharBuf(const char *buf, ssize_t end)
+{
+    MemBuf mb;
+    int success;
+    /* reset current state, because we are not used in incremental fashion */
+    reset();
+    mb.init();
+    mb.append(buf, end);
+    mb.terminate();
+    success = httpMsgParseStep(mb.buf, 0);
+    mb.clean();
+    return success == 1;
+}
 
 /*
  * parses a 0-terminating buffer into HttpMsg.
index 4fbcc5ddf6778de6b439373f8c4a3d404ed8840c..838bc21a1b9ccce924678ed9daf81022643b177f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpMsg.h,v 1.3 2005/09/15 20:19:41 wessels Exp $
+ * $Id: HttpMsg.h,v 1.4 2005/11/07 22:00:38 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -72,6 +72,7 @@ public:
 
     HttpMsgParseState pstate;  /* the current parsing state */
     bool parse(MemBuf *buf, bool eol, http_status *error);
+    bool parseCharBuf(const char *buf, ssize_t end);
     int httpMsgParseStep(const char *buf, int atEnd);
     int httpMsgParseError();
 
index b3f8f3ca25f64c75d1a256bf05b1c5f656c6327b..6fbe9aca7ce164c90596d7808288c7b6066c6abf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpReply.cc,v 1.78 2005/11/05 00:08:32 wessels Exp $
+ * $Id: HttpReply.cc,v 1.79 2005/11/07 22:00:38 wessels Exp $
  *
  * DEBUG: section 58    HTTP Reply (Response)
  * AUTHOR: Alex Rousskov
@@ -118,37 +118,6 @@ HttpReply::absorb(HttpReply * new_rep)
     delete new_rep;
 }
 
-/*
- * parse() takes character buffer of HTTP headers (buf),
- * which may not be NULL-terminated, and fills in an HttpReply
- * structure (rep).  The parameter 'end' specifies the offset to
- * the end of the reply headers.  The caller may know where the
- * end is, but is unable to NULL-terminate the buffer.  This function
- * returns true on success.
- */
-bool
-HttpReply::parse(const char *buf, ssize_t end)
-{
-    /*
-     * this extra buffer/copy will be eliminated when headers become
-     * meta-data in store. Currently we have to xstrncpy the buffer
-     * becuase somebody may feed a non NULL-terminated buffer to
-     * us.
-     */
-    MemBuf mb;
-    int success;
-    /* reset current state, because we are not used in incremental fashion */
-    reset();
-    /* put a string terminator.  s is how many bytes to touch in
-     * 'buf' including the terminating NULL. */
-    mb.init();
-    mb.append(buf, end);
-    mb.terminate();
-    success = httpMsgParseStep(mb.buf, 0);
-    mb.clean();
-    return success == 1;
-}
-
 void
 HttpReply::packHeadersInto(Packer * p) const
 {
index 8e61e38c1b3e809347057c51364eb0bf64a4ab42..35be53b92beaa0e614f4c06a66826347ef22419a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpReply.h,v 1.12 2005/11/05 00:08:32 wessels Exp $
+ * $Id: HttpReply.h,v 1.13 2005/11/07 22:00:38 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -78,8 +78,6 @@ public:
 
 public:
     void updateOnNotModified(HttpReply const *other);
-    /* parse returns true on success */
-    bool parse(const char *buf, ssize_t);
     /* absorb: copy the contents of a new reply to the old one, destroy new one */
     void absorb(HttpReply * new_rep);
     /* set commonly used info with one call */
index 2071105caaa63a165300e3a2a8f40761f11422a6..70e05196b54049406693ec723a71519c62bf02ce 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_reply.cc,v 1.89 2005/11/05 00:08:32 wessels Exp $
+ * $Id: client_side_reply.cc,v 1.90 2005/11/07 22:00:38 wessels Exp $
  *
  * DEBUG: section 88    Client-side Reply Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -1466,7 +1466,7 @@ clientReplyContext::buildReply(const char *buf, size_t size)
 
     holdReply(new HttpReply);
 
-    if (!holdingReply->parse(buf, k)) {
+    if (!holdingReply->parseCharBuf(buf, k)) {
         /* parsing failure, get rid of the invalid reply */
         delete holdingReply;
         holdReply (NULL);
index 7a7b387542acf2998c1767779da851b8e305aa09..19473129ab186e8a9fbf7da95ea26658d4b34854 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.465 2005/11/05 00:08:32 wessels Exp $
+ * $Id: http.cc,v 1.466 2005/11/07 22:00:38 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -719,7 +719,7 @@ HttpStateData::processReplyHeader(const char *buf, int size)
 
     /* Parse headers into reply structure */
     /* what happens if we fail to parse here? */
-    reply->parse(reply_hdr.buf, hdr_size);
+    reply->parseCharBuf(reply_hdr.buf, hdr_size);
 
     if (reply->sline.status >= HTTP_INVALID_HEADER) {
         debugs(11, 3, "processReplyHeader: Non-HTTP-compliant header: '" << reply_hdr.buf << "'");
index 9bf06f82eb2ed1f8f19c5aadfa0f7f61859c1c70..f5b701fabb737ea29f2b4b04c07c33d09b565a9d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_client.cc,v 1.143 2005/11/05 00:08:33 wessels Exp $
+ * $Id: store_client.cc,v 1.144 2005/11/07 22:00:38 wessels Exp $
  *
  * DEBUG: section 90    Storage Manager Client-Side Interface
  * AUTHOR: Duane Wessels
@@ -481,7 +481,7 @@ storeClientReadBody(void *data, const char *buf, ssize_t len)
         /* Our structure ! */
         HttpReply *rep = (HttpReply *) sc->entry->getReply(); // bypass const
 
-        if (!rep->parse(sc->copyInto.data, headersEnd(sc->copyInto.data, len))) {
+        if (!rep->parseCharBuf(sc->copyInto.data, headersEnd(sc->copyInto.data, len))) {
             debug (90,0)("Could not parse headers from on disk object\n");
         }
     }
@@ -592,7 +592,7 @@ store_client::readHeader(char const *buf, ssize_t len)
             /* Our structure ! */
             HttpReply *rep = (HttpReply *) entry->getReply(); // bypass const
 
-            if (!rep->parse(copyInto.data, headersEnd(copyInto.data, copy_sz))) {
+            if (!rep->parseCharBuf(copyInto.data, headersEnd(copyInto.data, copy_sz))) {
                 debug (90,0)("could not parse headers from on disk structure!\n");
             }
         }
index 7ce0c261ebdf8a507cb1c60dc4bbedf512e7783d..e77320098cef2606bf1fd7e015303f1dce766cc6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: urn.cc,v 1.91 2005/11/05 00:08:33 wessels Exp $
+ * $Id: urn.cc,v 1.92 2005/11/07 22:00:38 wessels Exp $
  *
  * DEBUG: section 52    URN Parsing
  * AUTHOR: Kostas Anagnostakis
@@ -368,7 +368,7 @@ urnHandleReply(void *data, StoreIOBuffer result)
     s = buf + k;
     assert(urlres_e->getReply());
     rep = new HttpReply;
-    rep->parse(buf, k);
+    rep->parseCharBuf(buf, k);
     debug(52, 3) ("reply exists, code=%d.\n",
                   rep->sline.status);