--------------------- PatchSet 5192 Date: 2002/10/02 12:32:13 Author: rbcollins Branch: fixrange Tag: (none) Log: flushing merged store changes Members: src/HttpReply.c:1.10->1.10.40.1 src/HttpReply.h:1.1->1.1.4.1 src/HttpRequest.c:1.7->1.7.60.1 src/HttpRequest.h:1.1->1.1.4.1 src/acl.c:1.58->1.58.2.1 src/asn.c:1.17.14.6->1.17.14.7 src/cache_manager.c:1.7->1.7.66.1 src/clientStream.c:1.2.8.10->1.2.8.11 src/client_side.c:1.72.2.45->1.72.2.46 src/client_side_reply.c:1.4.6.25->1.4.6.26 src/client_side_request.c:1.3.6.10->1.3.6.11 src/errorpage.c:1.23->1.23.2.1 src/forward.c:1.17->1.17.2.1 src/ftp.c:1.28->1.28.2.1 src/gopher.c:1.18.2.1->1.18.2.2 src/http.c:1.24.2.6->1.24.2.7 src/icp_v2.c:1.6->1.6.6.1 src/icp_v3.c:1.5->1.5.6.1 src/internal.c:1.9->1.9.14.1 src/main.c:1.36->1.36.6.1 src/mem.c:1.21->1.21.2.1 src/mem_node.h:1.1->1.1.2.1 src/mime.c:1.12->1.12.2.1 src/neighbors.c:1.20->1.20.2.1 src/net_db.c:1.15->1.15.10.1 src/peer_select.c:1.16->1.16.2.1 src/protos.h:1.61.2.8->1.61.2.9 src/refresh.c:1.8->1.8.10.1 src/ssl.c:1.16->1.16.2.1 src/stmem.c:1.8.2.1->1.8.2.2 src/stmem.h:1.1.2.1->1.1.2.2 src/store.c:1.18.2.1->1.18.2.2 src/store_client.c:1.14.2.12->1.14.2.13 src/store_log.c:1.7->1.7.40.1 src/store_swapout.c:1.13.14.2->1.13.14.3 src/structs.h:1.68.2.4->1.68.2.5 src/typedefs.h:1.28.2.3->1.28.2.4 src/url.c:1.11->1.11.2.1 src/urn.c:1.17.2.7->1.17.2.8 src/wais.c:1.9->1.9.2.1 src/whois.c:1.9->1.9.6.1 Index: squid/src/HttpReply.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpReply.c,v retrieving revision 1.10 retrieving revision 1.10.40.1 diff -u -r1.10 -r1.10.40.1 --- squid/src/HttpReply.c 24 Oct 2001 09:42:11 -0000 1.10 +++ squid/src/HttpReply.c 2 Oct 2002 12:32:13 -0000 1.10.40.1 @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.c,v 1.10 2001/10/24 09:42:11 squidadm Exp $ + * $Id: HttpReply.c,v 1.10.40.1 2002/10/02 12:32:13 rbcollins Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -33,6 +33,7 @@ * */ +#include "HttpReply.h" #include "squid.h" @@ -158,12 +159,19 @@ } void -httpReplyPackInto(const HttpReply * rep, Packer * p) +httpReplyPackHeadersInto(const HttpReply * rep, Packer * p) { assert(rep); httpStatusLinePackInto(&rep->sline, p); httpHeaderPackInto(&rep->header, p); packerAppend(p, "\r\n", 2); +} + + +void +httpReplyPackInto(const HttpReply * rep, Packer * p) +{ + httpReplyPackHeadersInto(rep, p); httpBodyPackInto(&rep->body, p); } @@ -182,16 +190,15 @@ return mb; } -/* swap: create swap-based packer, pack, destroy packer */ +/* swap: create swap-based packer, pack, destroy packer + * This eats the reply. + */ void -httpReplySwapOut(const HttpReply * rep, StoreEntry * e) +httpReplySwapOut(HttpReply * rep, StoreEntry * e) { - Packer p; assert(rep && e); - packerToStoreInit(&p, e); - httpReplyPackInto(rep, &p); - packerClean(&p); + storeEntryReplaceObject(e, rep); } MemBuf @@ -206,26 +213,50 @@ return mb; } -MemBuf -httpPacked304Reply(const HttpReply * rep) +HttpReply * +httpReplyMake304 (const HttpReply * rep) { static const http_hdr_type ImsEntries[] = - {HDR_DATE, HDR_CONTENT_TYPE, HDR_EXPIRES, HDR_LAST_MODIFIED, /* eof */ HDR_OTHER}; + {HDR_DATE, HDR_CONTENT_TYPE, HDR_EXPIRES, HDR_LAST_MODIFIED, /* eof */ HDR_OTHER}; + HttpReply *rv; int t; - MemBuf mb; - Packer p; HttpHeaderEntry *e; + http_version_t ver; assert(rep); - - memBufDefInit(&mb); - packerToMemInit(&p, &mb); - memBufPrintf(&mb, "%s", "HTTP/1.0 304 Not Modified\r\n"); + + rv = httpReplyCreate (); + /* rv->content_length; */ + rv->date = rep->date; + rv->last_modified = rep->last_modified; + rv->expires = rep->expires; + rv->content_type = stringDup (&rep->content_type); + /* rv->cache_control */ + /* rv->content_range */ + /* rv->keep_alive */ + httpBuildVersion(&ver, 1, 0); + httpStatusLineSet(&rv->sline, ver, + HTTP_NOT_MODIFIED, ""); + for (t = 0; ImsEntries[t] != HDR_OTHER; ++t) if ((e = httpHeaderFindEntry(&rep->header, ImsEntries[t]))) - httpHeaderEntryPackInto(e, &p); - memBufAppend(&mb, "\r\n", 2); - packerClean(&p); - return mb; + httpHeaderAddEntry(&rv->header, httpHeaderEntryClone(e)); + /* rv->body */ + return rv; +} + +MemBuf +httpPacked304Reply(const HttpReply * rep) +{ + /* Not as efficient as skipping the header duplication, + * but easier to maintain + */ + HttpReply *temp; + MemBuf rv; + assert (rep); + temp = httpReplyMake304 (rep); + rv = httpReplyPack(temp); + httpReplyDestroy (temp); + return rv; } void @@ -273,10 +304,48 @@ reply->content_length = 0; } +/* compare the validators of two replies. + * 1 = they match + * 0 = they do not match + */ +int +httpReplyValidatorsMatch(HttpReply const * rep, HttpReply const * otherRep) { + String one,two; + assert (rep && otherRep); + /* Numbers first - easiest to check */ + /* Content-Length */ + /* TODO: remove -1 bypass */ + if (rep->content_length != otherRep->content_length + && rep->content_length > -1 && + otherRep->content_length > -1) + return 0; + /* ETag */ + one = httpHeaderGetStrOrList(&rep->header, HDR_ETAG); + two = httpHeaderGetStrOrList(&otherRep->header, HDR_ETAG); + if (strcasecmp (strBuf(one), strBuf(two))) { + stringClean (&one); + stringClean (&two); + return 0; + } + if (rep->last_modified != otherRep->last_modified) + return 0; + /* MD5 */ + one = httpHeaderGetStrOrList(&rep->header, HDR_CONTENT_MD5); + two = httpHeaderGetStrOrList(&otherRep->header, HDR_CONTENT_MD5); + if (strcasecmp (strBuf(one), strBuf(two))) { + stringClean (&one); + stringClean (&two); + return 0; + } + return 1; +} + void -httpReplyUpdateOnNotModified(HttpReply * rep, HttpReply * freshRep) +httpReplyUpdateOnNotModified(HttpReply * rep, HttpReply const * freshRep) { assert(rep && freshRep); + /* Can not update modified headers that don't match! */ + assert (httpReplyValidatorsMatch(rep, freshRep)); /* clean cache */ httpReplyHdrCacheClean(rep); /* update raw headers */ @@ -450,7 +519,7 @@ * Returns the body size of a HTTP response */ int -httpReplyBodySize(method_t method, HttpReply * reply) +httpReplyBodySize(method_t method, HttpReply const * reply) { if (METHOD_HEAD == method) return 0; --- /dev/null Wed Feb 14 01:05:20 2007 +++ squid/src/HttpReply.h Wed Feb 14 01:07:12 2007 @@ -0,0 +1,79 @@ + +/* + * $Id: HttpReply.h,v 1.1.4.1 2002/10/02 12:32:13 rbcollins Exp $ + * + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#ifndef SQUID_HTTPREPLY_H +#define SQUID_HTTPREPLY_H + +#include "typedefs.h" + +/* Http Reply */ +extern void httpReplyInitModule(void); +/* create/destroy */ +extern HttpReply *httpReplyCreate(void); +extern void httpReplyDestroy(HttpReply * rep); +/* reset: clean, then init */ +extern void httpReplyReset(HttpReply * rep); +/* absorb: copy the contents of a new reply to the old one, destroy new one */ +extern void httpReplyAbsorb(HttpReply * rep, HttpReply * new_rep); +/* parse returns -1,0,+1 on error,need-more-data,success */ +extern int httpReplyParse(HttpReply * rep, const char *buf, ssize_t); +extern void httpReplyPackHeadersInto(const HttpReply * rep, Packer * p); +extern void httpReplyPackInto(const HttpReply * rep, Packer * p); +/* ez-routines */ +/* mem-pack: returns a ready to use mem buffer with a packed reply */ +extern MemBuf httpReplyPack(const HttpReply * rep); +/* swap: create swap-based packer, pack, destroy packer */ +extern void httpReplySwapOut(HttpReply * rep, StoreEntry * e); +/* set commonly used info with one call */ +extern void httpReplySetHeaders(HttpReply * rep, http_version_t ver, http_status status, + const char *reason, const char *ctype, int clen, time_t lmt, time_t expires); +/* do everything in one call: init, set, pack, clean, return MemBuf */ +extern MemBuf httpPackedReply(http_version_t ver, http_status status, const char *ctype, + int clen, time_t lmt, time_t expires); +/* construct 304 reply and pack it into MemBuf, return MemBuf */ +extern MemBuf httpPacked304Reply(const HttpReply * rep); +/* construct a 304 reply and return it */ +extern HttpReply *httpReplyMake304(const HttpReply *rep); +/* update when 304 reply is received for a cached object */ +extern void httpReplyUpdateOnNotModified(HttpReply * rep, HttpReply const * freshRep); +/* header manipulation */ +extern int httpReplyContentLen(const HttpReply * rep); +extern const char *httpReplyContentType(const HttpReply * rep); +extern time_t httpReplyExpires(const HttpReply * rep); +extern int httpReplyHasCc(const HttpReply * rep, http_hdr_cc_type type); +extern void httpRedirectReply(HttpReply *, http_status, const char *); +extern int httpReplyBodySize(method_t, HttpReply const *); +extern void httpReplyBodyBuildSize(request_t *, HttpReply *, dlink_list *); +extern int httpReplyValidatorsMatch (HttpReply const *, HttpReply const *); + +#endif /* SQUID_HTTPREPLY_H */ Index: squid/src/HttpRequest.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/HttpRequest.c,v retrieving revision 1.7 retrieving revision 1.7.60.1 diff -u -r1.7 -r1.7.60.1 --- squid/src/HttpRequest.c 14 Apr 2001 00:31:01 -0000 1.7 +++ squid/src/HttpRequest.c 2 Oct 2002 12:32:13 -0000 1.7.60.1 @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.c,v 1.7 2001/04/14 00:31:01 squidadm Exp $ + * $Id: HttpRequest.c,v 1.7.60.1 2002/10/02 12:32:13 rbcollins Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -33,8 +33,11 @@ * */ +#include "HttpRequest.h" #include "squid.h" +static void httpRequestHdrCacheInit(request_t * req); + request_t * requestCreate(method_t method, protocol_t protocol, const char *urlpath) { @@ -48,6 +51,7 @@ req->client_addr = no_addr; req->my_addr = no_addr; httpHeaderInit(&req->header, hoRequest); + httpRequestHdrCacheInit(req); return req; } @@ -93,9 +97,13 @@ httpRequestParseHeader(request_t * req, const char *parse_start) { const char *blk_start, *blk_end; + int rv; if (!httpMsgIsolateHeaders(&parse_start, &blk_start, &blk_end)) return 0; - return httpHeaderParse(&req->header, blk_start, blk_end); + rv = httpHeaderParse(&req->header, blk_start, blk_end); + if (rv) + httpRequestHdrCacheInit (req); + return rv; } /* swaps out request using httpRequestPack */ @@ -158,3 +166,31 @@ return 0; return 1; } + +/* sync this routine when you update request_t struct */ +static void +httpRequestHdrCacheInit(request_t * req) +{ + const HttpHeader *hdr = &req->header; +/* const char *str; */ + req->content_length = httpHeaderGetInt(hdr, HDR_CONTENT_LENGTH); + /* TODO: canonicalise these into an HttpEntity */ +#if 0 + req->date = httpHeaderGetTime(hdr, HDR_DATE); + req->last_modified = httpHeaderGetTime(hdr, HDR_LAST_MODIFIED); + str = httpHeaderGetStr(hdr, HDR_CONTENT_TYPE); + if (str) + stringLimitInit(&req->content_type, str, strcspn(str, ";\t ")); + else + req->content_type = StringNull; +#endif + req->cache_control = httpHeaderGetCc(hdr); + req->range = httpHeaderGetRange(hdr); +#if 0 + req->keep_alive = httpMsgIsPersistent(req->http_ver, &req->header); + + /* be sure to set expires after date and cache-control */ + req->expires = httpReplyHdrExpirationTime(req); +#endif +} + --- /dev/null Wed Feb 14 01:05:20 2007 +++ squid/src/HttpRequest.h Wed Feb 14 01:07:12 2007 @@ -0,0 +1,51 @@ + +/* + * $Id: HttpRequest.h,v 1.1.4.1 2002/10/02 12:32:13 rbcollins Exp $ + * + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#ifndef SQUID_HTTPREQUEST_H +#define SQUID_HTTPREQUEST_H + +#include "typedefs.h" + +/* Http Request */ +extern request_t *requestCreate(method_t, protocol_t, const char *urlpath); +extern void requestDestroy(request_t *); +extern request_t *requestLink(request_t *); +extern void requestUnlink(request_t *); +extern int httpRequestParseHeader(request_t * req, const char *parse_start); +extern void httpRequestSwapOut(const request_t * req, StoreEntry * e); +extern void httpRequestPack(const request_t * req, Packer * p); +extern int httpRequestPrefixLen(const request_t * req); +extern int httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConnection); +extern int httpRequestHdrAllowedByName(http_hdr_type id); + +#endif /* SQUID_HTTPREQUEST_H */ Index: squid/src/acl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/acl.c,v retrieving revision 1.58 retrieving revision 1.58.2.1 diff -u -r1.58 -r1.58.2.1 --- squid/src/acl.c 15 Sep 2002 11:06:29 -0000 1.58 +++ squid/src/acl.c 2 Oct 2002 12:32:13 -0000 1.58.2.1 @@ -1,6 +1,6 @@ /* - * $Id: acl.c,v 1.58 2002/09/15 11:06:29 rbcollins Exp $ + * $Id: acl.c,v 1.58.2.1 2002/10/02 12:32:13 rbcollins Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -35,6 +35,7 @@ #include "squid.h" #include "splay.h" +#include "HttpRequest.h" static void aclParseDomainList(void *curlist); static void aclParseUserList(void **current); Index: squid/src/asn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/asn.c,v retrieving revision 1.17.14.6 retrieving revision 1.17.14.7 diff -u -r1.17.14.6 -r1.17.14.7 --- squid/src/asn.c 19 Sep 2002 21:55:42 -0000 1.17.14.6 +++ squid/src/asn.c 2 Oct 2002 12:32:14 -0000 1.17.14.7 @@ -1,6 +1,6 @@ /* - * $Id: asn.c,v 1.17.14.6 2002/09/19 21:55:42 rbcollins Exp $ + * $Id: asn.c,v 1.17.14.7 2002/10/02 12:32:14 rbcollins Exp $ * * DEBUG: section 53 AS Number handling * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -35,6 +35,7 @@ #include "squid.h" #include "radix.h" +#include "HttpRequest.h" #include "StoreClient.h" #define WHOIS_PORT 43 @@ -239,6 +240,7 @@ asStateFree(asState); return; } + /* This checks for clean end of file AFAICT */ if (result.length == 0 && e->mem_obj->inmem_hi > 0) { asStateFree(asState); return; Index: squid/src/cache_manager.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/cache_manager.c,v retrieving revision 1.7 retrieving revision 1.7.66.1 diff -u -r1.7 -r1.7.66.1 --- squid/src/cache_manager.c 23 Feb 2001 21:03:30 -0000 1.7 +++ squid/src/cache_manager.c 2 Oct 2002 12:32:14 -0000 1.7.66.1 @@ -1,6 +1,6 @@ /* - * $Id: cache_manager.c,v 1.7 2001/02/23 21:03:30 hno Exp $ + * $Id: cache_manager.c,v 1.7.66.1 2002/10/02 12:32:14 rbcollins Exp $ * * DEBUG: section 16 Cache Manager Objects * AUTHOR: Duane Wessels @@ -34,6 +34,8 @@ */ #include "squid.h" +#include "HttpReply.h" +#include "HttpRequest.h" #define MGR_PASSWD_SZ 128 @@ -235,10 +237,8 @@ * password depends on action */ httpHeaderPutAuth(&rep->header, "Basic", mgr->action); - /* move info to the mem_obj->reply */ - httpReplyAbsorb(entry->mem_obj->reply, rep); /* store the reply */ - httpReplySwapOut(entry->mem_obj->reply, entry); + httpReplySwapOut(rep, entry); entry->expires = squid_curtime; storeComplete(entry); cachemgrStateFree(mgr); @@ -254,9 +254,7 @@ storeBuffer(entry); { http_version_t version; - HttpReply *rep = entry->mem_obj->reply; - /* prove there are no previous reply headers around */ - assert(0 == rep->sline.status); + HttpReply *rep = httpReplyCreate(); httpBuildVersion(&version, 1, 0); httpReplySetHeaders(rep, version, Index: squid/src/clientStream.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/clientStream.c,v retrieving revision 1.2.8.10 retrieving revision 1.2.8.11 diff -u -r1.2.8.10 -r1.2.8.11 --- squid/src/clientStream.c 17 Sep 2002 10:51:16 -0000 1.2.8.10 +++ squid/src/clientStream.c 2 Oct 2002 12:32:14 -0000 1.2.8.11 @@ -1,6 +1,6 @@ /* - * $Id: clientStream.c,v 1.2.8.10 2002/09/17 10:51:16 rbcollins Exp $ + * $Id: clientStream.c,v 1.2.8.11 2002/10/02 12:32:14 rbcollins Exp $ * * DEBUG: section 87 Client-side Stream routines. * AUTHOR: Robert Collins @@ -55,6 +55,8 @@ */ #include "squid.h" +#include "HttpReply.h" +#include "HttpRequest.h" #include "clientStream.h" CBDATA_TYPE(clientStreamNode); Index: squid/src/client_side.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/client_side.c,v retrieving revision 1.72.2.45 retrieving revision 1.72.2.46 diff -u -r1.72.2.45 -r1.72.2.46 --- squid/src/client_side.c 24 Sep 2002 10:44:57 -0000 1.72.2.45 +++ squid/src/client_side.c 2 Oct 2002 12:32:14 -0000 1.72.2.46 @@ -1,6 +1,6 @@ /* - * $Id: client_side.c,v 1.72.2.45 2002/09/24 10:44:57 rbcollins Exp $ + * $Id: client_side.c,v 1.72.2.46 2002/10/02 12:32:14 rbcollins Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -56,6 +56,8 @@ */ #include "squid.h" +#include "HttpReply.h" +#include "HttpRequest.h" #include "clientStream.h" #include "IPInterception.h" @@ -1376,14 +1378,13 @@ clientPullData(context); safe_free(prefix); break; - } else { - /* compile headers */ - /* we should skip request line! */ - if (!httpRequestParseHeader(request, prefix + req_line_sz)) - debug(33, 1) ("Failed to parse request headers: %s\n%s\n", - http->uri, prefix); - /* continue anyway? */ } + /* compile headers */ + /* we should skip request line! */ + if (!httpRequestParseHeader(request, prefix + req_line_sz)) + debug(33, 1) ("Failed to parse request headers: %s\n%s\n", + http->uri, prefix); + /* continue anyway? */ request->flags.accelerated = http->flags.accel; if (!http->flags.internal) { if (internalCheck(strBuf(request->urlpath))) { @@ -1398,11 +1399,6 @@ } } } - /* - * cache the Content-length value in request_t. - */ - request->content_length = httpHeaderGetInt(&request->header, - HDR_CONTENT_LENGTH); request->flags.internal = http->flags.internal; safe_free(prefix); safe_free(http->log_uri); @@ -2017,14 +2013,14 @@ } else { if (!vary) { vary = httpMakeVaryMark(request, entry->mem_obj->reply); - if (vary) + if (vary) request->vary_headers = xstrdup(vary); + else + /* Ouch.. we cannot handle this kind of variance */ + /* XXX This cannot really happen, but just to be complete */ + return VARY_CANCEL; } - if (!vary) { - /* Ouch.. we cannot handle this kind of variance */ - /* XXX This cannot really happen, but just to be complete */ - return VARY_CANCEL; - } else if (strcmp(vary, entry->mem_obj->vary_headers) == 0) { + if (strcmp(vary, entry->mem_obj->vary_headers) == 0) { return VARY_MATCH; } else { /* Oops.. we have already been here and still haven't Index: squid/src/client_side_reply.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/client_side_reply.c,v retrieving revision 1.4.6.25 retrieving revision 1.4.6.26 diff -u -r1.4.6.25 -r1.4.6.26 --- squid/src/client_side_reply.c 24 Sep 2002 11:13:25 -0000 1.4.6.25 +++ squid/src/client_side_reply.c 2 Oct 2002 12:32:14 -0000 1.4.6.26 @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.c,v 1.4.6.25 2002/09/24 11:13:25 rbcollins Exp $ + * $Id: client_side_reply.c,v 1.4.6.26 2002/10/02 12:32:14 rbcollins Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -34,6 +34,8 @@ */ #include "squid.h" +#include "HttpReply.h" +#include "HttpRequest.h" #include "StoreClient.h" #include "clientStream.h" @@ -62,7 +64,7 @@ /* Local functions */ static int clientGotNotEnough(clientHttpRequest const *); -static int clientReplyBodyTooLarge(HttpReply *, ssize_t); +static int clientReplyBodyTooLarge(HttpReply const *, ssize_t); static int clientOnlyIfCached(clientHttpRequest * http); static void clientProcessExpired(clientReplyContext *); static void clientProcessMiss(clientReplyContext *); @@ -326,6 +328,18 @@ debug(88, 5) ("clientGetsOldEntry: NO, reply=%d\n", status); return 0; } + /* If key metadata in the reply are not consistent with the + * old entry, we must use the new reply + */ + /* This is a duplicate call through the HandleIMS code path. + * Can we guarantee we don't need it elsewhere? + */ + if (!httpReplyValidatorsMatch(new_entry->mem_obj->reply, + old_entry->mem_obj->reply)) { + debug(88, 5) ("clientGetsOldEntry: NO, Old object has invalidated" + "by the new one\n"); + return 0; + } /* If the client did not send IMS in the request, then it * must get the old object, not this "Not Modified" reply */ if (!request->flags.ims) { @@ -421,7 +435,7 @@ * 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. */ - httpReplyUpdateOnNotModified(oldentry->mem_obj->reply, mem->reply); + httpReplyUpdateOnNotModified((HttpReply *)oldentry->mem_obj->reply, mem->reply); storeTimestampsSet(oldentry); clientRemoveStoreReference(context, &context->sc, &entry); oldentry->timestamp = squid_curtime; @@ -438,14 +452,14 @@ tempresult.data = next->readBuffer.data; clientSendMoreData(context, tempresult); return; - } - debug(88, 3) ("clientHandleIMSReply: Sending client the IMS reply for '%s'\n", url); - { - /* the client can handle this reply, whatever it is */ + } else { + if (1 || httpReplyValidatorsMatch (entry->mem_obj->reply, + http->old_entry->mem_obj->reply)) { + /* the client needs to get this reply */ StoreIOBuffer tempresult = EMPTYIOBUFFER; http->logType = LOG_TCP_REFRESH_MISS; if (HTTP_NOT_MODIFIED == mem->reply->sline.status) { - httpReplyUpdateOnNotModified(http->old_entry->mem_obj->reply, + httpReplyUpdateOnNotModified((HttpReply *)http->old_entry->mem_obj->reply, mem->reply); storeTimestampsSet(http->old_entry); http->logType = LOG_TCP_REFRESH_HIT; @@ -462,7 +476,17 @@ tempresult.length = context->reqsize; tempresult.data = context->tempbuf; clientSendMoreData(context, tempresult); - return; + } else { + /* TODO: invalidate the old entry, and start over */ + assert (0); + /* We start over for everything except IMS because: + * 1) HEAD requests will go straight through now + * 2) GET requests will go straight through now + * 3) IMS requests are a corner case. If the server + * decided to give us different data, we should give + * that to the client, which means returning our IMS request. + */ + } } } @@ -568,15 +592,6 @@ if (storeCheckNegativeHit(e)) { http->logType = LOG_TCP_NEGATIVE_HIT; clientSendMoreData(context, result); - } else if (r->method == METHOD_HEAD) { - /* - * RFC 2068 seems to indicate there is no "conditional HEAD" - * request. We cannot validate a cached object for a HEAD - * request, nor can we return 304. - */ - if (e->mem_status == IN_MEMORY) - http->logType = LOG_TCP_MEM_HIT; - clientSendMoreData(context, result); } else if (refreshCheckHTTP(e, r) && !http->flags.internal) { debug(88, 5) ("clientCacheHit: in refreshCheck() block\n"); /* @@ -633,7 +648,7 @@ clientSendMoreData(context, result); } else { time_t timestamp = e->timestamp; - MemBuf mb = httpPacked304Reply(e->mem_obj->reply); + HttpReply *temprep = httpReplyMake304 (e->mem_obj->reply); http->logType = LOG_TCP_IMS_HIT; clientRemoveStoreReference(context, &context->sc, &http->entry); http->entry = e = @@ -644,9 +659,7 @@ * reply has a meaningful Age: header. */ e->timestamp = timestamp; - httpReplyParse(e->mem_obj->reply, mb.buf, mb.size); - storeAppend(e, mb.buf, mb.size); - memBufClean(&mb); + httpReplySwapOut (temprep, e); storeComplete(e); /* TODO: why put this in the store and then serialise it and then parse it again. * Simply mark the request complete in our context and @@ -725,7 +738,6 @@ httpRedirectReply(rep, http->redirect.status, http->redirect.location); httpReplySwapOut(rep, http->entry); - httpReplyDestroy(rep); storeComplete(http->entry); return; } @@ -844,11 +856,14 @@ * Make a new entry to hold the reply to be written * to the client. */ + /* FIXME: This doesn't need to go through the store. Simply + * push down the client chain + */ http->entry = clientCreateStoreEntry(context, http->request->method, null_request_flags); triggerStoreReadWithClientParameters(context, http); - httpReplyReset(r = http->entry->mem_obj->reply); + r = httpReplyCreate(); httpBuildVersion(&version, 1, 0); httpReplySetHeaders(r, version, status, NULL, NULL, 0, 0, -1); httpReplySwapOut(r, http->entry); @@ -878,7 +893,6 @@ httpReplySetHeaders(rep, version, HTTP_OK, NULL, "text/plain", httpRequestPrefixLen(context->http->request), 0, squid_curtime); httpReplySwapOut(rep, context->http->entry); - httpReplyDestroy(rep); httpRequestSwapOut(context->http->request, context->http->entry); storeComplete(context->http->entry); } @@ -891,7 +905,7 @@ int sending = SENDING_BODY; StoreEntry *entry = http->entry; MemObject *mem; - http_reply *reply; + http_reply const *reply; int sendlen; if (entry == NULL) return 0; @@ -1152,9 +1166,25 @@ (void) 0; else if (http->entry->timestamp < 0) (void) 0; - else if (http->entry->timestamp < squid_curtime) + else if (http->entry->timestamp < squid_curtime) { httpHeaderPutInt(hdr, HDR_AGE, squid_curtime - http->entry->timestamp); + /* Signal old objects. NB: rfc 2616 is not clear, + * by implication, on whether we should do this to all + * responses, or only cache hits. + * 14.46 states it ONLY applys for heuristically caclulated + * freshness values, 13.2.4 doesn't specify the same limitation. + * We interpret RFC 2616 under the combination. + */ + /* TODO: if maxage or s-maxage is present, don't do this */ + if (squid_curtime - http->entry->timestamp >= 86400) { + char tempbuf[512]; + snprintf (tempbuf, sizeof(tempbuf), "%s %s %s", + "113", ThisCache, + "This cache hit is still fresh and more than 1 day old"); + httpHeaderPutStr(hdr, HDR_WARNING, tempbuf); + } + } } /* Handle authentication headers */ if (request->auth_user_request) @@ -1577,7 +1607,7 @@ } int -clientReplyBodyTooLarge(HttpReply * rep, ssize_t clen) +clientReplyBodyTooLarge(HttpReply const * rep, ssize_t clen) { if (0 == rep->maxBodySize) return 0; /* disabled */ Index: squid/src/client_side_request.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/client_side_request.c,v retrieving revision 1.3.6.10 retrieving revision 1.3.6.11 diff -u -r1.3.6.10 -r1.3.6.11 --- squid/src/client_side_request.c 24 Sep 2002 11:13:25 -0000 1.3.6.10 +++ squid/src/client_side_request.c 2 Oct 2002 12:32:15 -0000 1.3.6.11 @@ -1,10 +1,10 @@ /* - * $Id: client_side_request.c,v 1.3.6.10 2002/09/24 11:13:25 rbcollins Exp $ - * - * DEBUG: section 85 Client-side Request Routines AUTHOR: Robert Collins - * (Originally Duane Wessels in client_side.c) - * + * $Id: client_side_request.c,v 1.3.6.11 2002/10/02 12:32:15 rbcollins Exp $ + * + * DEBUG: section 85 Client-side Request Routines + * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) + * * SQUID Web Proxy Cache http://www.squid-cache.org/ * ---------------------------------------------------------- * @@ -42,6 +42,7 @@ */ #include "squid.h" +#include "HttpRequest.h" #include "clientStream.h" #include "client_side_request.h" Index: squid/src/errorpage.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/errorpage.c,v retrieving revision 1.23 retrieving revision 1.23.2.1 diff -u -r1.23 -r1.23.2.1 --- squid/src/errorpage.c 15 Sep 2002 11:06:32 -0000 1.23 +++ squid/src/errorpage.c 2 Oct 2002 12:32:15 -0000 1.23.2.1 @@ -1,6 +1,6 @@ /* - * $Id: errorpage.c,v 1.23 2002/09/15 11:06:32 rbcollins Exp $ + * $Id: errorpage.c,v 1.23.2.1 2002/10/02 12:32:15 rbcollins Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -41,7 +41,8 @@ */ #include "squid.h" - +#include "HttpReply.h" +#include "HttpRequest.h" /* local types */ @@ -318,7 +319,6 @@ */ authenticateFixHeader(rep, err->auth_user_request, err->request, 0, 1); httpReplySwapOut(rep, entry); - httpReplyAbsorb(mem->reply, rep); EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT); storeBufferFlush(entry); storeComplete(entry); Index: squid/src/forward.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/forward.c,v retrieving revision 1.17 retrieving revision 1.17.2.1 diff -u -r1.17 -r1.17.2.1 --- squid/src/forward.c 15 Sep 2002 11:06:32 -0000 1.17 +++ squid/src/forward.c 2 Oct 2002 12:32:15 -0000 1.17.2.1 @@ -1,6 +1,6 @@ /* - * $Id: forward.c,v 1.17 2002/09/15 11:06:32 rbcollins Exp $ + * $Id: forward.c,v 1.17.2.1 2002/10/02 12:32:15 rbcollins Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -35,6 +35,7 @@ #include "squid.h" +#include "HttpRequest.h" static PSC fwdStartComplete; static void fwdDispatch(FwdState *); @@ -339,6 +340,7 @@ ctimeout = fs->_peer->connect_timeout > 0 ? fs->_peer->connect_timeout : Config.Timeout.peer_connect; } else if (fwdState->request->flags.accelerated && + !fwdState->request->flags.internalclient && Config.Accel.single_host && Config.Accel.host) { host = Config.Accel.host; port = Config.Accel.port; Index: squid/src/ftp.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ftp.c,v retrieving revision 1.28 retrieving revision 1.28.2.1 diff -u -r1.28 -r1.28.2.1 --- squid/src/ftp.c 15 Sep 2002 11:06:32 -0000 1.28 +++ squid/src/ftp.c 2 Oct 2002 12:32:15 -0000 1.28.2.1 @@ -1,6 +1,6 @@ /* - * $Id: ftp.c,v 1.28 2002/09/15 11:06:32 rbcollins Exp $ + * $Id: ftp.c,v 1.28.2.1 2002/10/02 12:32:15 rbcollins Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -34,6 +34,8 @@ */ #include "squid.h" +#include "HttpRequest.h" +#include "HttpReply.h" static const char *const crlf = "\r\n"; static char cbuf[1024]; @@ -1087,7 +1089,7 @@ ftpState->user, request->port); } /* create reply */ - reply = entry->mem_obj->reply; + reply = httpReplyCreate (); assert(reply != NULL); /* create appropriate reply */ ftpAuthRequired(reply, request, realm); @@ -2504,7 +2506,7 @@ const char *filename = NULL; const char *t = NULL; StoreEntry *e = ftpState->entry; - http_reply *reply = e->mem_obj->reply; + http_reply *reply; http_version_t version; if (ftpState->flags.http_header_sent) @@ -2531,7 +2533,7 @@ } } storeBuffer(e); - httpReplyReset(reply); + reply = httpReplyCreate(); /* set standard stuff */ if (ftpState->restarted_offset) { /* Partial reply */ @@ -2553,7 +2555,9 @@ httpHeaderPutStr(&reply->header, HDR_CONTENT_ENCODING, mime_enc); httpReplySwapOut(reply, e); storeBufferFlush(e); +#if BROKENCODE reply->hdr_sz = e->mem_obj->inmem_hi; +#endif storeTimestampsSet(e); if (ftpState->flags.authenticated) { /* Index: squid/src/gopher.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/gopher.c,v retrieving revision 1.18.2.1 retrieving revision 1.18.2.2 diff -u -r1.18.2.1 -r1.18.2.2 --- squid/src/gopher.c 16 Sep 2002 23:21:00 -0000 1.18.2.1 +++ squid/src/gopher.c 2 Oct 2002 12:32:15 -0000 1.18.2.2 @@ -1,6 +1,6 @@ /* - * $Id: gopher.c,v 1.18.2.1 2002/09/16 23:21:00 rbcollins Exp $ + * $Id: gopher.c,v 1.18.2.2 2002/10/02 12:32:15 rbcollins Exp $ * * DEBUG: section 10 Gopher * AUTHOR: Harvest Derived @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "HttpRequest.h" /* gopher type code from rfc. Anawat. */ #define GOPHER_FILE '0' Index: squid/src/http.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/http.c,v retrieving revision 1.24.2.6 retrieving revision 1.24.2.7 diff -u -r1.24.2.6 -r1.24.2.7 --- squid/src/http.c 24 Sep 2002 10:43:06 -0000 1.24.2.6 +++ squid/src/http.c 2 Oct 2002 12:32:15 -0000 1.24.2.7 @@ -1,6 +1,6 @@ /* - * $Id: http.c,v 1.24.2.6 2002/09/24 10:43:06 rbcollins Exp $ + * $Id: http.c,v 1.24.2.7 2002/10/02 12:32:15 rbcollins Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -41,6 +41,8 @@ #include "squid.h" #include "http.h" #include "store.h" +#include "HttpReply.h" +#include "HttpRequest.h" static const char *const crlf = "\r\n"; @@ -240,8 +242,8 @@ static int httpCachableReply(HttpStateData * httpState) { - HttpReply *rep = httpState->entry->mem_obj->reply; - HttpHeader *hdr = &rep->header; + HttpReply const *rep = httpState->entry->mem_obj->reply; + HttpHeader const *hdr = &rep->header; const int cc_mask = (rep->cache_control) ? rep->cache_control->mask : 0; const char *v; if (!cacheControlAllowsCaching(rep->cache_control)); @@ -331,7 +333,9 @@ case HTTP_UNAUTHORIZED: case HTTP_PROXY_AUTHENTICATION_REQUIRED: case HTTP_INVALID_HEADER: /* Squid header parsing error */ + return 0; default: /* Unknown status code */ + debug (11,0)("httpCachableReply: unknown http status code in reply\n"); return 0; /* NOTREACHED */ break; @@ -345,7 +349,7 @@ * Returns false if the variance cannot be stored */ const char * -httpMakeVaryMark(request_t * request, HttpReply * reply) +httpMakeVaryMark(request_t * request, HttpReply const * reply) { String vary, hdr; const char *pos = NULL; @@ -406,7 +410,9 @@ StoreEntry *entry = httpState->entry; int room; size_t hdr_len; - HttpReply *reply = entry->mem_obj->reply; + /* Creates a blank header. If this routine is made incremental, this will + * not do */ + HttpReply *reply = httpReplyCreate(); Ctx ctx; debug(11, 3) ("httpProcessReplyHeader: key '%s'\n", storeKeyText(entry->hash.key)); @@ -423,6 +429,7 @@ debug(11, 3) ("httpProcessReplyHeader: Non-HTTP-compliant header: '%s'\n", httpState->reply_hdr); httpState->reply_hdr_state += 2; reply->sline.status = HTTP_INVALID_HEADER; + storeEntryReplaceObject (entry, reply); return; } t = httpState->reply_hdr + hdr_len; @@ -443,23 +450,35 @@ /* Parse headers into reply structure */ /* what happens if we fail to parse here? */ httpReplyParse(reply, httpState->reply_hdr, hdr_len); - if (reply->content_range) + /* TODO: we need our own reply * in the httpState, as we probably don't want to replace + * the storeEntry with interim headers + */ + + /* TODO: IF the reply is a 1.0 reply, AND it has a Connection: Header + * Parse the header and remove all referenced headers + */ + + storeEntryReplaceObject(entry, reply); + /* DO NOT USE reply now */ + reply = NULL; + + if (entry->mem_obj->reply->content_range) { - httpState->currentOffset = reply->content_range->spec.offset; + httpState->currentOffset = entry->mem_obj->reply->content_range->spec.offset; } storeTimestampsSet(entry); /* Check if object is cacheable or not based on reply code */ - debug(11, 3) ("httpProcessReplyHeader: HTTP CODE: %d\n", reply->sline.status); + debug(11, 3) ("httpProcessReplyHeader: HTTP CODE: %d\n", entry->mem_obj->reply->sline.status); if (neighbors_do_private_keys) - httpMaybeRemovePublic(entry, reply->sline.status); + httpMaybeRemovePublic(entry, entry->mem_obj->reply->sline.status); switch (httpCachableReply(httpState)) { case 1: - if (httpHeaderHas(&reply->header, HDR_VARY) + if (httpHeaderHas(&entry->mem_obj->reply->header, HDR_VARY) #if X_ACCELERATOR_VARY - || httpHeaderHas(&reply->header, HDR_X_ACCELERATOR_VARY) + || httpHeaderHas(&entry->mem_obj->reply->header, HDR_X_ACCELERATOR_VARY) #endif ) { - const char *vary = httpMakeVaryMark(httpState->orig_request, reply); + const char *vary = httpMakeVaryMark(httpState->orig_request, entry->mem_obj->reply); if (vary) { entry->mem_obj->vary_headers = xstrdup(vary); /* Kill the old base object if a change in variance is detected */ @@ -481,44 +500,52 @@ assert(0); break; } - if (reply->cache_control) { - if (EBIT_TEST(reply->cache_control->mask, CC_PROXY_REVALIDATE)) + if (entry->mem_obj->reply->cache_control) { + if (EBIT_TEST(entry->mem_obj->reply->cache_control->mask, CC_PROXY_REVALIDATE)) EBIT_SET(entry->flags, ENTRY_REVALIDATE); - else if (EBIT_TEST(reply->cache_control->mask, CC_MUST_REVALIDATE)) + else if (EBIT_TEST(entry->mem_obj->reply->cache_control->mask, CC_MUST_REVALIDATE)) EBIT_SET(entry->flags, ENTRY_REVALIDATE); } if (httpState->flags.keepalive) if (httpState->_peer) httpState->_peer->stats.n_keepalives_sent++; - if (reply->keep_alive) + if (entry->mem_obj->reply->keep_alive) if (httpState->_peer) httpState->_peer->stats.n_keepalives_recv++; - if (reply->date > -1 && !httpState->_peer) { - int skew = abs(reply->date - squid_curtime); + if (entry->mem_obj->reply->date > -1 && !httpState->_peer) { + int skew = abs(entry->mem_obj->reply->date - squid_curtime); if (skew > 86400) debug(11, 3) ("%s's clock is skewed by %d seconds!\n", httpState->request->host, skew); } ctx_exit(ctx); #if HEADERS_LOG - headersLog(1, 0, httpState->request->method, reply); + headersLog(1, 0, httpState->request->method, entry->mem_obj->reply); #endif } +/* 0 - non persistent or not complete + * 1 - finished persistent + * 2 - finished non-persistent + */ + static int httpPconnTransferDone(HttpStateData * httpState) { - /* return 1 if we got the last of the data on a persistent connection */ MemObject *mem = httpState->entry->mem_obj; - HttpReply *reply = mem->reply; + HttpReply const *reply = mem->reply; int clen; + int rv = 1; debug(11, 3) ("httpPconnTransferDone: FD %d\n", httpState->fd); + /* If the reply wants to close the connection, it takes precedence */ + if (httpHeaderHasConnDir(&reply->header, "close")) + rv = 2; /* * If we didn't send a keep-alive request header, then this * can not be a persistent connection. */ if (!httpState->flags.keepalive) - return 0; + rv = 2; /* * What does the reply have to say about keep-alive? */ @@ -532,7 +559,7 @@ * the server times out the socket. */ if (!reply->keep_alive) - return 0; + rv = 2; debug(11, 5) ("httpPconnTransferDone: content_length=%d\n", reply->content_length); /* If we haven't seen the end of reply headers, we are not done */ @@ -541,7 +568,7 @@ clen = httpReplyBodySize(httpState->request->method, reply); /* If there is no message body, we can be persistent */ if (0 == clen) - return 1; + return rv; /* If the body size is unknown we must wait for EOF */ if (clen < 0) return 0; @@ -549,7 +576,7 @@ if (mem->inmem_hi < reply->content_length + reply->hdr_sz) return 0; /* We got it all */ - return 1; + return rv; } /* This will be called when data is ready to be read from fd. Read until @@ -664,11 +691,28 @@ EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT); } } - tempBuffer.data = buf; - tempBuffer.length = len; - tempBuffer.offset = httpState->currentOffset; - httpState->currentOffset += len; - storeWrite(entry, tempBuffer); + if (!httpState->flags.headers_pushed) + { + /* The first block needs us to skip the headers */ + /* TODO: make this cleaner. WE should push the headers, NOT the parser */ + size_t end = headersEnd (buf, len); + if (len > end) + { + tempBuffer.data = buf+end; + tempBuffer.length = len - end; + tempBuffer.offset = httpState->currentOffset; + storeWrite(entry, tempBuffer); + } + httpState->flags.headers_pushed = 1; + } + else + { + tempBuffer.data = buf; + tempBuffer.length = len; + tempBuffer.offset = httpState->currentOffset; + httpState->currentOffset += len; + storeWrite(entry, tempBuffer); + } if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { /* * the above storeAppend() call could ABORT this entry, @@ -676,7 +720,12 @@ * there's nothing for us to do. */ (void) 0; - } else if (httpPconnTransferDone(httpState)) { + } else switch (httpPconnTransferDone(httpState)) { + case 0: + /* Wait for EOF condition */ + commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + break; + case 1: /* yes we have to clear all these! */ commSetDefer(fd, NULL, NULL); commSetTimeout(fd, -1, NULL, NULL); @@ -690,9 +739,24 @@ fwdComplete(httpState->fwd); httpState->fd = -1; httpStateFree(fd, httpState); - } else { - /* Wait for EOF condition */ - commSetSelect(fd, COMM_SELECT_READ, httpReadReply, httpState, 0); + break; + case 2: + /* close the connection ourselves */ + /* yes - same as for a complete persistent conn here */ + commSetDefer(fd, NULL, NULL); + commSetTimeout(fd, -1, NULL, NULL); + commSetSelect(fd, COMM_SELECT_READ, NULL, NULL, 0); +#if DELAY_POOLS + delayClearNoDelay(fd); +#endif + comm_remove_close_handler(fd, httpStateFree, httpState); + fwdUnregister(fd, httpState->fwd); + fwdComplete(httpState->fwd); + httpState->fd = -1; + httpStateFree(fd, httpState); + /* TODO: check that fd is still open here */ + comm_close (fd); + break; } } } @@ -968,9 +1032,12 @@ http_state_flags flags) { const int offset = mb->size; - memBufPrintf(mb, "%s %s HTTP/1.0\r\n", + http_version_t httpver; + httpBuildVersion(&httpver, 1, 0); + memBufPrintf(mb, "%s %s HTTP/%d.%d\r\n", RequestMethodStr[request->method], - strLen(request->urlpath) ? strBuf(request->urlpath) : "/"); + strLen(request->urlpath) ? strBuf(request->urlpath) : "/", + httpver.major,httpver.minor); /* build and pack headers */ { HttpHeader hdr; Index: squid/src/icp_v2.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/icp_v2.c,v retrieving revision 1.6 retrieving revision 1.6.6.1 diff -u -r1.6 -r1.6.6.1 --- squid/src/icp_v2.c 9 Aug 2002 21:46:02 -0000 1.6 +++ squid/src/icp_v2.c 2 Oct 2002 12:32:15 -0000 1.6.6.1 @@ -1,6 +1,6 @@ /* - * $Id: icp_v2.c,v 1.6 2002/08/09 21:46:02 squidadm Exp $ + * $Id: icp_v2.c,v 1.6.6.1 2002/10/02 12:32:15 rbcollins Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "HttpRequest.h" static void icpLogIcp(struct in_addr, log_type, int, const char *, int); static void icpHandleIcpV2(int, struct sockaddr_in, char *, int); Index: squid/src/icp_v3.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/icp_v3.c,v retrieving revision 1.5 retrieving revision 1.5.6.1 diff -u -r1.5 -r1.5.6.1 --- squid/src/icp_v3.c 9 Aug 2002 21:46:02 -0000 1.5 +++ squid/src/icp_v3.c 2 Oct 2002 12:32:16 -0000 1.5.6.1 @@ -1,6 +1,6 @@ /* - * $Id: icp_v3.c,v 1.5 2002/08/09 21:46:02 squidadm Exp $ + * $Id: icp_v3.c,v 1.5.6.1 2002/10/02 12:32:16 rbcollins Exp $ * * DEBUG: section 12 Internet Cache Protocol * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "HttpRequest.h" /* Currently Harvest cached-2.x uses ICP_VERSION_3 */ void Index: squid/src/internal.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/internal.c,v retrieving revision 1.9 retrieving revision 1.9.14.1 diff -u -r1.9 -r1.9.14.1 --- squid/src/internal.c 11 Apr 2002 22:30:30 -0000 1.9 +++ squid/src/internal.c 2 Oct 2002 12:32:16 -0000 1.9.14.1 @@ -1,6 +1,6 @@ /* - * $Id: internal.c,v 1.9 2002/04/11 22:30:30 squidadm Exp $ + * $Id: internal.c,v 1.9.14.1 2002/10/02 12:32:16 rbcollins Exp $ * * DEBUG: section 76 Internal Squid Object handling * AUTHOR: Duane, Alex, Henrik @@ -34,6 +34,8 @@ */ #include "squid.h" +#include "HttpRequest.h" +#include "HttpReply.h" /* called when we "miss" on an internal object; * generate known dynamic objects, @@ -50,13 +52,15 @@ if (0 == strcmp(upath, "/squid-internal-dynamic/netdb")) { netdbBinaryExchange(entry); } else if (0 == strcmp(upath, "/squid-internal-periodic/store_digest")) { + HttpReply *reply; #if USE_CACHE_DIGESTS const char *msgbuf = "This cache is currently building its digest.\n"; #else const char *msgbuf = "This cache does not suport Cache Digests.\n"; #endif httpBuildVersion(&version, 1, 0); - httpReplySetHeaders(entry->mem_obj->reply, + reply = httpReplyCreate(); + httpReplySetHeaders(reply, version, HTTP_NOT_FOUND, "Not Found", @@ -64,7 +68,7 @@ strlen(msgbuf), squid_curtime, -2); - httpReplySwapOut(entry->mem_obj->reply, entry); + httpReplySwapOut(reply, entry); storeAppend(entry, msgbuf, strlen(msgbuf)); storeComplete(entry); } else { Index: squid/src/main.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/main.c,v retrieving revision 1.36 retrieving revision 1.36.6.1 diff -u -r1.36 -r1.36.6.1 --- squid/src/main.c 8 Aug 2002 19:41:58 -0000 1.36 +++ squid/src/main.c 2 Oct 2002 12:32:16 -0000 1.36.6.1 @@ -1,6 +1,6 @@ /* - * $Id: main.c,v 1.36 2002/08/08 19:41:58 squidadm Exp $ + * $Id: main.c,v 1.36.6.1 2002/10/02 12:32:16 rbcollins Exp $ * * DEBUG: section 1 Startup and Main Loop * AUTHOR: Harvest Derived @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "HttpReply.h" /* for error reporting from xmalloc and friends */ extern void (*failure_notify) (const char *); Index: squid/src/mem.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mem.c,v retrieving revision 1.21 retrieving revision 1.21.2.1 diff -u -r1.21 -r1.21.2.1 --- squid/src/mem.c 15 Sep 2002 11:06:33 -0000 1.21 +++ squid/src/mem.c 2 Oct 2002 12:32:16 -0000 1.21.2.1 @@ -1,6 +1,6 @@ /* - * $Id: mem.c,v 1.21 2002/09/15 11:06:33 rbcollins Exp $ + * $Id: mem.c,v 1.21.2.1 2002/10/02 12:32:16 rbcollins Exp $ * * DEBUG: section 13 High Level Memory Pool Management * AUTHOR: Harvest Derived @@ -36,6 +36,9 @@ #include "squid.h" #include "memMeter.h" +/* Non global types - we should distribute this somehow */ +#include "mem_node.h" + /* module globals */ /* local prototypes */ --- /dev/null Wed Feb 14 01:05:20 2007 +++ squid/src/mem_node.h Wed Feb 14 01:07:13 2007 @@ -0,0 +1,47 @@ + +/* + * $Id: mem_node.h,v 1.1.2.1 2002/10/02 12:32:16 rbcollins Exp $ + * + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#ifndef SQUID_MEM_NODE_H +#define SQUID_MEM_NODE_H + +#include "StoreIOBuffer.h" +struct _mem_node { + /* public */ + StoreIOBuffer nodeBuffer; + mem_node *next; + /* Private */ + char data[SM_PAGE_SIZE]; +}; + + +#endif /* SQUID_MEM_NODE_H */ Index: squid/src/mime.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/mime.c,v retrieving revision 1.12 retrieving revision 1.12.2.1 diff -u -r1.12 -r1.12.2.1 --- squid/src/mime.c 1 Sep 2002 16:30:42 -0000 1.12 +++ squid/src/mime.c 2 Oct 2002 12:32:16 -0000 1.12.2.1 @@ -1,6 +1,6 @@ /* - * $Id: mime.c,v 1.12 2002/09/01 16:30:42 squidadm Exp $ + * $Id: mime.c,v 1.12.2.1 2002/10/02 12:32:16 rbcollins Exp $ * * DEBUG: section 25 MIME Parsing * AUTHOR: Harvest Derived @@ -34,6 +34,8 @@ */ #include "squid.h" +#include "HttpReply.h" +#include "HttpRequest.h" #define GET_HDR_SZ 1024 @@ -430,7 +432,7 @@ storeSetPublicKey(e); storeBuffer(e); e->mem_obj->request = requestLink(urlParse(METHOD_GET, url)); - httpReplyReset(reply = e->mem_obj->reply); + reply = httpReplyCreate(); httpBuildVersion(&version, 1, 0); httpReplySetHeaders(reply, version, HTTP_OK, NULL, type, (int) sb.st_size, sb.st_mtime, -1); @@ -438,7 +440,6 @@ httpHdrCcSetMaxAge(reply->cache_control, 86400); httpHeaderPutCc(&reply->header, reply->cache_control); httpReplySwapOut(reply, e); - reply->hdr_sz = e->mem_obj->inmem_hi; /* yuk */ /* read the file into the buffer and append it to store */ buf = memAllocate(MEM_4K_BUF); while ((n = FD_READ_METHOD(fd, buf, 4096)) > 0) Index: squid/src/neighbors.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/neighbors.c,v retrieving revision 1.20 retrieving revision 1.20.2.1 diff -u -r1.20 -r1.20.2.1 --- squid/src/neighbors.c 15 Sep 2002 11:06:33 -0000 1.20 +++ squid/src/neighbors.c 2 Oct 2002 12:32:16 -0000 1.20.2.1 @@ -1,6 +1,6 @@ /* - * $Id: neighbors.c,v 1.20 2002/09/15 11:06:33 rbcollins Exp $ + * $Id: neighbors.c,v 1.20.2.1 2002/10/02 12:32:16 rbcollins Exp $ * * DEBUG: section 15 Neighbor Routines * AUTHOR: Harvest Derived @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "HttpRequest.h" /* count mcast group peers every 15 minutes */ #define MCAST_COUNT_RATE 900 Index: squid/src/net_db.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/net_db.c,v retrieving revision 1.15 retrieving revision 1.15.10.1 diff -u -r1.15 -r1.15.10.1 --- squid/src/net_db.c 26 Jun 2002 17:28:32 -0000 1.15 +++ squid/src/net_db.c 2 Oct 2002 12:32:16 -0000 1.15.10.1 @@ -1,6 +1,6 @@ /* - * $Id: net_db.c,v 1.15 2002/06/26 17:28:32 squidadm Exp $ + * $Id: net_db.c,v 1.15.10.1 2002/10/02 12:32:16 rbcollins Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -42,6 +42,7 @@ */ #include "squid.h" +#include "HttpReply.h" #if USE_ICMP #define NETDB_REQBUF_SZ 4096 @@ -986,7 +987,7 @@ void netdbBinaryExchange(StoreEntry * s) { - http_reply *reply = s->mem_obj->reply; + http_reply *reply = httpReplyCreate(); http_version_t version; #if USE_ICMP netdbEntry *n; @@ -996,7 +997,6 @@ char *buf; struct in_addr addr; storeBuffer(s); - httpReplyReset(reply); httpBuildVersion(&version, 1, 0); httpReplySetHeaders(reply, version, HTTP_OK, "OK", NULL, -1, squid_curtime, -2); @@ -1039,10 +1039,10 @@ storeBufferFlush(s); memFree(buf, MEM_4K_BUF); #else - httpReplyReset(reply); httpBuildVersion(&version, 1, 0); httpReplySetHeaders(reply, version, HTTP_BAD_REQUEST, "Bad Request", NULL, -1, squid_curtime, -2); + httpReplySwapOut(reply, s); storeAppendPrintf(s, "NETDB support not compiled into this Squid cache.\n"); #endif storeComplete(s); Index: squid/src/peer_select.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/peer_select.c,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -r1.16 -r1.16.2.1 --- squid/src/peer_select.c 15 Sep 2002 11:06:33 -0000 1.16 +++ squid/src/peer_select.c 2 Oct 2002 12:32:17 -0000 1.16.2.1 @@ -1,6 +1,6 @@ /* - * $Id: peer_select.c,v 1.16 2002/09/15 11:06:33 rbcollins Exp $ + * $Id: peer_select.c,v 1.16.2.1 2002/10/02 12:32:17 rbcollins Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "HttpRequest.h" const char *hier_strings[] = { Index: squid/src/protos.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/protos.h,v retrieving revision 1.61.2.8 retrieving revision 1.61.2.9 diff -u -r1.61.2.8 -r1.61.2.9 --- squid/src/protos.h 24 Sep 2002 10:43:37 -0000 1.61.2.8 +++ squid/src/protos.h 2 Oct 2002 12:32:17 -0000 1.61.2.9 @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.61.2.8 2002/09/24 10:43:37 rbcollins Exp $ + * $Id: protos.h,v 1.61.2.9 2002/10/02 12:32:17 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -317,7 +317,7 @@ extern int httpAnonHdrDenied(http_hdr_type hdr_id); extern void httpBuildRequestHeader(request_t *, request_t *, StoreEntry *, HttpHeader *, int, http_state_flags); extern void httpBuildVersion(http_version_t * version, unsigned int major, unsigned int minor); -extern const char *httpMakeVaryMark(request_t * request, HttpReply * reply); +extern const char *httpMakeVaryMark(request_t * request, HttpReply const * reply); /* ETag */ extern int etagParseInit(ETag * etag, const char *str); @@ -477,54 +477,6 @@ extern int httpMsgIsPersistent(http_version_t http_ver, const HttpHeader * hdr); extern int httpMsgIsolateHeaders(const char **parse_start, const char **blk_start, const char **blk_end); -/* Http Reply */ -extern void httpReplyInitModule(void); -/* create/destroy */ -extern HttpReply *httpReplyCreate(void); -extern void httpReplyDestroy(HttpReply * rep); -/* reset: clean, then init */ -extern void httpReplyReset(HttpReply * rep); -/* absorb: copy the contents of a new reply to the old one, destroy new one */ -extern void httpReplyAbsorb(HttpReply * rep, HttpReply * new_rep); -/* parse returns -1,0,+1 on error,need-more-data,success */ -extern int httpReplyParse(HttpReply * rep, const char *buf, ssize_t); -extern void httpReplyPackInto(const HttpReply * rep, Packer * p); -/* ez-routines */ -/* mem-pack: returns a ready to use mem buffer with a packed reply */ -extern MemBuf httpReplyPack(const HttpReply * rep); -/* swap: create swap-based packer, pack, destroy packer */ -extern void httpReplySwapOut(const HttpReply * rep, StoreEntry * e); -/* set commonly used info with one call */ -extern void httpReplySetHeaders(HttpReply * rep, http_version_t ver, http_status status, - const char *reason, const char *ctype, int clen, time_t lmt, time_t expires); -/* do everything in one call: init, set, pack, clean, return MemBuf */ -extern MemBuf httpPackedReply(http_version_t ver, http_status status, const char *ctype, - int clen, time_t lmt, time_t expires); -/* construct 304 reply and pack it into MemBuf, return MemBuf */ -extern MemBuf httpPacked304Reply(const HttpReply * rep); -/* update when 304 reply is received for a cached object */ -extern void httpReplyUpdateOnNotModified(HttpReply * rep, HttpReply * freshRep); -/* header manipulation */ -extern int httpReplyContentLen(const HttpReply * rep); -extern const char *httpReplyContentType(const HttpReply * rep); -extern time_t httpReplyExpires(const HttpReply * rep); -extern int httpReplyHasCc(const HttpReply * rep, http_hdr_cc_type type); -extern void httpRedirectReply(HttpReply *, http_status, const char *); -extern int httpReplyBodySize(method_t, HttpReply *); -extern void httpReplyBodyBuildSize(request_t *, HttpReply *, dlink_list *); - -/* Http Request */ -extern request_t *requestCreate(method_t, protocol_t, const char *urlpath); -extern void requestDestroy(request_t *); -extern request_t *requestLink(request_t *); -extern void requestUnlink(request_t *); -extern int httpRequestParseHeader(request_t * req, const char *parse_start); -extern void httpRequestSwapOut(const request_t * req, StoreEntry * e); -extern void httpRequestPack(const request_t * req, Packer * p); -extern int httpRequestPrefixLen(const request_t * req); -extern int httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConnection); -extern int httpRequestHdrAllowedByName(http_hdr_type id); - extern void icmpOpen(void); extern void icmpClose(void); extern void icmpPing(struct in_addr to); @@ -813,12 +765,10 @@ extern void pconnHistCount(int, int); extern int stat5minClientRequests(void); extern double stat5minCPUUsage(void); -extern const char *storeEntryFlags(const StoreEntry *); extern double statRequestHitRatio(int minutes); extern double statRequestHitMemoryRatio(int minutes); extern double statRequestHitDiskRatio(int minutes); extern double statByteHitRatio(int minutes); -extern int storeEntryLocked(const StoreEntry *); /* StatHist */ @@ -932,11 +882,14 @@ extern void storeSetPrivateKey(StoreEntry *); extern int objectLen(const StoreEntry * e); extern int contentLen(const StoreEntry * e); -extern HttpReply *storeEntryReply(StoreEntry *); +extern HttpReply const *storeEntryReply(StoreEntry *); extern int storeTooManyDiskFilesOpen(void); extern void storeEntryReset(StoreEntry *); extern void storeHeapPositionUpdate(StoreEntry *, SwapDir *); extern void storeSwapFileNumberSet(StoreEntry * e, sfileno filn); +extern int storeEntryLocked(const StoreEntry *); +extern const char *storeEntryFlags(const StoreEntry *); +extern void storeEntryReplaceObject(StoreEntry *, HttpReply *); extern void storeFsInit(void); extern void storeFsDone(void); extern void storeFsAdd(const char *, STSETUP *); Index: squid/src/refresh.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/refresh.c,v retrieving revision 1.8 retrieving revision 1.8.10.1 diff -u -r1.8 -r1.8.10.1 --- squid/src/refresh.c 16 Jun 2002 08:50:41 -0000 1.8 +++ squid/src/refresh.c 2 Oct 2002 12:32:17 -0000 1.8.10.1 @@ -1,6 +1,6 @@ /* - * $Id: refresh.c,v 1.8 2002/06/16 08:50:41 squidadm Exp $ + * $Id: refresh.c,v 1.8.10.1 2002/10/02 12:32:17 rbcollins Exp $ * * DEBUG: section 22 Refresh Calculation * AUTHOR: Harvest Derived @@ -269,6 +269,12 @@ if (R->flags.ignore_reload && cc->max_age == 0) { } else #endif +#if 0 + if (cc->max_age == 0) { + debug (22,3) ("refreshCheck: YES: client-max-age = 0\n"); + return STALE_EXCEEDS_REQUEST_MAX_AGE_VALUE; + } +#endif if (age > cc->max_age) { debug(22, 3) ("refreshCheck: YES: age > client-max-age\n"); return STALE_EXCEEDS_REQUEST_MAX_AGE_VALUE; Index: squid/src/ssl.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/ssl.c,v retrieving revision 1.16 retrieving revision 1.16.2.1 diff -u -r1.16 -r1.16.2.1 --- squid/src/ssl.c 15 Sep 2002 11:06:33 -0000 1.16 +++ squid/src/ssl.c 2 Oct 2002 12:32:18 -0000 1.16.2.1 @@ -1,6 +1,6 @@ /* - * $Id: ssl.c,v 1.16 2002/09/15 11:06:33 rbcollins Exp $ + * $Id: ssl.c,v 1.16.2.1 2002/10/02 12:32:18 rbcollins Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "HttpRequest.h" typedef struct { char *url; Index: squid/src/stmem.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/stmem.c,v retrieving revision 1.8.2.1 retrieving revision 1.8.2.2 diff -u -r1.8.2.1 -r1.8.2.2 --- squid/src/stmem.c 20 Sep 2002 08:16:31 -0000 1.8.2.1 +++ squid/src/stmem.c 2 Oct 2002 12:32:18 -0000 1.8.2.2 @@ -1,6 +1,6 @@ /* - * $Id: stmem.c,v 1.8.2.1 2002/09/20 08:16:31 rbcollins Exp $ + * $Id: stmem.c,v 1.8.2.2 2002/10/02 12:32:18 rbcollins Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Harvest Derived @@ -35,8 +35,26 @@ #include "squid.h" #include "stmem.h" +#include "mem_node.h" static void stmemInternalAppend (mem_hdr * mem, const char *data, int len); +/* static mem_node *stmemInternalGetBlockContainingStartOf (mem_hdr *mem, StoreIOBuffer aBuffer); */ + +int +lowestOffset (mem_hdr const *mem) +{ + if (mem->head) + return mem->head->nodeBuffer.offset; + return 0; +} + +off_t +endOffset (mem_hdr const *mem) +{ + if (mem->tail) + return mem->tail->nodeBuffer.offset + mem->tail->nodeBuffer.length; + return 0; +} void stmemFree(mem_hdr * mem) @@ -51,47 +69,37 @@ } } mem->head = mem->tail = NULL; - mem->origin_offset = 0; } int stmemFreeDataUpto(mem_hdr * mem, int target_offset) { - int current_offset = mem->origin_offset; mem_node *lastp; mem_node *p = mem->head; - while (p && ((current_offset + p->len) <= target_offset)) { + while (p && ((p->nodeBuffer.offset + p->nodeBuffer.length) <= target_offset)) { if (p == mem->tail) { /* keep the last one to avoid change to other part of code */ mem->head = mem->tail; - mem->origin_offset = current_offset; - return current_offset; + return p->nodeBuffer.offset; } else { lastp = p; + assert (lastp); p = p->next; - current_offset += lastp->len; - store_mem_size -= SM_PAGE_SIZE; - if (lastp) { - memFree(lastp, MEM_MEM_NODE); - lastp = NULL; - } + store_mem_size -= lastp->nodeBuffer.length; + memFree(lastp, MEM_MEM_NODE); + lastp = NULL; } } mem->head = p; - mem->origin_offset = current_offset; - if (current_offset < target_offset) { - /* there are still some data left. */ - return current_offset; - } - assert(current_offset == target_offset); - return current_offset; + assert (lowestOffset (mem) <= target_offset); + return lowestOffset (mem); } /* Append incoming data. */ void stmemAppend(mem_hdr * mem, const char *data, int len) { - debug (19,0) ("memAppend: This routine is deprecated. Please update the patch or working branch to use stmemWrite instead. stmem is still fully functional and you MAY ignore this warning\n"); + debug (19,0) ("memAppend: This routine is deprecated. Please update the patch or working branch to use stmemWrite instead. stmemAppend is still fully functional and you MAY ignore this warning\n"); stmemInternalAppend (mem, data, len); } @@ -104,20 +112,22 @@ /* Does the last block still contain empty space? * If so, fill out the block before dropping into the * allocation loop */ - if (mem->head && mem->tail && (mem->tail->len < SM_PAGE_SIZE)) { - avail_len = SM_PAGE_SIZE - (mem->tail->len); + if (mem->head && mem->tail && (mem->tail->nodeBuffer.length < SM_PAGE_SIZE)) { + avail_len = SM_PAGE_SIZE - (mem->tail->nodeBuffer.length); len_to_copy = XMIN(avail_len, len); - xmemcpy((mem->tail->data + mem->tail->len), data, len_to_copy); + xmemcpy((mem->tail->data + mem->tail->nodeBuffer.length), data, len_to_copy); /* Adjust the ptr and len according to what was deposited in the page */ data += len_to_copy; len -= len_to_copy; - mem->tail->len += len_to_copy; + mem->tail->nodeBuffer.length += len_to_copy; } while (len > 0) { len_to_copy = XMIN(len, SM_PAGE_SIZE); p = memAllocate(MEM_MEM_NODE); p->next = NULL; - p->len = len_to_copy; + p->nodeBuffer.length = len_to_copy; + p->nodeBuffer.data = p->data; + p->nodeBuffer.offset = endOffset (mem); store_mem_size += SM_PAGE_SIZE; xmemcpy(p->data, data, len_to_copy); if (!mem->head) { @@ -133,14 +143,34 @@ } } + +/* returns a mem_node that contains the start of aBuffer. + * If no node contains the start, it returns NULL. + */ +#if 0 +mem_node * +stmemInternalGetBlockContainingStartOf (mem_hdr *mem, StoreIOBuffer aBuffer) +{ +#if 0 + /* Trivial case */ + if (aBuffer.offset < mem->origin_offset) + return NULL; + if (aBuffer.offset > memGreatestOffset (mem) + +#endif + return NULL; +} +#endif + void stmemWrite(MemObject *m, StoreIOBuffer writeBuffer, STMCB *callback, void *callbackData) { mem_hdr *mem = &m->data_hdr; +// mem_node *tempNode; debug(19, 6) ("memWrite: offset %lu len %d\n", writeBuffer.offset, writeBuffer.length); /* TODO: support arbitrary location writes */ assert (writeBuffer.offset == m->inmem_hi); + assert (writeBuffer.offset == endOffset (mem)); /* Three main cases. * 1) prefix insert. NOT DONE. @@ -154,16 +184,23 @@ * until aBuffer.length == 0; * callback (data, writeBuffer); */ +/* tempNode = stmemInternalGetBlockContainingStartOf (mem, writeBuffer); + if (!tempNode) + stmemInternalCreateBlockAt (mem, writeBuffer.offset); */ stmemInternalAppend (mem, writeBuffer.data, writeBuffer.length); m->inmem_hi += writeBuffer.length; callback (callbackData, writeBuffer); } +/* FIXME: how do we deal with sparse results - + * where we have (say) + * 0-500 and 1000-1500, but are asked for + * 0-2000 + */ ssize_t stmemCopy(const mem_hdr * mem, off_t offset, char *buf, size_t size) { mem_node *p = mem->head; - off_t t_off = mem->origin_offset; size_t bytes_to_go = size; char *ptr_to_buf = NULL; int bytes_from_this_packet = 0; @@ -174,8 +211,7 @@ /* RC: the next assert is useless */ assert(size > 0); /* Seek our way into store */ - while ((t_off + p->len) < offset) { - t_off += p->len; + while ((p->nodeBuffer.offset + p->nodeBuffer.length) < offset) { if (!p->next) { debug(19, 1) ("memCopy: p->next == NULL\n"); return 0; @@ -185,17 +221,17 @@ } /* Start copying begining with this block until * we're satiated */ - bytes_into_this_packet = offset - t_off; - bytes_from_this_packet = XMIN(bytes_to_go, p->len - bytes_into_this_packet); + bytes_into_this_packet = offset - p->nodeBuffer.offset; + bytes_from_this_packet = XMIN(bytes_to_go, p->nodeBuffer.length - bytes_into_this_packet); xmemcpy(buf, p->data + bytes_into_this_packet, bytes_from_this_packet); bytes_to_go -= bytes_from_this_packet; ptr_to_buf = buf + bytes_from_this_packet; p = p->next; while (p && bytes_to_go > 0) { - if (bytes_to_go > p->len) { - xmemcpy(ptr_to_buf, p->data, p->len); - ptr_to_buf += p->len; - bytes_to_go -= p->len; + if (bytes_to_go > p->nodeBuffer.length) { + xmemcpy(ptr_to_buf, p->data, p->nodeBuffer.length); + ptr_to_buf += p->nodeBuffer.length; + bytes_to_go -= p->nodeBuffer.length; } else { xmemcpy(ptr_to_buf, p->data, bytes_to_go); bytes_to_go -= bytes_to_go; Index: squid/src/stmem.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/Attic/stmem.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -u -r1.1.2.1 -r1.1.2.2 --- squid/src/stmem.h 20 Sep 2002 08:16:31 -0000 1.1.2.1 +++ squid/src/stmem.h 2 Oct 2002 12:32:18 -0000 1.1.2.2 @@ -1,6 +1,6 @@ /* - * $Id: stmem.h,v 1.1.2.1 2002/09/20 08:16:31 rbcollins Exp $ + * $Id: stmem.h,v 1.1.2.2 2002/10/02 12:32:18 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -38,5 +38,7 @@ typedef void STMCB (void *data, StoreIOBuffer wroteBuffer); extern void stmemWrite(MemObject *, StoreIOBuffer, STMCB *, void *); +extern int lowestOffset (mem_hdr const *mem); +extern off_t endOffset (mem_hdr const *mem); #endif /* SQUID_STMEM_H */ Index: squid/src/store.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store.c,v retrieving revision 1.18.2.1 retrieving revision 1.18.2.2 diff -u -r1.18.2.1 -r1.18.2.2 --- squid/src/store.c 20 Sep 2002 08:16:31 -0000 1.18.2.1 +++ squid/src/store.c 2 Oct 2002 12:32:18 -0000 1.18.2.2 @@ -1,6 +1,6 @@ /* - * $Id: store.c,v 1.18.2.1 2002/09/20 08:16:31 rbcollins Exp $ + * $Id: store.c,v 1.18.2.2 2002/10/02 12:32:18 rbcollins Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -35,6 +35,9 @@ #include "squid.h" #include "stmem.h" +#include "HttpReply.h" +#include "HttpRequest.h" + static STMCB storeWriteComplete; #define REBUILD_TIMESTAMP_DELTA_MAX 2 @@ -162,7 +165,7 @@ * still have mem->clients set if mem->fd == -1 */ assert(mem->fd == -1 || mem->clients.head == NULL); - httpReplyDestroy(mem->reply); + httpReplyDestroy((HttpReply *)mem->reply); requestUnlink(mem->request); mem->request = NULL; ctx_exit(ctx); /* must exit before we free mem->url */ @@ -430,10 +433,12 @@ String vary; pe = storeCreateEntry(mem->url, mem->log_url, request->flags, request->method); httpBuildVersion(&version, 1, 0); - httpReplySetHeaders(pe->mem_obj->reply, version, HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000); + /* We are allowed to do this typecast */ + httpReplySetHeaders((HttpReply *)pe->mem_obj->reply, version, HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000); vary = httpHeaderGetList(&mem->reply->header, HDR_VARY); - if (strBuf(vary)) { - httpHeaderPutStr(&pe->mem_obj->reply->header, HDR_VARY, strBuf(vary)); + if (strLen(vary)) { + /* Again, we own this structure layout */ + httpHeaderPutStr((HttpHeader *)&pe->mem_obj->reply->header, HDR_VARY, strBuf(vary)); stringClean(&vary); } #if X_ACCELERATOR_VARY @@ -444,7 +449,13 @@ } #endif storeSetPublicKey(pe); - httpReplySwapOut(pe->mem_obj->reply, pe); + /* TODO: remove this when the metadata is separated */ + { + Packer p; + packerToStoreInit(&p, pe); + httpReplyPackHeadersInto(pe->mem_obj->reply, &p); + packerClean(&p); + } storeBufferFlush(pe); storeTimestampsSet(pe); storeComplete(pe); @@ -1171,8 +1182,11 @@ mem->data_hdr.head); debug(20, 1) ("MemObject->data.tail: %p\n", mem->data_hdr.tail); +#if 0 + /* do we want this one? */ debug(20, 1) ("MemObject->data.origin_offset: %d\n", - mem->data_hdr.origin_offset); + mem->data_hdr.head ? mem->data_hdr.head->nodeBuffer.offset : 0); +#endif debug(20, 1) ("MemObject->start_ping: %d.%06d\n", (int) mem->start_ping.tv_sec, (int) mem->start_ping.tv_usec); @@ -1298,7 +1312,7 @@ return e->mem_obj->object_sz - e->mem_obj->reply->hdr_sz; } -HttpReply * +HttpReply const * storeEntryReply(StoreEntry * e) { if (NULL == e) @@ -1316,11 +1330,41 @@ assert(mem->swapout.sio == NULL); stmemFree(&mem->data_hdr); mem->inmem_hi = mem->inmem_lo = 0; - httpReplyDestroy(mem->reply); - mem->reply = httpReplyCreate(); + /* Should we check for clients? */ + httpReplyReset((HttpReply *)mem->reply); e->expires = e->lastmod = e->timestamp = -1; } +/* Replace a store entry with + * a new reply. This eats the reply. + */ +void +storeEntryReplaceObject(StoreEntry * e, HttpReply * rep) +{ + MemObject *mem = e->mem_obj; + HttpReply *myrep; + Packer p; + debug(20, 3) ("storeEntryReplaceObject: %s\n", storeUrl(e)); + if (!mem) { + debug (20,0)("Attempt to replace object with no in-memory representation\n"); + return; + } + /* TODO: check that there is at most 1 store client ? */ + myrep = (HttpReply *)mem->reply; /* we are allowed to do this */ + /* move info to the mem_obj->reply */ + httpReplyAbsorb(myrep, rep); + + /* TODO: when we store headers serparately remove the header portion */ + /* TODO: mark the length of the headers ? */ + /* We ONLY want the headers */ + packerToStoreInit(&p, e); + assert (e->mem_obj->inmem_hi == 0); + httpReplyPackHeadersInto(mem->reply, &p); + myrep->hdr_sz = e->mem_obj->inmem_hi; /* yuk */ + httpBodyPackInto(&mem->reply->body, &p); + packerClean(&p); +} + /* * storeFsInit * Index: squid/src/store_client.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_client.c,v retrieving revision 1.14.2.12 retrieving revision 1.14.2.13 diff -u -r1.14.2.12 -r1.14.2.13 --- squid/src/store_client.c 24 Sep 2002 10:43:06 -0000 1.14.2.12 +++ squid/src/store_client.c 2 Oct 2002 12:32:18 -0000 1.14.2.13 @@ -1,6 +1,6 @@ /* - * $Id: store_client.c,v 1.14.2.12 2002/09/24 10:43:06 rbcollins Exp $ + * $Id: store_client.c,v 1.14.2.13 2002/10/02 12:32:18 rbcollins Exp $ * * DEBUG: section 20 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -34,12 +34,16 @@ */ #include "squid.h" +#include "HttpReply.h" #include "StoreClient.h" CBDATA_TYPE(store_client); /* * NOTE: 'Header' refers to the swapfile metadata header. + * 'OBJHeader' refers to the object header, with cannonical + * processed object headers (which may derive from FTP/HTTP etc + * upstream protocols/ * 'Body' refers to the swapfile body, which is the full * HTTP reply (including HTTP headers and body). */ @@ -236,6 +240,9 @@ static void storeClientCopy2(StoreEntry * e, store_client * sc) { + /* reentrancy not allowed - note this could lead to + * dropped events + */ if (sc->flags.copy_event_pending) { return; } @@ -375,7 +382,10 @@ assert(sc->callback != NULL); debug(20, 3) ("storeClientReadBody: len %d\n", (int) len); if (sc->copyInto.offset == 0 && len > 0 && mem->reply->sline.status == 0) - httpReplyParse(mem->reply, sc->copyInto.data, headersEnd(sc->copyInto.data, len)); + /* Our structure ! */ + if (!httpReplyParse((HttpReply *)mem->reply, sc->copyInto.data, headersEnd(sc->copyInto.data, len))) { + debug (20,0)("Could not parse headers from on disk object\n"); + } storeClientCallback(sc, len); } @@ -479,9 +489,12 @@ debug(20, 3) ("storeClientReadHeader: copying %d bytes of body\n", (int) copy_sz); xmemmove(sc->copyInto.data, sc->copyInto.data + swap_hdr_sz, copy_sz); - if (sc->copyInto.offset == 0 && len > 0 && mem->reply->sline.status == 0) - httpReplyParse(mem->reply, sc->copyInto.data, - headersEnd(sc->copyInto.data, copy_sz)); + if (sc->copyInto.offset == 0 && len > 0 && mem->reply->sline.status == 0) + /* Our structure ! */ + if (!httpReplyParse((HttpReply *)mem->reply, sc->copyInto.data, + headersEnd(sc->copyInto.data, copy_sz))) { + debug (20,0)("could not parse headers from on disk structure!\n"); + } storeClientCallback(sc, copy_sz); return; } Index: squid/src/store_log.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_log.c,v retrieving revision 1.7 retrieving revision 1.7.40.1 diff -u -r1.7 -r1.7.40.1 --- squid/src/store_log.c 18 Oct 2001 20:52:11 -0000 1.7 +++ squid/src/store_log.c 2 Oct 2002 12:32:18 -0000 1.7.40.1 @@ -1,6 +1,6 @@ /* - * $Id: store_log.c,v 1.7 2001/10/18 20:52:11 squidadm Exp $ + * $Id: store_log.c,v 1.7.40.1 2002/10/02 12:32:18 rbcollins Exp $ * * DEBUG: section 20 Storage Manager Logging Functions * AUTHOR: Duane Wessels @@ -50,7 +50,7 @@ storeLog(int tag, const StoreEntry * e) { MemObject *mem = e->mem_obj; - HttpReply *reply; + HttpReply const *reply; if (NULL == storelog) return; #if UNUSED_CODE Index: squid/src/store_swapout.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/store_swapout.c,v retrieving revision 1.13.14.2 retrieving revision 1.13.14.3 diff -u -r1.13.14.2 -r1.13.14.3 --- squid/src/store_swapout.c 20 Sep 2002 08:16:32 -0000 1.13.14.2 +++ squid/src/store_swapout.c 2 Oct 2002 12:32:19 -0000 1.13.14.3 @@ -1,6 +1,6 @@ /* - * $Id: store_swapout.c,v 1.13.14.2 2002/09/20 08:16:32 rbcollins Exp $ + * $Id: store_swapout.c,v 1.13.14.3 2002/10/02 12:32:19 rbcollins Exp $ * * DEBUG: section 20 Storage Manager Swapout Functions * AUTHOR: Duane Wessels @@ -35,6 +35,8 @@ #include "squid.h" #include "StoreClient.h" +/* FIXME: Abstract the use of this more */ +#include "mem_node.h" static off_t storeSwapOutObjectBytesOnDisk(const MemObject *); static void storeSwapOutStart(StoreEntry * e); @@ -251,7 +253,7 @@ * but we can look at this at a later date or whenever the code results * in bad swapouts, whichever happens first. :-) */ - swap_buf_len = mem->swapout.memnode->len; + swap_buf_len = mem->swapout.memnode->nodeBuffer.length; debug(20, 3) ("storeSwapOut: swap_buf_len = %d\n", (int) swap_buf_len); assert(swap_buf_len > 0); Index: squid/src/structs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/structs.h,v retrieving revision 1.68.2.4 retrieving revision 1.68.2.5 diff -u -r1.68.2.4 -r1.68.2.5 --- squid/src/structs.h 20 Sep 2002 04:03:05 -0000 1.68.2.4 +++ squid/src/structs.h 2 Oct 2002 12:32:19 -0000 1.68.2.5 @@ -1,6 +1,6 @@ /* - * $Id: structs.h,v 1.68.2.4 2002/09/20 04:03:05 rbcollins Exp $ + * $Id: structs.h,v 1.68.2.5 2002/10/02 12:32:19 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -691,6 +691,7 @@ char *store_dir_select_algorithm; int sleep_after_fork; /* microseconds */ external_acl *externalAclHelperList; + char *HttpVersion; }; struct _SquidConfig2 { @@ -966,6 +967,7 @@ unsigned int proxying:1; unsigned int keepalive:1; unsigned int only_if_cached:1; + unsigned int headers_pushed:1; }; struct _icpUdpData { @@ -1393,16 +1395,9 @@ } Http, Ftp, Gopher, Wais; }; -struct _mem_node { - char data[SM_PAGE_SIZE]; - int len; - mem_node *next; -}; - struct _mem_hdr { mem_node *head; mem_node *tail; - int origin_offset; }; /* Removal policies */ @@ -1453,7 +1448,8 @@ mem_node *memnode; /* which node we're currently paging out */ storeIOState *sio; } swapout; - HttpReply *reply; + /* Read only - this reply must be preserved by store clients */ + HttpReply const *reply; /* The original reply. possibly with updated metadata. */ request_t *request; struct timeval start_ping; IRCB *ping_reply_callback; Index: squid/src/typedefs.h =================================================================== RCS file: /cvsroot/squid-sf//squid/src/typedefs.h,v retrieving revision 1.28.2.3 retrieving revision 1.28.2.4 diff -u -r1.28.2.3 -r1.28.2.4 --- squid/src/typedefs.h 20 Sep 2002 04:03:06 -0000 1.28.2.3 +++ squid/src/typedefs.h 2 Oct 2002 12:32:19 -0000 1.28.2.4 @@ -1,6 +1,6 @@ /* - * $Id: typedefs.h,v 1.28.2.3 2002/09/20 04:03:06 rbcollins Exp $ + * $Id: typedefs.h,v 1.28.2.4 2002/10/02 12:32:19 rbcollins Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -31,6 +31,8 @@ * */ +#include "squid.h" + #ifndef SQUID_TYPEDEFS_H #define SQUID_TYPEDEFS_H Index: squid/src/url.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/url.c,v retrieving revision 1.11 retrieving revision 1.11.2.1 diff -u -r1.11 -r1.11.2.1 --- squid/src/url.c 12 Sep 2002 20:56:25 -0000 1.11 +++ squid/src/url.c 2 Oct 2002 12:32:19 -0000 1.11.2.1 @@ -1,6 +1,6 @@ /* - * $Id: url.c,v 1.11 2002/09/12 20:56:25 squidadm Exp $ + * $Id: url.c,v 1.11.2.1 2002/10/02 12:32:19 rbcollins Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "HttpRequest.h" const char *RequestMethodStr[] = { Index: squid/src/urn.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/urn.c,v retrieving revision 1.17.2.7 retrieving revision 1.17.2.8 diff -u -r1.17.2.7 -r1.17.2.8 --- squid/src/urn.c 24 Sep 2002 10:43:06 -0000 1.17.2.7 +++ squid/src/urn.c 2 Oct 2002 12:32:19 -0000 1.17.2.8 @@ -1,6 +1,6 @@ /* - * $Id: urn.c,v 1.17.2.7 2002/09/24 10:43:06 rbcollins Exp $ + * $Id: urn.c,v 1.17.2.8 2002/10/02 12:32:19 rbcollins Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -34,6 +34,8 @@ */ #include "squid.h" +#include "HttpReply.h" +#include "HttpRequest.h" #include "StoreClient.h" #define URN_REQBUF_SZ 4096 @@ -177,6 +179,7 @@ return u1->rtt - u2->rtt; } +/* TODO: use the clientStream support for this */ static void urnHandleReply(void *data, StoreIOBuffer result) { @@ -234,17 +237,20 @@ } s = buf + k; assert(urlres_e->mem_obj->reply); - httpReplyParse(urlres_e->mem_obj->reply, buf, k); - debug(52, 3) ("mem->reply exists, code=%d.\n", - urlres_e->mem_obj->reply->sline.status); - if (urlres_e->mem_obj->reply->sline.status != HTTP_OK) { + rep = httpReplyCreate (); + httpReplyParse(rep, buf, k); + debug(52, 3) ("reply exists, code=%d.\n", + rep->sline.status); + if (rep->sline.status != HTTP_OK) { debug(52, 3) ("urnHandleReply: failed.\n"); err = errorCon(ERR_URN_RESOLVE, HTTP_NOT_FOUND); err->request = requestLink(urnState->request); err->url = xstrdup(storeUrl(e)); errorAppendEntry(e, err); + httpReplyDestroy(rep); goto error; } + httpReplyDestroy(rep); while (xisspace(*s)) s++; urls = urnParseReply(s, urnState->request->method); @@ -288,8 +294,7 @@ "Generated by %s@%s\n" "\n", full_appname_string, getMyHostname()); - rep = e->mem_obj->reply; - httpReplyReset(rep); + rep = httpReplyCreate(); httpBuildVersion(&version, 1, 0); httpReplySetHeaders(rep, version, HTTP_MOVED_TEMPORARILY, NULL, "text/html", mb.size, 0, squid_curtime); Index: squid/src/wais.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/wais.c,v retrieving revision 1.9 retrieving revision 1.9.2.1 diff -u -r1.9 -r1.9.2.1 --- squid/src/wais.c 15 Sep 2002 11:06:34 -0000 1.9 +++ squid/src/wais.c 2 Oct 2002 12:32:19 -0000 1.9.2.1 @@ -1,6 +1,6 @@ /* - * $Id: wais.c,v 1.9 2002/09/15 11:06:34 rbcollins Exp $ + * $Id: wais.c,v 1.9.2.1 2002/10/02 12:32:19 rbcollins Exp $ * * DEBUG: section 24 WAIS Relay * AUTHOR: Harvest Derived @@ -34,6 +34,7 @@ */ #include "squid.h" +#include "HttpRequest.h" typedef struct { int fd; Index: squid/src/whois.c =================================================================== RCS file: /cvsroot/squid-sf//squid/src/whois.c,v retrieving revision 1.9 retrieving revision 1.9.6.1 diff -u -r1.9 -r1.9.6.1 --- squid/src/whois.c 22 Aug 2002 12:30:09 -0000 1.9 +++ squid/src/whois.c 2 Oct 2002 12:32:20 -0000 1.9.6.1 @@ -1,6 +1,6 @@ /* - * $Id: whois.c,v 1.9 2002/08/22 12:30:09 squidadm Exp $ + * $Id: whois.c,v 1.9.6.1 2002/10/02 12:32:20 rbcollins Exp $ * * DEBUG: section 75 WHOIS protocol * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -97,8 +97,12 @@ debug(75, 3) ("whoisReadReply: FD %d read %d bytes\n", fd, len); debug(75, 5) ("{%s}\n", buf); if (len > 0) { - if (0 == mem->inmem_hi) - mem->reply->sline.status = HTTP_OK; + if (0 == mem->inmem_hi) { + assert (0); + /* I haven't coded for this yet. Lets see where it occurs */ + /* TODO: FIXME */ + /* ->reply->sline.status = HTTP_OK; */ + } fd_bytes(fd, len, FD_READ); kb_incr(&statCounter.server.all.kbytes_in, len); kb_incr(&statCounter.server.http.kbytes_in, len);