From: wessels <> Date: Tue, 11 Nov 1997 03:54:30 +0000 (+0000) Subject: Bad things were happening when we copied the mem->reply structure X-Git-Tag: SQUID_3_0_PRE1~4556 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=64763c372ab0ee654eca588084f952e28512aa55;p=thirdparty%2Fsquid.git Bad things were happening when we copied the mem->reply structure 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! --- diff --git a/src/client_side.cc b/src/client_side.cc index 5a5f40f0e3..38333778df 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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; diff --git a/src/protos.h b/src/protos.h index d0293ae84b..eb7027cefe 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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 *); diff --git a/src/store.cc b/src/store.cc index 973edcf811..940a97f19c 100644 --- a/src/store.cc +++ b/src/store.cc @@ -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; +}