From 06a5ae203abccdad71cae5187ade1b7bc10514fc Mon Sep 17 00:00:00 2001 From: wessels <> Date: Sat, 5 Nov 2005 07:08:32 +0000 Subject: [PATCH] Converted HttpReply to a proper C++ class. Removed httpReplyCreate(), httpReplyDestroy(), and other static httpReply*() functions. --- src/ESI.cc | 4 +- src/ESIInclude.cc | 6 +- src/HttpReply.cc | 280 +++++++++++++++++-------------------- src/HttpReply.h | 72 +++++----- src/MemObject.cc | 8 +- src/access_log.cc | 4 +- src/cache_manager.cc | 23 ++- src/cbdata.cc | 12 +- src/client_side.cc | 4 +- src/client_side_reply.cc | 57 ++++---- src/client_side_request.cc | 4 +- src/errorpage.cc | 14 +- src/ftp.cc | 21 ++- src/http.cc | 12 +- src/internal.cc | 21 ++- src/mime.cc | 10 +- src/net_db.cc | 15 +- src/peer_digest.cc | 4 +- src/store.cc | 14 +- src/store_client.cc | 17 ++- src/store_digest.cc | 12 +- src/urn.cc | 18 +-- src/whois.cc | 6 +- 23 files changed, 302 insertions(+), 336 deletions(-) diff --git a/src/ESI.cc b/src/ESI.cc index 008b2d9fe8..ba8a71c07c 100644 --- a/src/ESI.cc +++ b/src/ESI.cc @@ -1,6 +1,6 @@ /* - * $Id: ESI.cc,v 1.18 2005/09/24 14:38:35 serassio Exp $ + * $Id: ESI.cc,v 1.19 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -1423,7 +1423,7 @@ ESIContext::freeResources () debug (86,5)("ESIContext::freeResources: Freeing for this=%p\n",this); if (rep) { - httpReplyDestroy(rep); + delete rep; rep = NULL; } diff --git a/src/ESIInclude.cc b/src/ESIInclude.cc index 4c6320ddc7..f15aa6b86a 100644 --- a/src/ESIInclude.cc +++ b/src/ESIInclude.cc @@ -1,6 +1,6 @@ /* - * $Id: ESIInclude.cc,v 1.7 2005/09/09 17:31:33 wessels Exp $ + * $Id: ESIInclude.cc,v 1.8 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 86 ESI processing * AUTHOR: Robert Collins @@ -101,7 +101,7 @@ esiBufferRecipient (clientStreamNode *node, ClientHttpRequest *http, HttpReply * } else { if (rep) { if (rep->sline.status != HTTP_OK) { - httpReplyDestroy(rep); + delete rep; rep = NULL; esiStream->include->fail (esiStream); esiStream->finished = 1; @@ -115,7 +115,7 @@ esiBufferRecipient (clientStreamNode *node, ClientHttpRequest *http, HttpReply * #endif - httpReplyDestroy(rep); + delete rep; rep = NULL; } diff --git a/src/HttpReply.cc b/src/HttpReply.cc index d464d822d3..b3f8f3ca25 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.77 2005/09/17 05:50:07 wessels Exp $ + * $Id: HttpReply.cc,v 1.78 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -52,13 +52,6 @@ static http_hdr_type Denied304HeadersArr[] = }; -/* local routines */ -static void httpReplyClean(HttpReply * rep); -static void httpReplyDoDestroy(HttpReply * rep); -static void httpReplyHdrCacheClean(HttpReply * rep); -static time_t httpReplyHdrExpirationTime(const HttpReply * rep); - - /* module initialization */ void httpReplyInitModule(void) @@ -69,73 +62,64 @@ httpReplyInitModule(void) } -HttpReply * -httpReplyCreate(void) -{ - HttpReply *rep = new HttpReply; - debug(58, 7) ("creating rep: %p\n", rep); - return rep; -} - HttpReply::HttpReply() : HttpMsg(hoReply), date (0), last_modified (0), expires (0), surrogate_control (NULL), content_range (NULL), keep_alive (0), protoPrefix("HTTP/") { - httpBodyInit(&body); - hdrCacheInit(); - httpStatusLineInit(&sline); -} - -void HttpReply::reset() -{ - httpReplyReset(this); + init(); } -static void -httpReplyClean(HttpReply * rep) +HttpReply::~HttpReply() { - assert(rep); - httpBodyClean(&rep->body); - httpReplyHdrCacheClean(rep); - httpHeaderClean(&rep->header); - httpStatusLineClean(&rep->sline); + if (do_clean) + clean(); } void -httpReplyDestroy(HttpReply * rep) +HttpReply::init() { - assert(rep); - debug(58, 7) ("destroying rep: %p\n", rep); - httpReplyClean(rep); - httpReplyDoDestroy(rep); + httpBodyInit(&body); + hdrCacheInit(); + httpStatusLineInit(&sline); + do_clean = true; } -void -httpReplyReset(HttpReply * rep) +void HttpReply::reset() { + // reset should not reset the protocol; could have made protoPrefix a // virtual function instead, but it is not clear whether virtual methods // are allowed with MEMPROXY_CLASS() and whether some cbdata void* // conversions are not going to kill virtual tables - const String pfx = rep->protoPrefix; - httpReplyClean(rep); - *rep = HttpReply(); - rep->protoPrefix = pfx; + const String pfx = protoPrefix; + clean(); + init(); + protoPrefix = pfx; +} + +void +HttpReply::clean() +{ + httpBodyClean(&body); + hdrCacheClean(); + httpHeaderClean(&header); + httpStatusLineClean(&sline); } /* absorb: copy the contents of a new reply to the old one, destroy new one */ void -httpReplyAbsorb(HttpReply * rep, HttpReply * new_rep) +HttpReply::absorb(HttpReply * new_rep) { - assert(rep && new_rep); - httpReplyClean(rep); - *rep = *new_rep; + assert(new_rep); + clean(); + *this = *new_rep; new_rep->header.entries.clean(); /* cannot use Clean() on new reply now! */ + new_rep->do_clean = false; new_rep->cache_control = NULL; // helps with debugging - httpReplyDoDestroy(new_rep); + delete new_rep; } /* - * httpReplyParse takes character buffer of HTTP headers (buf), + * parse() takes character buffer of HTTP headers (buf), * which may not be NULL-terminated, and fills in an HttpReply * structure (rep). The parameter 'end' specifies the offset to * the end of the reply headers. The caller may know where the @@ -143,7 +127,7 @@ httpReplyAbsorb(HttpReply * rep, HttpReply * new_rep) * returns true on success. */ bool -httpReplyParse(HttpReply * rep, const char *buf, ssize_t end) +HttpReply::parse(const char *buf, ssize_t end) { /* * this extra buffer/copy will be eliminated when headers become @@ -154,86 +138,83 @@ httpReplyParse(HttpReply * rep, const char *buf, ssize_t end) MemBuf mb; int success; /* reset current state, because we are not used in incremental fashion */ - httpReplyReset(rep); + reset(); /* put a string terminator. s is how many bytes to touch in * 'buf' including the terminating NULL. */ mb.init(); mb.append(buf, end); - mb.append("\0", 1); - success = rep->httpMsgParseStep(mb.buf, 0); + mb.terminate(); + success = httpMsgParseStep(mb.buf, 0); mb.clean(); return success == 1; } void -httpReplyPackHeadersInto(const HttpReply * rep, Packer * p) +HttpReply::packHeadersInto(Packer * p) const { - assert(rep); - httpStatusLinePackInto(&rep->sline, p); - httpHeaderPackInto(&rep->header, p); + httpStatusLinePackInto(&sline, p); + httpHeaderPackInto(&header, p); packerAppend(p, "\r\n", 2); } void -httpReplyPackInto(const HttpReply * rep, Packer * p) +HttpReply::packInto(Packer * p) { - httpReplyPackHeadersInto(rep, p); - httpBodyPackInto(&rep->body, p); + packHeadersInto(p); + httpBodyPackInto(&body, p); } -/* create memBuf, create mem-based packer, pack, destroy packer, return MemBuf */ +/* create memBuf, create mem-based packer, pack, destroy packer, return MemBuf */ MemBuf * -httpReplyPack(const HttpReply * rep) +HttpReply::pack() { MemBuf *mb = new MemBuf; Packer p; - assert(rep); mb->init(); packerToMemInit(&p, mb); - httpReplyPackInto(rep, &p); + packInto(&p); packerClean(&p); return mb; } -/* swap: create swap-based packer, pack, destroy packer +/* + * swap: create swap-based packer, pack, destroy packer * This eats the reply. */ void -httpReplySwapOut(HttpReply * rep, StoreEntry * e) +HttpReply::swapOut(StoreEntry * e) { - assert(rep && e); + assert(e); - storeEntryReplaceObject(e, rep); + storeEntryReplaceObject(e, this); } MemBuf * httpPackedReply(HttpVersion ver, http_status status, const char *ctype, int clen, time_t lmt, time_t expires) { - HttpReply *rep = httpReplyCreate(); - httpReplySetHeaders(rep, ver, status, ctype, NULL, clen, lmt, expires); - MemBuf *mb = httpReplyPack(rep); - httpReplyDestroy(rep); + HttpReply *rep = new HttpReply; + rep->setHeaders(ver, status, ctype, NULL, clen, lmt, expires); + MemBuf *mb = rep->pack(); + delete rep; return mb; } HttpReply * -httpReplyMake304 (const HttpReply * rep) +HttpReply::make304 () const { static const http_hdr_type ImsEntries[] = {HDR_DATE, HDR_CONTENT_TYPE, HDR_EXPIRES, HDR_LAST_MODIFIED, /* eof */ HDR_OTHER}; - HttpReply *rv; + HttpReply *rv = new HttpReply; int t; HttpHeaderEntry *e; - assert(rep); - rv = httpReplyCreate (); /* rv->content_length; */ - rv->date = rep->date; - rv->last_modified = rep->last_modified; - rv->expires = rep->expires; - rv->content_type = rep->content_type; + rv->date = date; + rv->last_modified = last_modified; + rv->expires = expires; + rv->content_type = content_type; /* rv->cache_control */ /* rv->content_range */ /* rv->keep_alive */ @@ -242,7 +223,7 @@ httpReplyMake304 (const HttpReply * rep) HTTP_NOT_MODIFIED, ""); for (t = 0; ImsEntries[t] != HDR_OTHER; ++t) - if ((e = httpHeaderFindEntry(&rep->header, ImsEntries[t]))) + if ((e = httpHeaderFindEntry(&header, ImsEntries[t]))) httpHeaderAddEntry(&rv->header, httpHeaderEntryClone(e)); /* rv->body */ @@ -250,36 +231,33 @@ httpReplyMake304 (const HttpReply * rep) } MemBuf * -httpPacked304Reply(const HttpReply * rep) +HttpReply::packed304Reply() { /* Not as efficient as skipping the header duplication, * but easier to maintain */ - HttpReply *temp; - assert (rep); - temp = httpReplyMake304 (rep); - MemBuf *rv = httpReplyPack(temp); - httpReplyDestroy (temp); + HttpReply *temp = make304 (); + MemBuf *rv = temp->pack(); + delete temp; return rv; } void -httpReplySetHeaders(HttpReply * reply, HttpVersion ver, http_status status, const char *reason, - const char *ctype, int clen, time_t lmt, time_t expires) +HttpReply::setHeaders(HttpVersion ver, http_status status, const char *reason, + const char *ctype, int clen, time_t lmt, time_t expires) { HttpHeader *hdr; - assert(reply); - httpStatusLineSet(&reply->sline, ver, status, reason); - hdr = &reply->header; + httpStatusLineSet(&sline, ver, status, reason); + hdr = &header; httpHeaderPutStr(hdr, HDR_SERVER, visible_appname_string); httpHeaderPutStr(hdr, HDR_MIME_VERSION, "1.0"); httpHeaderPutTime(hdr, HDR_DATE, squid_curtime); if (ctype) { httpHeaderPutStr(hdr, HDR_CONTENT_TYPE, ctype); - reply->content_type = ctype; + content_type = ctype; } else - reply->content_type = String(); + content_type = String(); if (clen >= 0) httpHeaderPutInt(hdr, HDR_CONTENT_LENGTH, clen); @@ -290,29 +268,28 @@ httpReplySetHeaders(HttpReply * reply, HttpVersion ver, http_status status, cons if (lmt > 0) /* this used to be lmt != 0 @?@ */ httpHeaderPutTime(hdr, HDR_LAST_MODIFIED, lmt); - reply->date = squid_curtime; + date = squid_curtime; - reply->content_length = clen; + content_length = clen; - reply->expires = expires; + expires = expires; - reply->last_modified = lmt; + last_modified = lmt; } void -httpRedirectReply(HttpReply * reply, http_status status, const char *loc) +HttpReply::redirect(http_status status, const char *loc) { HttpHeader *hdr; - assert(reply); HttpVersion ver(1,0); - httpStatusLineSet(&reply->sline, ver, status, httpStatusString(status)); - hdr = &reply->header; + httpStatusLineSet(&sline, ver, status, httpStatusString(status)); + hdr = &header; httpHeaderPutStr(hdr, HDR_SERVER, full_appname_string); httpHeaderPutTime(hdr, HDR_DATE, squid_curtime); httpHeaderPutInt(hdr, HDR_CONTENT_LENGTH, 0); httpHeaderPutStr(hdr, HDR_LOCATION, loc); - reply->date = squid_curtime; - reply->content_length = 0; + date = squid_curtime; + content_length = 0; } /* compare the validators of two replies. @@ -320,21 +297,21 @@ httpRedirectReply(HttpReply * reply, http_status status, const char *loc) * 0 = they do not match */ int -httpReplyValidatorsMatch(HttpReply const * rep, HttpReply const * otherRep) +HttpReply::validatorsMatch(HttpReply const * otherRep) const { String one,two; - assert (rep && otherRep); + assert (otherRep); /* Numbers first - easiest to check */ /* Content-Length */ /* TODO: remove -1 bypass */ - if (rep->content_length != otherRep->content_length - && rep->content_length > -1 && + if (content_length != otherRep->content_length + && content_length > -1 && otherRep->content_length > -1) return 0; /* ETag */ - one = httpHeaderGetStrOrList(&rep->header, HDR_ETAG); + one = httpHeaderGetStrOrList(&header, HDR_ETAG); two = httpHeaderGetStrOrList(&otherRep->header, HDR_ETAG); @@ -344,11 +321,11 @@ httpReplyValidatorsMatch(HttpReply const * rep, HttpReply const * otherRep) return 0; } - if (rep->last_modified != otherRep->last_modified) + if (last_modified != otherRep->last_modified) return 0; /* MD5 */ - one = httpHeaderGetStrOrList(&rep->header, HDR_CONTENT_MD5); + one = httpHeaderGetStrOrList(&header, HDR_CONTENT_MD5); two = httpHeaderGetStrOrList(&otherRep->header, HDR_CONTENT_MD5); @@ -363,13 +340,13 @@ httpReplyValidatorsMatch(HttpReply const * rep, HttpReply const * otherRep) void -HttpReply::httpReplyUpdateOnNotModified(HttpReply const * freshRep) +HttpReply::updateOnNotModified(HttpReply const * freshRep) { assert(freshRep); /* Can not update modified headers that don't match! */ - assert (httpReplyValidatorsMatch(this, freshRep)); + assert (validatorsMatch(freshRep)); /* clean cache */ - httpReplyHdrCacheClean(this); + hdrCacheClean(); /* update raw headers */ httpHeaderUpdate(&header, &freshRep->header, (const HttpHeaderMask *) &Denied304HeadersMask); @@ -380,50 +357,43 @@ HttpReply::httpReplyUpdateOnNotModified(HttpReply const * freshRep) /* internal routines */ -/* internal function used by Destroy and Absorb */ -static void -httpReplyDoDestroy(HttpReply * rep) -{ - delete rep; -} - -static time_t -httpReplyHdrExpirationTime(const HttpReply * rep) +time_t +HttpReply::hdrExpirationTime() { /* The s-maxage and max-age directive takes priority over Expires */ - if (rep->cache_control) { - if (rep->date >= 0) { - if (rep->cache_control->s_maxage >= 0) - return rep->date + rep->cache_control->s_maxage; + if (cache_control) { + if (date >= 0) { + if (cache_control->s_maxage >= 0) + return date + cache_control->s_maxage; - if (rep->cache_control->max_age >= 0) - return rep->date + rep->cache_control->max_age; + if (cache_control->max_age >= 0) + return date + cache_control->max_age; } else { /* * Conservatively handle the case when we have a max-age * header, but no Date for reference? */ - if (rep->cache_control->s_maxage >= 0) + if (cache_control->s_maxage >= 0) return squid_curtime; - if (rep->cache_control->max_age >= 0) + if (cache_control->max_age >= 0) return squid_curtime; } } if (Config.onoff.vary_ignore_expire && - httpHeaderHas(&rep->header, HDR_VARY)) { - const time_t d = httpHeaderGetTime(&rep->header, HDR_DATE); - const time_t e = httpHeaderGetTime(&rep->header, HDR_EXPIRES); + httpHeaderHas(&header, HDR_VARY)) { + const time_t d = httpHeaderGetTime(&header, HDR_DATE); + const time_t e = httpHeaderGetTime(&header, HDR_EXPIRES); if (d == e) return -1; } - if (httpHeaderHas(&rep->header, HDR_EXPIRES)) { - const time_t e = httpHeaderGetTime(&rep->header, HDR_EXPIRES); + if (httpHeaderHas(&header, HDR_EXPIRES)) { + const time_t e = httpHeaderGetTime(&header, HDR_EXPIRES); /* * HTTP/1.0 says that robust implementations should consider * bad or malformed Expires header as equivalent to "expires @@ -455,28 +425,28 @@ HttpReply::hdrCacheInit() content_type = String(); /* be sure to set expires after date and cache-control */ - expires = httpReplyHdrExpirationTime(this); + expires = hdrExpirationTime(); } /* sync this routine when you update HttpReply struct */ -static void -httpReplyHdrCacheClean(HttpReply * rep) +void +HttpReply::hdrCacheClean() { - rep->content_type.clean(); + content_type.clean(); - if (rep->cache_control) { - httpHdrCcDestroy(rep->cache_control); - rep->cache_control = NULL; + if (cache_control) { + httpHdrCcDestroy(cache_control); + cache_control = NULL; } - if (rep->surrogate_control) { - httpHdrScDestroy(rep->surrogate_control); - rep->surrogate_control = NULL; + if (surrogate_control) { + httpHdrScDestroy(surrogate_control); + surrogate_control = NULL; } - if (rep->content_range) { - httpHdrContRangeDestroy(rep->content_range); - rep->content_range = NULL; + if (content_range) { + httpHdrContRangeDestroy(content_range); + content_range = NULL; } } @@ -484,22 +454,22 @@ httpReplyHdrCacheClean(HttpReply * rep) * Returns the body size of a HTTP response */ int -httpReplyBodySize(method_t method, HttpReply const * reply) +HttpReply::bodySize(method_t method) const { - if (reply->sline.version.major < 1) + if (sline.version.major < 1) return -1; else if (METHOD_HEAD == method) return 0; - else if (reply->sline.status == HTTP_OK) + else if (sline.status == HTTP_OK) (void) 0; /* common case, continue */ - else if (reply->sline.status == HTTP_NO_CONTENT) + else if (sline.status == HTTP_NO_CONTENT) return 0; - else if (reply->sline.status == HTTP_NOT_MODIFIED) + else if (sline.status == HTTP_NOT_MODIFIED) return 0; - else if (reply->sline.status < HTTP_OK) + else if (sline.status < HTTP_OK) return 0; - return reply->content_length; + return content_length; } bool HttpReply::sanityCheckStartLine(MemBuf *buf, http_status *error) diff --git a/src/HttpReply.h b/src/HttpReply.h index 8ecea4ce5e..8e61e38c1b 100644 --- a/src/HttpReply.h +++ b/src/HttpReply.h @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.h,v 1.11 2005/09/15 20:19:41 wessels Exp $ + * $Id: HttpReply.h,v 1.12 2005/11/05 00:08:32 wessels Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -37,43 +37,9 @@ #include "HttpMsg.h" #include "HttpStatusLine.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 true on success */ -extern bool 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, HttpVersion 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(HttpVersion 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); -/* 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 int httpReplyValidatorsMatch (HttpReply const *, HttpReply const *); - +extern MemBuf *httpPackedReply(HttpVersion ver, http_status status, const char *ctype, int clen, time_t lmt, time_t expires); /* Sync changes here with HttpReply.cc */ @@ -85,6 +51,7 @@ class HttpReply: public HttpMsg public: MEMPROXY_CLASS(HttpReply); HttpReply(); + ~HttpReply(); virtual void reset(); @@ -107,9 +74,40 @@ public: HttpBody body; /* for small constant memory-resident text bodies only */ String protoPrefix; // e.g., "HTTP/" + bool do_clean; public: - void httpReplyUpdateOnNotModified(HttpReply const *other); + void updateOnNotModified(HttpReply const *other); + /* parse returns true on success */ + bool parse(const char *buf, ssize_t); + /* absorb: copy the contents of a new reply to the old one, destroy new one */ + void absorb(HttpReply * new_rep); + /* set commonly used info with one call */ + void setHeaders(HttpVersion ver, http_status status, + const char *reason, const char *ctype, int clen, time_t lmt, time_t expires); + /* mem-pack: returns a ready to use mem buffer with a packed reply */ + MemBuf *pack(); + /* swap: create swap-based packer, pack, destroy packer */ + void swapOut(StoreEntry * e); + /* construct a 304 reply and return it */ + HttpReply *make304() const; + + void redirect(http_status, const char *); + int bodySize(method_t) const; + int validatorsMatch (HttpReply const *other) const; + void packHeadersInto(Packer * p) const; + +private: + /* initialize */ + void init(); + void clean(); + void hdrCacheClean(); + void packInto(Packer * p); + /* ez-routines */ + /* construct 304 reply and pack it into MemBuf, return MemBuf */ + MemBuf *packed304Reply(); + /* header manipulation */ + time_t hdrExpirationTime(); protected: virtual void packFirstLineInto(Packer * p, bool) const; diff --git a/src/MemObject.cc b/src/MemObject.cc index 8a41dd2e7b..6900f13b5b 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -1,6 +1,6 @@ /* - * $Id: MemObject.cc,v 1.17 2005/09/17 05:50:07 wessels Exp $ + * $Id: MemObject.cc,v 1.18 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -73,9 +73,9 @@ MemObject::inUseCount() return stats.items_inuse; } -MemObject::MemObject(char const *aUrl, char const *aLog_url) : - _reply (httpReplyCreate()) +MemObject::MemObject(char const *aUrl, char const *aLog_url) { + _reply = new HttpReply; url = xstrdup(aUrl); #if URL_CHECKSUM_DEBUG @@ -112,7 +112,7 @@ MemObject::~MemObject() #endif if (_reply) - httpReplyDestroy((HttpReply *)_reply); + delete _reply; requestUnlink(request); diff --git a/src/access_log.cc b/src/access_log.cc index 769cf666fd..defee03e70 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -1,6 +1,6 @@ /* - * $Id: access_log.cc,v 1.106 2005/10/16 14:31:25 serassio Exp $ + * $Id: access_log.cc,v 1.107 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -1787,7 +1787,7 @@ accessLogFreeMemory(AccessLogEntry * aLogEntry) safe_free(aLogEntry->cache.authuser); if (aLogEntry->reply) { - httpReplyDestroy(aLogEntry->reply); + delete aLogEntry->reply; aLogEntry->reply = NULL; } diff --git a/src/cache_manager.cc b/src/cache_manager.cc index 7ac00de4e8..0e0514a184 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -1,6 +1,6 @@ /* - * $Id: cache_manager.cc,v 1.33 2005/09/10 19:31:31 serassio Exp $ + * $Id: cache_manager.cc,v 1.34 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 16 Cache Manager Objects * AUTHOR: Duane Wessels @@ -295,7 +295,7 @@ cachemgrStart(int fd, HttpRequest * request, StoreEntry * entry) httpHeaderPutAuth(&rep->header, "Basic", mgr->action); /* store the reply */ - httpReplySwapOut(rep, entry); + rep->swapOut(entry); entry->expires = squid_curtime; @@ -317,16 +317,15 @@ cachemgrStart(int fd, HttpRequest * request, StoreEntry * entry) { HttpVersion version(1,0); - HttpReply *rep = httpReplyCreate(); - httpReplySetHeaders(rep, - version, - HTTP_OK, - NULL, - "text/plain", - -1, /* C-Len */ - squid_curtime, /* LMT */ - squid_curtime); - httpReplySwapOut(rep, entry); + HttpReply *rep = new HttpReply; + rep->setHeaders(version, + HTTP_OK, + NULL, + "text/plain", + -1, /* C-Len */ + squid_curtime, /* LMT */ + squid_curtime); + rep->swapOut(entry); } a->handler(entry); diff --git a/src/cbdata.cc b/src/cbdata.cc index 644d56bc84..4c7fc8023a 100644 --- a/src/cbdata.cc +++ b/src/cbdata.cc @@ -1,6 +1,6 @@ /* - * $Id: cbdata.cc,v 1.64 2004/08/30 05:12:31 robertc Exp $ + * $Id: cbdata.cc,v 1.65 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 45 Callback Data Registry * ORIGINAL AUTHOR: Duane Wessels @@ -115,7 +115,7 @@ public: /* TODO: examine making cbdata templated on this - so we get type * safe access to data - RBC 20030902 */ void *data; -void check() const { assert(cookie == ((long)this ^ Cookie));} +void check(int line) const {assert(cookie == ((long)this ^ Cookie));} size_t dataSize() const { return sizeof(data);} @@ -298,7 +298,7 @@ cbdataInternalFree(void *p) debug(45, 3) ("cbdataFree: %p\n", p); #endif - c->check(); + c->check(__LINE__); assert(c->valid); c->valid = 0; #if CBDATA_DEBUG @@ -362,7 +362,7 @@ cbdataInternalLock(const void *p) #endif - c->check(); + c->check(__LINE__); assert(c->locks < 65535); @@ -395,7 +395,7 @@ cbdataInternalUnlock(const void *p) #endif - c->check(); + c->check(__LINE__); assert(c != NULL); @@ -445,7 +445,7 @@ cbdataReferenceValid(const void *p) c = (cbdata *) (((char *) p) - cbdata::Offset); - c->check(); + c->check(__LINE__); assert(c->locks > 0); diff --git a/src/client_side.cc b/src/client_side.cc index 88f57fbcca..10243c79e7 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.701 2005/10/23 15:52:17 hno Exp $ + * $Id: client_side.cc,v 1.702 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -1168,7 +1168,7 @@ ClientSocketContext::sendStartOfMessage(HttpReply * rep, StoreIOBuffer bodyData) { prepareReply(rep); assert (rep); - MemBuf *mb = httpReplyPack(rep); + MemBuf *mb = rep->pack(); /* Save length of headers for persistent conn checks */ http->out.headers_sz = mb->contentSize(); #if HEADERS_LOG diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 00a7ff80e8..2071105caa 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.88 2005/09/15 19:22:30 wessels Exp $ + * $Id: client_side_reply.cc,v 1.89 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -315,8 +315,7 @@ clientReplyContext::clientGetsOldEntry()const /* This is a duplicate call through the HandleIMS code path. * Can we guarantee we don't need it elsewhere? */ - if (!httpReplyValidatorsMatch(http->storeEntry()->getReply(), - old_entry->getReply())) { + if (!http->storeEntry()->getReply()->validatorsMatch(old_entry->getReply())) { debug(88, 5) ("clientGetsOldEntry: NO, Old object has been invalidated" "by the new one\n"); return false; @@ -414,8 +413,7 @@ clientReplyContext::handleIMSGiveClientUpdatedOldEntry() * headers have been loaded from disk. */ http->logType = LOG_TCP_REFRESH_HIT; - if (httpReplyValidatorsMatch(http->storeEntry()->getReply(), - old_entry->getReply())) { + if (http->storeEntry()->getReply()->validatorsMatch(old_entry->getReply())) { int unlink_request = 0; if (old_entry->mem_obj->request == NULL) { @@ -429,7 +427,7 @@ clientReplyContext::handleIMSGiveClientUpdatedOldEntry() * not the body they refer to. */ HttpReply *old_rep = (HttpReply *) old_entry->getReply(); - old_rep->httpReplyUpdateOnNotModified(http->storeEntry()->getReply()); + old_rep->updateOnNotModified(http->storeEntry()->getReply()); storeTimestampsSet(old_entry); @@ -461,8 +459,7 @@ clientReplyContext::handleIMSGiveClientNewEntry() * Send the IMS reply to the client. */ sendClientUpstreamResponse(); - } else if (httpReplyValidatorsMatch (http->storeEntry()->getReply(), - old_entry->getReply())) { + } else if (http->storeEntry()->getReply()->validatorsMatch(old_entry->getReply())) { /* Our object is usable once updated */ /* the client did not ask for IMS, send the whole object */ @@ -472,7 +469,7 @@ clientReplyContext::handleIMSGiveClientNewEntry() if (HTTP_NOT_MODIFIED == http->storeEntry()->getReply()->sline.status) { HttpReply *old_rep = (HttpReply *) old_entry->getReply(); - old_rep->httpReplyUpdateOnNotModified(http->storeEntry()->getReply()); + old_rep->updateOnNotModified(http->storeEntry()->getReply()); storeTimestampsSet(old_entry); http->logType = LOG_TCP_REFRESH_HIT; } @@ -728,7 +725,7 @@ clientReplyContext::cacheHit(StoreIOBuffer result) sendMoreData(result); } else { time_t const timestamp = e->timestamp; - HttpReply *temprep = httpReplyMake304 (e->getReply()); + HttpReply *temprep = e->getReply()->make304(); http->logType = LOG_TCP_IMS_HIT; removeClientStoreReference(&sc, http); createStoreEntry(http->request->method, @@ -739,7 +736,7 @@ clientReplyContext::cacheHit(StoreIOBuffer result) * reply has a meaningful Age: header. */ e->timestamp = timestamp; - httpReplySwapOut (temprep, e); + temprep->swapOut(e); e->complete(); /* 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 @@ -818,16 +815,15 @@ clientReplyContext::processMiss() triggerInitialStoreRead(); if (http->redirect.status) { - HttpReply *rep = httpReplyCreate(); + HttpReply *rep = new HttpReply; #if LOG_TCP_REDIRECTS http->logType = LOG_TCP_REDIRECT; #endif storeReleaseRequest(http->storeEntry()); - httpRedirectReply(rep, http->redirect.status, - http->redirect.location); - httpReplySwapOut(rep, http->storeEntry()); + rep->redirect(http->redirect.status, http->redirect.location); + rep->swapOut(http->storeEntry()); http->storeEntry()->complete(); return; } @@ -1026,13 +1022,13 @@ clientReplyContext::purgeDoPurgeHead(StoreEntry *newEntry) triggerInitialStoreRead(); - r = httpReplyCreate(); + r = new HttpReply; HttpVersion version(1,0); - httpReplySetHeaders(r, version, purgeStatus, NULL, NULL, 0, 0, -1); + r->setHeaders(version, purgeStatus, NULL, NULL, 0, 0, -1); - httpReplySwapOut(r, http->storeEntry()); + r->swapOut(http->storeEntry()); http->storeEntry()->complete(); } @@ -1052,11 +1048,11 @@ clientReplyContext::traceReply(clientStreamNode * node) tempBuffer, SendMoreData, this); storeReleaseRequest(http->storeEntry()); storeBuffer(http->storeEntry()); - rep = httpReplyCreate(); + rep = new HttpReply; HttpVersion version(1,0); - httpReplySetHeaders(rep, version, HTTP_OK, NULL, "text/plain", - httpRequestPrefixLen(http->request), 0, squid_curtime); - httpReplySwapOut(rep, http->storeEntry()); + rep->setHeaders(version, HTTP_OK, NULL, "text/plain", + httpRequestPrefixLen(http->request), 0, squid_curtime); + rep->swapOut(http->storeEntry()); httpRequestSwapOut(http->request, http->storeEntry()); http->storeEntry()->complete(); } @@ -1217,8 +1213,7 @@ clientReplyContext::replyStatus() debug(88, 5) ("clientReplyStatus: transfer is DONE\n"); /* Ok we're finished, but how? */ - if (httpReplyBodySize(http->request->method, - http->storeEntry()->getReply()) < 0) { + if (http->storeEntry()->getReply()->bodySize(http->request->method) < 0) { debug(88, 5) ("clientReplyStatus: closing, content_length < 0\n"); return STREAM_FAILED; } @@ -1412,7 +1407,7 @@ clientReplyContext::buildReplyHeader() #endif - if (httpReplyBodySize(request->method, holdingReply) < 0) { + if (holdingReply->bodySize(request->method) < 0) { debug(88, 3) ("clientBuildReplyHeader: can't keep-alive, unknown body size\n"); @@ -1469,13 +1464,13 @@ clientReplyContext::buildReply(const char *buf, size_t size) if (!k) return; - holdReply(httpReplyCreate()); + holdReply(new HttpReply); - if (!httpReplyParse(holdingReply, buf, k)) { + if (!holdingReply->parse(buf, k)) { /* parsing failure, get rid of the invalid reply */ - httpReplyDestroy(holdingReply); + delete holdingReply; holdReply (NULL); - /* This is wrong. httpReplyDestroy should to the rep + /* This is wrong. ~HttpReply() should to the rep * for us, and we can destroy our own range info */ @@ -1868,7 +1863,7 @@ clientReplyContext::processReplyAccess () http->request); removeClientStoreReference(&sc, http); startError(err); - httpReplyDestroy(rep); + delete rep; return; } @@ -1918,7 +1913,7 @@ clientReplyContext::processReplyAccessResult(bool accessAllowed) startError(err); - httpReplyDestroy(rep); + delete rep; http->logType = LOG_TCP_DENIED_REPLY; diff --git a/src/client_side_request.cc b/src/client_side_request.cc index b12af7cd7f..3204ffde0e 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.49 2005/10/18 20:17:21 serassio Exp $ + * $Id: client_side_request.cc,v 1.50 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -890,7 +890,7 @@ ClientHttpRequest::gotEnough() const { /** TODO: should be querying the stream. */ int contentLength = - httpReplyBodySize(request->method, memObject()->getReply()); + memObject()->getReply()->bodySize(request->method); assert(contentLength >= 0); if (out.offset < contentLength) diff --git a/src/errorpage.cc b/src/errorpage.cc index 5345c0b0bb..5c86fa4b43 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.204 2005/09/17 05:50:08 wessels Exp $ + * $Id: errorpage.cc,v 1.205 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -376,7 +376,7 @@ errorAppendEntry(StoreEntry * entry, ErrorState * err) * on 407/401 responses, and do not check the accel state on 401/407 responses */ authenticateFixHeader(rep, err->auth_user_request, err->request, 0, 1); - httpReplySwapOut(rep, entry); + rep->swapOut(entry); EBIT_CLR(entry->flags, ENTRY_FWD_HDR_WAIT); storeBufferFlush(entry); entry->complete(); @@ -424,9 +424,9 @@ errorSend(int fd, ErrorState * err) rep = errorBuildReply(err); - comm_old_write_mbuf(fd, httpReplyPack(rep), errorSendComplete, err); + comm_old_write_mbuf(fd, rep->pack(), errorSendComplete, err); - httpReplyDestroy(rep); + delete rep; } /* @@ -839,14 +839,14 @@ errorConvert(char token, ErrorState * err) HttpReply * errorBuildReply(ErrorState * err) { - HttpReply *rep = httpReplyCreate(); + HttpReply *rep = new HttpReply; const char *name = errorPageName(err->page_id); /* no LMT for error pages; error pages expire immediately */ HttpVersion version(1, 0); if (strchr(name, ':')) { /* Redirection */ - httpReplySetHeaders(rep, version, HTTP_MOVED_TEMPORARILY, NULL, "text/html", 0, 0, squid_curtime); + rep->setHeaders(version, HTTP_MOVED_TEMPORARILY, NULL, "text/html", 0, 0, squid_curtime); if (err->request) { char *quoted_url = rfc1738_escape_part(urlCanonical(err->request)); @@ -856,7 +856,7 @@ errorBuildReply(ErrorState * err) httpHeaderPutStrf(&rep->header, HDR_X_SQUID_ERROR, "%d %s\n", err->httpStatus, "Access Denied"); } else { MemBuf *content = errorBuildContent(err); - httpReplySetHeaders(rep, version, err->httpStatus, NULL, "text/html", content->contentSize(), 0, squid_curtime); + rep->setHeaders(version, err->httpStatus, NULL, "text/html", content->contentSize(), 0, squid_curtime); /* * include some information for downstream caches. Implicit * replaceable content. This isn't quite sufficient. xerrno is not diff --git a/src/ftp.cc b/src/ftp.cc index ac3c0f6f05..d3778c91de 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -1,6 +1,6 @@ /* - * $Id: ftp.cc,v 1.372 2005/10/18 19:10:29 serassio Exp $ + * $Id: ftp.cc,v 1.373 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 9 File Transfer Protocol (FTP) * AUTHOR: Harvest Derived @@ -1431,14 +1431,14 @@ ftpStart(FwdState * fwd) } /* create reply */ - reply = httpReplyCreate (); + reply = new HttpReply; assert(reply != NULL); /* create appropriate reply */ ftpAuthRequired(reply, request, realm); - httpReplySwapOut(reply, entry); + reply->swapOut(entry); fwdComplete(ftpState->fwd); @@ -3061,7 +3061,7 @@ ftpAppendSuccessHeader(FtpStateData * ftpState) const char *filename = NULL; const char *t = NULL; StoreEntry *e = ftpState->entry; - HttpReply *reply = httpReplyCreate (); + HttpReply *reply = new HttpReply; if (ftpState->flags.http_header_sent) return; @@ -3097,7 +3097,6 @@ ftpAppendSuccessHeader(FtpStateData * ftpState) } } - reply = httpReplyCreate(); /* set standard stuff */ if (ftpState->restarted_offset) { @@ -3106,21 +3105,21 @@ ftpAppendSuccessHeader(FtpStateData * ftpState) range_spec.offset = ftpState->restarted_offset; range_spec.length = ftpState->size - ftpState->restarted_offset; HttpVersion version(1, 0); - httpReplySetHeaders(reply, version, HTTP_PARTIAL_CONTENT, "Gatewaying", - mime_type, ftpState->size - ftpState->restarted_offset, ftpState->mdtm, -2); + reply->setHeaders(version, HTTP_PARTIAL_CONTENT, "Gatewaying", + mime_type, ftpState->size - ftpState->restarted_offset, ftpState->mdtm, -2); httpHeaderAddContRange(&reply->header, range_spec, ftpState->size); } else { /* Full reply */ HttpVersion version(1, 0); - httpReplySetHeaders(reply, version, HTTP_OK, "Gatewaying", - mime_type, ftpState->size, ftpState->mdtm, -2); + reply->setHeaders(version, HTTP_OK, "Gatewaying", + mime_type, ftpState->size, ftpState->mdtm, -2); } /* additional info */ if (mime_enc) httpHeaderPutStr(&reply->header, HDR_CONTENT_ENCODING, mime_enc); - httpReplySwapOut(reply, e); + reply->swapOut(e); storeTimestampsSet(e); @@ -3147,7 +3146,7 @@ ftpAuthRequired(HttpReply * old_reply, HttpRequest * request, const char *realm) /* add Authenticate header */ httpHeaderPutAuth(&rep->header, "Basic", realm); /* move new reply to the old one */ - httpReplyAbsorb(old_reply, rep); + old_reply->absorb(rep); } char * diff --git a/src/http.cc b/src/http.cc index 5e5715d9c7..7a7b387542 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.464 2005/11/04 20:27:31 wessels Exp $ + * $Id: http.cc,v 1.465 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -653,7 +653,7 @@ HttpStateData::processReplyHeader(const char *buf, int size) /* Creates a blank header. If this routine is made incremental, this will * not do */ - HttpReply *reply = httpReplyCreate(); + HttpReply *reply = new HttpReply; Ctx ctx = ctx_enter(entry->mem_obj->url); debug(11, 3) ("processReplyHeader: key '%s'\n", entry->getMD5Text()); @@ -701,7 +701,7 @@ HttpStateData::processReplyHeader(const char *buf, int size) if (eof) hdr_size = hdr_len; else { - httpReplyDestroy(reply); + delete reply; ctx_exit(ctx); return; /* headers not complete */ } @@ -719,7 +719,7 @@ HttpStateData::processReplyHeader(const char *buf, int size) /* Parse headers into reply structure */ /* what happens if we fail to parse here? */ - httpReplyParse(reply, reply_hdr.buf, hdr_size); + reply->parse(reply_hdr.buf, hdr_size); if (reply->sline.status >= HTTP_INVALID_HEADER) { debugs(11, 3, "processReplyHeader: Non-HTTP-compliant header: '" << reply_hdr.buf << "'"); @@ -811,7 +811,7 @@ no_cache: if (_peer) _peer->stats.n_keepalives_recv++; - if (Config.onoff.detect_broken_server_pconns && httpReplyBodySize(request->method, reply) == -1) { + if (Config.onoff.detect_broken_server_pconns && reply->bodySize(request->method) == -1) { debug(11, 1) ("processReplyHeader: Impossible keep-alive header from '%s'\n", storeUrl(entry)); debug(11, 2) ("GOT HTTP REPLY HDR:\n---------\n%s\n----------\n", reply_hdr.buf); flags.keepalive_broken = 1; @@ -896,7 +896,7 @@ HttpStateData::persistentConnStatus() const if (!flags.headers_parsed) return INCOMPLETE_MSG; - clen = httpReplyBodySize(request->method, reply); + clen = reply->bodySize(request->method); /* If there is no message body, we can be persistent */ if (0 == clen) diff --git a/src/internal.cc b/src/internal.cc index 108d87b2b6..b59b5991df 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -1,6 +1,6 @@ /* - * $Id: internal.cc,v 1.33 2005/09/17 05:50:08 wessels Exp $ + * $Id: internal.cc,v 1.34 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 76 Internal Squid Object handling * AUTHOR: Duane, Alex, Henrik @@ -62,16 +62,15 @@ internalStart(HttpRequest * request, StoreEntry * entry) #endif HttpVersion version(1, 0); - HttpReply *reply = httpReplyCreate (); - httpReplySetHeaders(reply, - version, - HTTP_NOT_FOUND, - "Not Found", - "text/plain", - strlen(msgbuf), - squid_curtime, - -2); - httpReplySwapOut(reply, entry); + HttpReply *reply = new HttpReply; + reply->setHeaders(version, + HTTP_NOT_FOUND, + "Not Found", + "text/plain", + strlen(msgbuf), + squid_curtime, + -2); + reply->swapOut(entry); storeAppend(entry, msgbuf, strlen(msgbuf)); entry->complete(); } else { diff --git a/src/mime.cc b/src/mime.cc index e302ae0c4e..affa8f536b 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -1,6 +1,6 @@ /* - * $Id: mime.cc,v 1.119 2005/09/17 05:50:08 wessels Exp $ + * $Id: mime.cc,v 1.120 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 25 MIME Parsing * AUTHOR: Harvest Derived @@ -607,12 +607,12 @@ MimeIcon::created (StoreEntry *newEntry) e->mem_obj->request = requestLink(r); - HttpReply *reply = httpReplyCreate(); + HttpReply *reply = new HttpReply; HttpVersion version(1, 0); - httpReplySetHeaders(reply, version, HTTP_OK, NULL, - mimeGetContentType(icon), (int) sb.st_size, sb.st_mtime, -1); + reply->setHeaders(version, HTTP_OK, NULL, + mimeGetContentType(icon), (int) sb.st_size, sb.st_mtime, -1); reply->cache_control = httpHdrCcCreate(); @@ -620,7 +620,7 @@ MimeIcon::created (StoreEntry *newEntry) httpHeaderPutCc(&reply->header, reply->cache_control); - httpReplySwapOut(reply, e); + reply->swapOut(e); /* read the file into the buffer and append it to store */ buf = (char *)memAllocate(MEM_4K_BUF); diff --git a/src/net_db.cc b/src/net_db.cc index ea3a05b3ca..c1959dd9e5 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -1,6 +1,6 @@ /* - * $Id: net_db.cc,v 1.177 2005/07/03 15:25:08 serassio Exp $ + * $Id: net_db.cc,v 1.178 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 38 Network Measurement Database * AUTHOR: Duane Wessels @@ -1197,7 +1197,7 @@ netdbDeleteAddrNetwork(struct IN_ADDR addr) void netdbBinaryExchange(StoreEntry * s) { - HttpReply *reply = httpReplyCreate(); + HttpReply *reply = new HttpReply; #if USE_ICMP netdbEntry *n; @@ -1209,9 +1209,8 @@ netdbBinaryExchange(StoreEntry * s) struct IN_ADDR addr; storeBuffer(s); HttpVersion version(1, 0); - httpReplySetHeaders(reply, version, HTTP_OK, "OK", - NULL, -1, squid_curtime, -2); - httpReplySwapOut(reply, s); + reply->setHeaders(version, HTTP_OK, "OK", NULL, -1, squid_curtime, -2); + reply->SwapOut(s); rec_sz = 0; rec_sz += 1 + sizeof(addr.s_addr); rec_sz += 1 + sizeof(int); @@ -1269,9 +1268,9 @@ netdbBinaryExchange(StoreEntry * s) #else HttpVersion version(1,0); - httpReplySetHeaders(reply, version, HTTP_BAD_REQUEST, "Bad Request", - NULL, -1, squid_curtime, -2); - httpReplySwapOut(reply, s); + reply->setHeaders(version, HTTP_BAD_REQUEST, "Bad Request", + NULL, -1, squid_curtime, -2); + reply->swapOut(s); storeAppendPrintf(s, "NETDB support not compiled into this Squid cache.\n"); #endif diff --git a/src/peer_digest.cc b/src/peer_digest.cc index adaa0e0fb9..f154549ea5 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: peer_digest.cc,v 1.104 2005/09/15 19:22:30 wessels Exp $ + * $Id: peer_digest.cc,v 1.105 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 72 Peer Digest Routines * AUTHOR: Alex Rousskov @@ -545,7 +545,7 @@ peerDigestFetchReply(void *data, char *buf, ssize_t size) HttpReply *old_rep = (HttpReply *) fetch->old_entry->getReply(); - old_rep->httpReplyUpdateOnNotModified(reply); + old_rep->updateOnNotModified(reply); storeTimestampsSet(fetch->old_entry); diff --git a/src/store.cc b/src/store.cc index 47e7f7d7fd..8f290cc650 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.579 2005/09/10 19:31:31 serassio Exp $ + * $Id: store.cc,v 1.580 2005/11/05 00:08:32 wessels Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -667,7 +667,8 @@ storeSetPublicKey(StoreEntry * e) pe = storeCreateEntry(mem->url, mem->log_url, request->flags, request->method); HttpVersion version(1, 0); /* We are allowed to do this typecast */ - httpReplySetHeaders((HttpReply *)pe->getReply(), version, HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000); + HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const + rep->setHeaders(version, HTTP_OK, "Internal marker object", "x-squid-internal/vary", -1, -1, squid_curtime + 100000); vary = httpHeaderGetList(&mem->getReply()->header, HDR_VARY); if (vary.size()) { @@ -694,7 +695,7 @@ storeSetPublicKey(StoreEntry * e) { Packer p; packerToStoreInit(&p, pe); - httpReplyPackHeadersInto(pe->getReply(), &p); + pe->getReply()->packHeadersInto(&p); packerClean(&p); } @@ -1668,7 +1669,8 @@ storeEntryReset(StoreEntry * e) assert (mem); debug(20, 3) ("storeEntryReset: %s\n", storeUrl(e)); mem->reset(); - httpReplyReset((HttpReply *)e->getReply()); + HttpReply *rep = (HttpReply *) e->getReply(); // bypass const + rep->reset(); e->expires = e->lastmod = e->timestamp = -1; } @@ -1769,7 +1771,7 @@ storeEntryReplaceObject(StoreEntry * e, HttpReply * rep) myrep = (HttpReply *)e->getReply(); /* we are allowed to do this */ /* move info to the mem_obj->reply */ - httpReplyAbsorb(myrep, rep); + myrep->absorb(rep); /* TODO: when we store headers serparately remove the header portion */ /* TODO: mark the length of the headers ? */ @@ -1778,7 +1780,7 @@ storeEntryReplaceObject(StoreEntry * e, HttpReply * rep) assert (e->isEmpty()); - httpReplyPackHeadersInto(e->getReply(), &p); + e->getReply()->packHeadersInto(&p); myrep->hdr_sz = e->mem_obj->endOffset(); diff --git a/src/store_client.cc b/src/store_client.cc index 64ebdf45ef..9bf06f82eb 100644 --- a/src/store_client.cc +++ b/src/store_client.cc @@ -1,6 +1,6 @@ /* - * $Id: store_client.cc,v 1.142 2005/09/30 22:24:21 wessels Exp $ + * $Id: store_client.cc,v 1.143 2005/11/05 00:08:33 wessels Exp $ * * DEBUG: section 90 Storage Manager Client-Side Interface * AUTHOR: Duane Wessels @@ -477,11 +477,14 @@ storeClientReadBody(void *data, const char *buf, ssize_t len) assert(sc->_callback.pending()); debug(90, 3)("storeClientReadBody: len %d", (int) len); - if (sc->copyInto.offset == 0 && len > 0 && sc->entry->getReply()->sline.status == 0) + if (sc->copyInto.offset == 0 && len > 0 && sc->entry->getReply()->sline.status == 0) { /* Our structure ! */ - if (!httpReplyParse((HttpReply *)sc->entry->getReply(), sc->copyInto.data, headersEnd(sc->copyInto.data, len))) { + HttpReply *rep = (HttpReply *) sc->entry->getReply(); // bypass const + + if (!rep->parse(sc->copyInto.data, headersEnd(sc->copyInto.data, len))) { debug (90,0)("Could not parse headers from on disk object\n"); } + } sc->callback(len); } @@ -585,12 +588,14 @@ store_client::readHeader(char const *buf, ssize_t len) (int) copy_sz); xmemmove(copyInto.data, copyInto.data + mem->swap_hdr_sz, copy_sz); - if (copyInto.offset == 0 && len > 0 && entry->getReply()->sline.status == 0) + if (copyInto.offset == 0 && len > 0 && entry->getReply()->sline.status == 0) { /* Our structure ! */ - if (!httpReplyParse((HttpReply *)entry->getReply(), copyInto.data, - headersEnd(copyInto.data, copy_sz))) { + HttpReply *rep = (HttpReply *) entry->getReply(); // bypass const + + if (!rep->parse(copyInto.data, headersEnd(copyInto.data, copy_sz))) { debug (90,0)("could not parse headers from on disk structure!\n"); } + } callback(copy_sz); return; diff --git a/src/store_digest.cc b/src/store_digest.cc index 50c21b5d34..85f823647d 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: store_digest.cc,v 1.59 2005/01/03 16:08:26 robertc Exp $ + * $Id: store_digest.cc,v 1.60 2005/11/05 00:08:33 wessels Exp $ * * DEBUG: section 71 Store Digest Manager * AUTHOR: Alex Rousskov @@ -422,15 +422,15 @@ storeDigestRewriteResume(void) /* setting public key will purge old digest entry if any */ storeSetPublicKey(e); /* fake reply */ - HttpReply *rep = httpReplyCreate (); + HttpReply *rep = new HttpReply; HttpVersion version(1, 0); - httpReplySetHeaders(rep, version, HTTP_OK, "Cache Digest OK", - "application/cache-digest", store_digest->mask_size + sizeof(sd_state.cblock), - squid_curtime, squid_curtime + Config.digest.rewrite_period); + rep->setHeaders(version, HTTP_OK, "Cache Digest OK", + "application/cache-digest", store_digest->mask_size + sizeof(sd_state.cblock), + squid_curtime, squid_curtime + Config.digest.rewrite_period); debug(71, 3) ("storeDigestRewrite: entry expires on %ld (%+d)\n", (long int) rep->expires, (int) (rep->expires - squid_curtime)); storeBuffer(e); - httpReplySwapOut(rep, e); + rep->swapOut(e); storeDigestCBlockSwapOut(e); storeBufferFlush(e); eventAdd("storeDigestSwapOutStep", storeDigestSwapOutStep, sd_state.rewrite_lock, 0.0, 1); diff --git a/src/urn.cc b/src/urn.cc index 136b92a616..7ce0c261eb 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -1,6 +1,6 @@ /* - * $Id: urn.cc,v 1.90 2005/09/17 05:50:08 wessels Exp $ + * $Id: urn.cc,v 1.91 2005/11/05 00:08:33 wessels Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -367,8 +367,8 @@ urnHandleReply(void *data, StoreIOBuffer result) s = buf + k; assert(urlres_e->getReply()); - rep = httpReplyCreate (); - httpReplyParse(rep, buf, k); + rep = new HttpReply; + rep->parse(buf, k); debug(52, 3) ("reply exists, code=%d.\n", rep->sline.status); @@ -378,11 +378,11 @@ urnHandleReply(void *data, StoreIOBuffer result) err->request = requestLink(urnState->request); err->url = xstrdup(storeUrl(e)); errorAppendEntry(e, err); - httpReplyDestroy(rep); + delete rep; goto error; } - httpReplyDestroy(rep); + delete rep; while (xisspace(*s)) s++; @@ -436,9 +436,9 @@ urnHandleReply(void *data, StoreIOBuffer result) "Generated by %s@%s\n" "\n", full_appname_string, getMyHostname()); - rep = httpReplyCreate(); - httpReplySetHeaders(rep, version, HTTP_MOVED_TEMPORARILY, NULL, - "text/html", mb->contentSize(), 0, squid_curtime); + rep = new HttpReply; + rep->setHeaders(version, HTTP_MOVED_TEMPORARILY, NULL, + "text/html", mb->contentSize(), 0, squid_curtime); if (urnState->flags.force_menu) { debug(51, 3) ("urnHandleReply: forcing menu\n"); @@ -448,7 +448,7 @@ urnHandleReply(void *data, StoreIOBuffer result) httpBodySet(&rep->body, mb); /* don't clean or delete mb; rep->body owns it now */ - httpReplySwapOut(rep, e); + rep->swapOut(e); e->complete(); for (i = 0; i < urlcnt; i++) { diff --git a/src/whois.cc b/src/whois.cc index a3e29bc03d..52ef50ac55 100644 --- a/src/whois.cc +++ b/src/whois.cc @@ -1,6 +1,6 @@ /* - * $Id: whois.cc,v 1.30 2005/09/10 19:31:31 serassio Exp $ + * $Id: whois.cc,v 1.31 2005/11/05 00:08:33 wessels Exp $ * * DEBUG: section 75 WHOIS protocol * AUTHOR: Duane Wessels, Kostas Anagnostakis @@ -112,10 +112,10 @@ whoisReadReply(int fd, char *buf, size_t len, comm_err_t flag, int xerrno, void void WhoisState::setReplyToOK(StoreEntry *entry) { - HttpReply *reply = httpReplyCreate(); + HttpReply *reply = new HttpReply; storeBuffer(entry); HttpVersion version(1, 0); - httpReplySetHeaders(reply, version, HTTP_OK, "Gatewaying", "text/plain", -1, -1, -2); + reply->setHeaders(version, HTTP_OK, "Gatewaying", "text/plain", -1, -1, -2); storeEntryReplaceObject (entry, reply); } -- 2.47.2