Index: icp.c =================================================================== RCS file: /surf1/CVS/squid/src/icp.c,v retrieving revision 1.61.2.72 diff -c -w -r1.61.2.72 icp.c *** icp.c 1996/06/06 19:34:58 1.61.2.72 --- icp.c 1996/06/07 20:37:57 *************** *** 8,13 **** --- 8,14 ---- int neighbors_do_private_keys = 1; + static char NotModified[] = "HTTP/1.0 304 Not Modified\r\n\r\n"; static char *log_tags[] = { "LOG_NONE", *************** *** 415,426 **** icpStateData *icpState; { StoreEntry *entry = icpState->entry; ! char *buf = icpState->buf; int buf_len = icpState->offset; int len; int max_len = 8191 - buf_len; ! char *p = buf + buf_len; ! char *IMS_hdr; time_t IMS; int IMS_length; time_t date; --- 416,427 ---- icpStateData *icpState; { StoreEntry *entry = icpState->entry; ! MemObject *mem = entry->mem_obj; int buf_len = icpState->offset; int len; int max_len = 8191 - buf_len; ! char *p = icpState->buf + buf_len; ! char *IMS_hdr = NULL; time_t IMS; int IMS_length; time_t date; *************** *** 436,452 **** storeClientCopy(entry, icpState->offset, max_len, p, &len, fd); buf_len = icpState->offset = +len; ! if (!mime_headers_end(buf)) { /* All headers are not yet available, wait for more data */ storeRegister(entry, fd, (PIF) icpHandleStoreIMS, (void *) icpState); return COMM_OK; } /* All headers are available, check if object is modified or not */ IMS_hdr = mime_get_header(icpState->request_hdr, "If-Modified-Since"); ! httpParseHeaders(buf, entry->mem_obj->reply); ! ! /* Headers is no longer needed (they are parsed) */ ! icpFreeBufOrPage(icpState); if (!IMS_hdr) fatal_dump("icpGetHeadersForIMS: Cant find IMS header in request\n"); --- 437,450 ---- storeClientCopy(entry, icpState->offset, max_len, p, &len, fd); buf_len = icpState->offset = +len; ! if (!mime_headers_end(icpState->buf)) { /* All headers are not yet available, wait for more data */ storeRegister(entry, fd, (PIF) icpHandleStoreIMS, (void *) icpState); return COMM_OK; } /* All headers are available, check if object is modified or not */ IMS_hdr = mime_get_header(icpState->request_hdr, "If-Modified-Since"); ! httpParseHeaders(icpState->buf, mem->reply); if (!IMS_hdr) fatal_dump("icpGetHeadersForIMS: Cant find IMS header in request\n"); *************** *** 455,461 **** /* Only objects with statuscode==200 can be "Not modified" */ /* XXX: Should we ignore this? */ ! if (entry->mem_obj->reply->code != 200) return icpProcessMISS(fd, icpState); p = strtok(IMS_hdr, ";"); IMS = parse_rfc850(p); --- 453,459 ---- /* Only objects with statuscode==200 can be "Not modified" */ /* XXX: Should we ignore this? */ ! if (mem->reply->code != 200) return icpProcessMISS(fd, icpState); p = strtok(IMS_hdr, ";"); IMS = parse_rfc850(p); *************** *** 468,492 **** } /* Find date when the object last was modified */ ! if (*entry->mem_obj->reply->last_modified) ! date = parse_rfc850(entry->mem_obj->reply->last_modified); ! else if (*entry->mem_obj->reply->date) ! date = parse_rfc850(entry->mem_obj->reply->date); else date = entry->timestamp; /* Find size of the object */ ! if (entry->mem_obj->reply->content_length) ! length = entry->mem_obj->reply->content_length; else ! length = entry->object_len - mime_headers_size(buf); /* Compare with If-Modified-Since header */ if (IMS > date || (IMS == date && (IMS_length < 0 || IMS_length == length))) { /* The object is not modified */ debug(12, 4, "icpGetHeadersForIMS: Not modified '%s'\n", entry->url); ! strcpy(buf, "HTTP/1.0 304 Not modified\n\r\n\r"); ! comm_write(fd, "HTTP/1.0 304 Not modified\r\n\r\n", strlen("HTTP/1.0 304 Not modified\r\n\r\n"), 30, icpHandleIMSComplete, (void *) icpState); return COMM_OK; } else { debug(12, 4, "icpGetHeadersForIMS: We have newer '%s'\n", entry->url); --- 466,497 ---- } /* Find date when the object last was modified */ ! if (*mem->reply->last_modified) ! date = parse_rfc850(mem->reply->last_modified); ! else if (*mem->reply->date) ! date = parse_rfc850(mem->reply->date); else date = entry->timestamp; /* Find size of the object */ ! if (mem->reply->content_length) ! length = mem->reply->content_length; else ! length = entry->object_len - mime_headers_size(icpState->buf); ! ! /* Headers is no longer needed (they are parsed) */ ! icpFreeBufOrPage(icpState); /* Compare with If-Modified-Since header */ if (IMS > date || (IMS == date && (IMS_length < 0 || IMS_length == length))) { /* The object is not modified */ debug(12, 4, "icpGetHeadersForIMS: Not modified '%s'\n", entry->url); ! comm_write(fd, ! NotModified, ! strlen(NotModified), ! 30, ! icpHandleIMSComplete, ! icpState); return COMM_OK; } else { debug(12, 4, "icpGetHeadersForIMS: We have newer '%s'\n", entry->url);