]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
First stab at header cloning. The motivation behind this is to get rid
authorHenrik Nordstrom <henrik@henriknordstrom.net>
Sat, 15 Mar 2008 18:03:11 +0000 (19:03 +0100)
committerHenrik Nordstrom <henrik@henriknordstrom.net>
Sat, 15 Mar 2008 18:03:11 +0000 (19:03 +0100)
of the need of buffering response headers in the server side code
(client_side_reply). A positive sideeffect is that this should also
improve performance considerably.

src/HttpReply.cc
src/HttpReply.h
src/client_side_reply.cc

index ee6718ad623057ae31ed8cf175df11189ab8f633..7f8ab7f449192da73d88931cec579025abfcbebd 100644 (file)
@@ -551,3 +551,13 @@ HttpReply::calcMaxBodySize(HttpRequest& request)
         }
     }
 }
+
+HttpReply *
+HttpReply::clone() const
+{
+    HttpReply *rep = new HttpReply();
+    rep->header.append(&header);
+    rep->hdrCacheInit();
+    rep->hdr_sz = hdr_sz;
+    return rep;
+}
index ac21e44164375dd77833b3bb2b7bf231b9ffff6f..16cc1834a7d4abb66a6150206ec86d491922bbd2 100644 (file)
@@ -130,6 +130,11 @@ public:
 
     void packHeadersInto(Packer * p) const;
 
+    /// Clone this reply.
+    /// Could be done as a copy-contructor but we do not want to
+    /// accidently copy a HttpReply..
+    HttpReply *clone() const;
+
 private:
     /* initialize */
     void init();
index 38408bbbe56de292683c70ab1d70e9e3b842d377..b74ace1ef2b50ef432a67dd5b9d6e0af31329ad5 100644 (file)
@@ -1912,28 +1912,13 @@ clientReplyContext::sendMoreData (StoreIOBuffer result)
 
     char *body_buf = buf;
 
-    /* This is always valid until we get the headers as metadata from
-     * storeClientCopy. 
-     * Then it becomes reqofs == next->readBuffer.offset()
-     */
-    assert(reqofs == 0 || flags.storelogiccomplete);
-
-    if (flags.headersSent && buf != result.data) {
+    if (buf != result.data) {
         /* we've got to copy some data */
         assert(result.length <= next()->readBuffer.length);
         xmemcpy(buf, result.data, result.length);
         body_buf = buf;
-    } else if (!flags.headersSent &&
-               buf + reqofs !=result.data) {
-        /* we've got to copy some data */
-        assert(result.length + reqofs <= next()->readBuffer.length);
-        xmemcpy(buf + reqofs, result.data, result.length);
-        body_buf = buf;
     }
 
-    /* We've got the final data to start pushing... */
-    flags.storelogiccomplete = 1;
-
     reqofs += result.length;
 
     assert(reqofs <= HTTP_REQBUF_SZ || flags.headersSent);
@@ -1967,8 +1952,13 @@ clientReplyContext::sendMoreData (StoreIOBuffer result)
         return;
     }
 
-    buildReply(buf, reqofs);
-
+    if (!reply) {
+       reply = entry->mem_obj->getReply()->clone();
+    }
+    if ((long)reqofs < reply->hdr_sz) {
+        waitForMoreData();
+        return;
+    }
     if (reply) {
 
         /* handle headers */
@@ -1987,9 +1977,6 @@ clientReplyContext::sendMoreData (StoreIOBuffer result)
         processReplyAccess();
         return;
 
-    } else if (reqofs < HTTP_REQBUF_SZ && entry->store_status == STORE_PENDING) {
-        waitForMoreData();
-        return;
     } else {
         debugs(88, 0, "clientReplyContext::sendMoreData: Unable to parse reply headers within a single HTTP_REQBUF_SZ length buffer");
         StoreIOBuffer tempBuffer;