From: rousskov <> Date: Fri, 17 Jul 1998 10:49:59 +0000 (+0000) Subject: - added debugObj(); same as debug() put prints "objects" that have an objPack() X-Git-Tag: SQUID_3_0_PRE1~3057 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a00a7c85e8bb1ed7d76fc0f611d22d82ca80e105;p=thirdparty%2Fsquid.git - added debugObj(); same as debug() put prints "objects" that have an objPack() method --- diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 736392d10f..0607704ab4 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.cc,v 1.8 1998/07/02 17:39:41 wessels Exp $ + * $Id: HttpRequest.cc,v 1.9 1998/07/17 04:49:59 rousskov Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -94,23 +94,29 @@ httpRequestParseHeader(request_t * req, const char *parse_start) return httpHeaderParse(&req->header, blk_start, blk_end); } -/* swaps out request-line and headers, appends terminator */ +/* swaps out request using httpRequestPack */ void httpRequestSwapOut(const request_t * req, StoreEntry * e) { + Packer p; assert(req && e); - /* store request-line */ - storeAppendPrintf(e, "%s %s HTTP/1.0\r\n", + packerToStoreInit(&p, e); + httpRequestPack(req, &p); + packerClean(&p); +} + +/* packs request-line and headers, appends terminator */ +void +httpRequestPack(const request_t * req, Packer *p) +{ + assert(req && p); + /* pack request-line */ + packerPrintf(p, "%s %s HTTP/1.0\r\n", RequestMethodStr[req->method], strBuf(req->urlpath)); - /* store headers */ - { - Packer p; - packerToStoreInit(&p, e); - httpHeaderPackInto(&req->header, &p); - packerClean(&p); - } + /* headers */ + httpHeaderPackInto(&req->header, p); /* trailer */ - storeAppend(e, "\r\n", 2); + packerAppend(p, "\r\n", 2); } #if UNUSED_CODE diff --git a/src/internal.cc b/src/internal.cc index e61f519929..ebafb462fb 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -16,6 +16,7 @@ internalStart(request_t * request, StoreEntry * entry) netdbBinaryExchange(entry); else { debug(0, 0) ("internalStart: unknown request '%s'\n", upath); + debugObj(0,0, request, &httpRequestPack); err = errorCon(ERR_INVALID_REQ, HTTP_NOT_FOUND); err->request = requestLink(request); errorAppendEntry(entry, err); diff --git a/src/protos.h b/src/protos.h index 4a61c503ab..66a6549be7 100644 --- a/src/protos.h +++ b/src/protos.h @@ -424,6 +424,7 @@ 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); @@ -1015,6 +1016,8 @@ extern void carpInit(void); extern peer * carpSelectParent(request_t *); #endif +/* packs, then prints an object using debug() */ +extern void debugObj(int section, int level, void *obj, void (*packMeth)(void *obj, Packer *p)); /* * prototypes for system functions missing from system includes diff --git a/src/tools.cc b/src/tools.cc index c2437397ff..e3f853b8b2 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -1,6 +1,6 @@ /* - * $Id: tools.cc,v 1.158 1998/06/08 17:29:21 wessels Exp $ + * $Id: tools.cc,v 1.159 1998/07/17 04:50:01 rousskov Exp $ * * DEBUG: section 21 Misc Functions * AUTHOR: Harvest Derived @@ -895,3 +895,17 @@ gb_to_str(const gb_t * g) snprintf(buf, sizeof(GbBuf), "%.2f TB", value / 1e12); return buf; } + +void +debugObj(int section, int level, void *obj, void (*packMeth)(void *obj, Packer *p)) +{ + MemBuf mb; + Packer p; + assert(obj); + memBufDefInit(&mb); + packerToMemInit(&p, &mb); + (*packMeth)(obj, &p); + debug(section, level) ("%s", mb.buf); + packerClean(&p); + memBufClean(&mb); +}