]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
Bad things were happening when we copied the mem->reply structure
authorwessels <>
Tue, 11 Nov 1997 03:54:30 +0000 (03:54 +0000)
committerwessels <>
Tue, 11 Nov 1997 03:54:30 +0000 (03:54 +0000)
from a 'NOT MODIFIED' reply over to the old object.  Specifically,
www.thegist.com (netscape/1.13) sends us a bogus content-length.
this content length seems to refer to the size of the NOT MODIFIED
reply headers instead of the URI body!

src/client_side.cc
src/protos.h
src/store.cc

index 5a5f40f0e3f721de3aa327a4211213396d64deee..38333778dfb99ab80010a0382b38f49da12f6fb4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.142 1997/11/05 19:52:22 wessels Exp $
+ * $Id: client_side.cc,v 1.143 1997/11/10 20:54:30 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -280,7 +280,11 @@ icpHandleIMSReply(void *data, char *buf, ssize_t size)
            oldentry->mem_obj->request = requestLink(mem->request);
            unlink_request = 1;
        }
-       memcpy(oldentry->mem_obj->reply, entry->mem_obj->reply, sizeof(struct _http_reply));
+       /* Don't memcpy() the whole reply structure here.  For example,
+        * www.thegist.com (Netscape/1.13) returns a content-length for
+        * 304's which seems to be the length of the 304 HEADERS!!! and
+        * not the body they refer to.  */
+       storeCopyNotModifiedReplyHeaders(entry->mem_obj, oldentry->mem_obj);
        storeTimestampsSet(oldentry);
        storeUnregister(entry, http);
        storeUnlockObject(entry);
@@ -1698,7 +1702,6 @@ icpCheckTransferDone(clientHttpRequest * http)
 {
     StoreEntry *entry = http->entry;
     MemObject *mem = NULL;
-
     if (entry == NULL)
        return 0;
     if (entry->store_status != STORE_PENDING)
@@ -1708,6 +1711,7 @@ icpCheckTransferDone(clientHttpRequest * http)
        return 0;
     if (mem->reply->content_length == 0)
        return 0;
+    assert(http->out.offset <= mem->reply->content_length + mem->reply->hdr_sz);
     if (http->out.offset >= mem->reply->content_length + mem->reply->hdr_sz)
        return 1;
     return 0;
index d0293ae84b88f3a9e7cd327dbe36aa7a81412a40..eb7027cefed3a0ea0be386e06655d4eb52ccc3f5 100644 (file)
@@ -461,6 +461,7 @@ extern void storeUnregisterAbort(StoreEntry * e);
 extern void storeMemObjectDump(MemObject * mem);
 extern const char *storeUrl(const StoreEntry *);
 extern void storeCreateMemObject(StoreEntry *, const char *, const char *);
+extern void storeCopyNotModifiedReplyHeaders(MemObject * O, MemObject * N);
 
 /* storeKey stuff */
 extern const cache_key *storeKeyDup(const cache_key *);
index 973edcf811205f52d2cb9a34a60ca4abb8938bdc..940a97f19c8b974532f4d3fa9f508981a8778519 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.336 1997/11/05 20:00:57 wessels Exp $
+ * $Id: store.cc,v 1.337 1997/11/10 20:54:33 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -2359,3 +2359,18 @@ storeCreateMemObject(StoreEntry * e, const char *url, const char *log_url)
        return;
     e->mem_obj = new_MemObject(url, log_url);
 }
+
+void
+storeCopyNotModifiedReplyHeaders(MemObject * oldmem, MemObject * newmem)
+{
+    http_reply *oldreply = oldmem->reply;
+    http_reply *newreply = newmem->reply;
+    oldreply->cache_control = newreply->cache_control;
+    oldreply->misc_headers = newreply->misc_headers;
+    if (newreply->date > -1)
+       oldreply->date = newreply->date;
+    if (newreply->last_modified > -1)
+       oldreply->last_modified = newreply->last_modified;
+    if (newreply->expires > -1)
+       oldreply->expires = newreply->expires;
+}