/*
- * $Id: CacheDigest.cc,v 1.23 1998/07/20 17:18:59 wessels Exp $
+ * $Id: CacheDigest.cc,v 1.24 1998/07/20 19:25:28 wessels Exp $
*
* DEBUG: section 70 Cache Digest
* AUTHOR: Alex Rousskov
return (size_t) (cap * bpe + 7) / 8;
}
-#if OLD_CODE
- /*
- * This has byte-order bugs
- */
-static void
-cacheDigestHashKey(const CacheDigest * cd, const cache_key * key)
-{
- const int bit_count = cd->mask_size * 8;
- /* get four hashed values */
- memcpy(hashed_keys, key, sizeof(hashed_keys));
- /* wrap */
- hashed_keys[0] %= bit_count;
- hashed_keys[1] %= bit_count;
- hashed_keys[2] %= bit_count;
- hashed_keys[3] %= bit_count;
- debug(70, 9) ("cacheDigestHashKey: %s -(%d)-> %d %d %d %d\n",
- storeKeyText(key), bit_count, hashed_keys[0], hashed_keys[1], hashed_keys[2], hashed_keys[3]);
-}
-#endif
-
static void
cacheDigestHashKey(const CacheDigest * cd, const cache_key * key)
{
/*
- * $Id: HttpReply.cc,v 1.27 1998/07/20 17:19:07 wessels Exp $
+ * $Id: HttpReply.cc,v 1.28 1998/07/20 19:26:48 wessels Exp $
*
* DEBUG: section 58 HTTP Reply (Response)
* AUTHOR: Alex Rousskov
void
httpReplyUpdateOnNotModified(HttpReply * rep, HttpReply * freshRep)
{
-#if OLD_CODE
- rep->cache_control = freshRep->cache_control;
- rep->misc_headers = freshRep->misc_headers;
- if (freshRep->date > -1)
- rep->date = freshRep->date;
- if (freshRep->last_modified > -1)
- rep->last_modified = freshRep->last_modified;
- if (freshRep->expires > -1)
- rep->expires = freshRep->expires;
-#endif
assert(rep && freshRep);
/* clean cache */
httpReplyHdrCacheClean(rep);
/*
- * $Id: HttpRequest.cc,v 1.11 1998/07/20 19:19:47 wessels Exp $
+ * $Id: HttpRequest.cc,v 1.12 1998/07/20 19:26:49 wessels Exp $
*
* DEBUG: section 73 HTTP Request
* AUTHOR: Duane Wessels
void
httpRequestSetHeaders(request_t * req, method_t method, const char *uri, const char *header_str)
{
-#if OLD_CODE
- MemBuf mb;
- assert(req && uri && header_str);
- assert(!req->prefix);
-
- memBufDefInit(&mb);
- memBufPrintf(&mb, "%s %s HTTP/%3.1f\r\n%s\r\n",
- RequestMethodStr[method], uri, req->http_ver, header_str);
- req->prefix = xstrdup(mb.buf);
- req->prefix_sz = mb.size;
- memBufClean(&mb);
-#else
assert(req && uri && header_str);
assert(!req->header.len);
-#endif
httpHeaderParse(&req->header, header_str, header_str + strlen(header_str));
}
/*
- * $Id: asn.cc,v 1.41 1998/07/20 17:19:18 wessels Exp $
+ * $Id: asn.cc,v 1.42 1998/07/20 19:25:29 wessels Exp $
*
* DEBUG: section 53 AS Number handling
* AUTHOR: Duane Wessels, Kostas Anagnostakis
req = urlParse(METHOD_GET, asres);
assert(NULL != req);
asState->request = requestLink(req);
-#if OLD_CODE
- asState->request->headers = xstrdup("\r\n");
- asState->request->headers_sz = strlen(asState->request->headers);
-#endif
if ((e = storeGet(k)) == NULL) {
e = storeCreateEntry(asres, asres, 0, METHOD_GET);
storeClientListAdd(e, asState);
/*
- * $Id: cache_manager.cc,v 1.13 1998/07/20 17:19:22 wessels Exp $
+ * $Id: cache_manager.cc,v 1.14 1998/07/20 19:25:30 wessels Exp $
*
* DEBUG: section 16 Cache Manager Objects
* AUTHOR: Duane Wessels
const char *basic_cookie; /* base 64 _decoded_ user:passwd pair */
const char *passwd_del;
assert(mgr && request);
-#if OLD_CODE
- const char *authField;
- /* this parsing will go away when hdrs are added to request_t @?@ */
- basic_cookie = mime_get_auth(request->headers, "Basic", &authField);
- debug(16, 9) ("cachemgrParseHeaders: got auth: '%s'\n", authField ? authField : "<none>");
- if (!authField)
- return;
- if (!basic_cookie) {
- debug(16, 1) ("cachemgrParseHeaders: unknown auth format in '%s'\n", authField);
- return;
- }
-#else
basic_cookie = httpHeaderGetAuth(&request->header, HDR_AUTHORIZATION, "Basic");
if (!basic_cookie)
return;
-#endif
if (!(passwd_del = strchr(basic_cookie, ':'))) {
debug(16, 1) ("cachemgrParseHeaders: unknown basic_cookie format '%s'\n", basic_cookie);
return;
/*
- * $Id: ftp.cc,v 1.235 1998/07/20 17:19:41 wessels Exp $
+ * $Id: ftp.cc,v 1.236 1998/07/20 19:25:31 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
static wordlist *ftpParseControlReply(char *, size_t, int *, int *);
static void ftpAppendSuccessHeader(FtpStateData * ftpState);
static void ftpAuthRequired(HttpReply * reply, request_t * request, const char *realm);
-#if OLD_CODE
-static STABH ftpAbort;
-#endif
static void ftpHackShortcut(FtpStateData * ftpState, FTPSM * nextState);
static void ftpPutStart(FtpStateData *);
static CWCB ftpPutTransferDone;
if (ftpState->password[0])
return 1; /* passwd with no name? */
/* URL has name, but no passwd */
-#if OLD_CODE
- if (!(auth = mime_get_auth(req_hdr, "Basic", NULL)))
-#else
if (!(auth = httpHeaderGetAuth(req_hdr, HDR_AUTHORIZATION, "Basic")))
-#endif
return 0; /* need auth header */
orig_user = xstrdup(ftpState->user);
ftpLoginParser(auth, ftpState);
ftpState->request->host, strBuf(ftpState->request->urlpath),
ftpState->user, ftpState->password);
comm_add_close_handler(fd, ftpStateFree, ftpState);
-#if OLD_CODE
- storeRegisterAbort(entry, ftpAbort, ftpState);
-#endif
ftpState->state = BEGIN;
ftpState->ctrl.buf = memAllocate(MEM_4K_BUF);
ftpState->ctrl.freefunc = memFree4K;
storeSetPublicKey(e);
}
-#if OLD_CODE
-static void
-ftpAbort(void *data)
-{
- FtpStateData *ftpState = data;
- debug(9, 2) ("ftpAbort: %s\n", storeUrl(ftpState->entry));
- if (ftpState->data.fd >= 0) {
- comm_close(ftpState->data.fd);
- ftpState->data.fd = -1;
- }
- comm_close(ftpState->ctrl.fd);
-}
-#endif
-
static void
ftpAuthRequired(HttpReply * old_reply, request_t * request, const char *realm)
{
/*
- * $Id: gopher.cc,v 1.131 1998/07/20 17:19:42 wessels Exp $
+ * $Id: gopher.cc,v 1.132 1998/07/20 19:25:32 wessels Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
static CWCB gopherSendComplete;
static PF gopherSendRequest;
static GopherStateData *CreateGopherStateData(void);
-#if OLD_CODE
-static STABH gopherAbort;
-#endif
static char def_gopher_bin[] = "www/unknown";
static char def_gopher_text[] = "text/plain";
if (gopherState == NULL)
return;
if (gopherState->entry) {
-#if OLD_CODE
- storeUnregisterAbort(gopherState->entry);
-#endif
storeUnlockObject(gopherState->entry);
}
memFree(MEM_4K_BUF, gopherState->buf);
return;
}
comm_add_close_handler(fd, gopherStateFree, gopherState);
-#if OLD_CODE
- storeRegisterAbort(entry, gopherAbort, gopherState);
-#endif
if (((gopherState->type_id == GOPHER_INDEX) || (gopherState->type_id == GOPHER_CSO))
&& (strchr(gopherState->request, '?') == NULL)) {
/* Index URL without query word */
gd->buf = memAllocate(MEM_4K_BUF);
return (gd);
}
-
-#if OLD_CODE
-static void
-gopherAbort(void *data)
-{
- GopherStateData *gopherState = data;
- debug(10, 1) ("gopherAbort: %s\n", storeUrl(gopherState->entry));
- comm_close(gopherState->fd);
-}
-#endif
/*
- * $Id: http.cc,v 1.296 1998/07/20 17:19:45 wessels Exp $
+ * $Id: http.cc,v 1.297 1998/07/20 19:25:34 wessels Exp $
*
* DEBUG: section 11 Hypertext Transfer Protocol (HTTP)
* AUTHOR: Harvest Derived
static PF httpSendRequest;
static PF httpStateFree;
static PF httpTimeout;
-#if OLD_CODE
-static void httpAppendRequestHeader(char *hdr, const char *line, size_t * sz, size_t max, int);
-#endif
static void httpCacheNegatively(StoreEntry *);
static void httpMakePrivate(StoreEntry *);
static void httpMakePublic(StoreEntry *);
HttpStateData *httpState = data;
if (httpState == NULL)
return;
-#if OLD_CODE
- storeUnregisterAbort(httpState->entry);
-#endif
storeUnlockObject(httpState->entry);
if (httpState->reply_hdr) {
memFree(MEM_8K_BUF, httpState->reply_hdr);
}
}
-#if OLD_CODE
-static void
-httpAppendRequestHeader(char *hdr, const char *line, size_t * sz, size_t max, int check)
-{
- size_t n = *sz + strlen(line) + 2;
- if (n >= max)
- return;
- if (check) {
- if (Config.onoff.anonymizer == ANONYMIZER_PARANOID) {
- if (!httpAnonAllowed(line))
- return;
- } else if (Config.onoff.anonymizer == ANONYMIZER_STANDARD) {
- if (httpAnonDenied(line))
- return;
- }
- }
- /* allowed header, explicitly known to be not dangerous */
- debug(11, 5) ("httpAppendRequestHeader: %s\n", line);
- strcpy(hdr + (*sz), line);
- strcat(hdr + (*sz), crlf);
- *sz = n;
-}
-#endif
-
/*
* build request headers and append them to a given MemBuf
* used by httpBuildRequestPrefix()
int filter_range;
const HttpHeaderEntry *e;
HttpHeaderPos pos = HttpHeaderInitPos;
-
-#if OLD_CODE
- assert(orig_request->prefix != NULL);
- debug(11, 3) ("httpBuildRequestHeader:\n%s", orig_request->prefix);
-#endif
httpHeaderInit(hdr_out, hoRequest);
-
/* append our IMS header */
if (entry && entry->lastmod > -1 && request->method == METHOD_GET)
httpHeaderPutTime(hdr_out, HDR_IF_MODIFIED_SINCE, entry->lastmod);
header.opcode, inet_ntoa(from.sin_addr));
break;
}
- if (icp_request) {
-#if OLD_CODE
- stringClean(&icp_request->urlpath);
- memFree(MEM_REQUEST_T, icp_request);
-#else
+ if (icp_request)
requestDestroy(icp_request);
-#endif
- }
}
#ifdef ICP_PKT_DUMP
header.opcode, inet_ntoa(from.sin_addr));
break;
}
- if (icp_request) {
-#if OLD_CODE
- stringClean(&icp_request->urlpath);
- memFree(MEM_REQUEST_T, icp_request);
-#else
+ if (icp_request)
requestDestroy(icp_request);
-#endif
- }
}
/*
- * $Id: net_db.cc,v 1.117 1998/07/20 17:19:56 wessels Exp $
+ * $Id: net_db.cc,v 1.118 1998/07/20 19:25:36 wessels Exp $
*
* DEBUG: section 37 Network Measurement Database
* AUTHOR: Duane Wessels
}
requestLink(ex->r);
assert(NULL != ex->r);
-#if OLD_CODE
- ex->r->headers = xstrdup("\r\n");
- ex->r->headers_sz = strlen(ex->r->headers);
-#endif
ex->r->http_ver = 1.0;
ex->e = storeCreateEntry(uri, uri, 0, METHOD_GET);
ex->buf_sz = 4096;;
/*
- * $Id: peer_digest.cc,v 1.41 1998/07/20 17:19:58 wessels Exp $
+ * $Id: peer_digest.cc,v 1.42 1998/07/20 19:25:37 wessels Exp $
*
* DEBUG: section 72 Peer Digest Routines
* AUTHOR: Alex Rousskov
requestLink(req);
assert(req);
/* add custom headers */
-#if OLD_CODE
- /* rewrite this when requests get rid of "prefix" */
- assert(!req->prefix);
- {
- MemBuf mb;
- memBufDefInit(&mb);
- memBufPrintf(&mb, "Accept: %s,text/html\r\n", StoreDigestMimeStr);
- httpRequestSetHeaders(req, METHOD_GET, url, mb.buf);
- memBufClean(&mb);
- }
-#else
assert(!req->header.len);
httpHeaderPutStr(&req->header, HDR_ACCEPT, StoreDigestMimeStr);
httpHeaderPutStr(&req->header, HDR_ACCEPT, "text/html");
-#endif
/* create fetch state structure */
fetch = memAllocate(MEM_DIGEST_FETCH_STATE);
cbdataAdd(fetch, MEM_DIGEST_FETCH_STATE);
extern char *mime_get_header(const char *mime, const char *header);
extern char *mime_get_header_field(const char *mime, const char *name, const char *prefix);
-#if OLD_CODE
-extern char *mime_headers_end(const char *mime);
-#endif
extern size_t headersEnd(const char *, size_t);
extern const char *mime_get_auth(const char *hdr, const char *auth_scheme, const char **auth_field);
/*
- * $Id: store_dir.cc,v 1.72 1998/07/20 17:20:16 wessels Exp $
+ * $Id: store_dir.cc,v 1.73 1998/07/20 19:25:40 wessels Exp $
*
* DEBUG: section 47 Store Directory Routines
* AUTHOR: Duane Wessels
}
}
-#if OLD_CODE
-static int
-storeMostFreeSwapDir(void)
-{
- double least_used = 1.0;
- double this_used;
- int dirn = 0;
- int i;
- SwapDir *SD;
- for (i = 0; i < Config.cacheSwap.n_configured; i++) {
- SD = &Config.cacheSwap.swapDirs[i];
- this_used = (double) SD->cur_size / SD->max_size;
- if (this_used > least_used)
- continue;
- if (SD->read_only)
- continue;
- least_used = this_used;
- dirn = i;
- }
- return dirn;
-}
-#endif
-
/*
*Spread load across least 3/4 of the store directories
*/
/*
- * $Id: url.cc,v 1.101 1998/07/20 17:20:20 wessels Exp $
+ * $Id: url.cc,v 1.102 1998/07/20 19:25:41 wessels Exp $
*
* DEBUG: section 23 URL Parsing
* AUTHOR: Duane Wessels
return buf;
}
-#if OLD_CODE /* moved to HttpRequest.c */
-request_t *
-requestLink(request_t * request)
-{
- request->link_count++;
- return request;
-}
-
-void
-requestUnlink(request_t * request)
-{
- if (request == NULL)
- return;
- request->link_count--;
- if (request->link_count)
- return;
-#if OLD_CODE
- safe_free(request->headers);
-#else
- httpHeaderClean(&request->header);
- safe_free(request->prefix);
-#endif
- safe_free(request->body);
- stringClean(&request->urlpath);
- safe_free(request->canonical);
- memFree(MEM_REQUEST_T, request);
-}
-#endif
-
int
matchDomainName(const char *domain, const char *host)
{
/*
*
- * $Id: urn.cc,v 1.38 1998/07/20 17:20:21 wessels Exp $
+ * $Id: urn.cc,v 1.39 1998/07/20 19:25:42 wessels Exp $
*
* DEBUG: section 52 URN Parsing
* AUTHOR: Kostas Anagnostakis
errorAppendEntry(e, err);
return;
}
-#if OLD_CODE
- urlres_r->headers = xstrdup("Accept: text/plain\r\n\r\n");
- urlres_r->headers_sz = strlen(urlres_r->headers);
-#else
httpHeaderPutStr(&urlres_r->header, HDR_ACCEPT, "text/plain");
-#endif
if ((urlres_e = storeGet(k)) == NULL) {
urlres_e = storeCreateEntry(urlres, urlres, 0, METHOD_GET);
storeClientListAdd(urlres_e, urnState);
/*
- * $Id: wais.cc,v 1.112 1998/07/20 17:20:23 wessels Exp $
+ * $Id: wais.cc,v 1.113 1998/07/20 19:25:43 wessels Exp $
*
* DEBUG: section 24 WAIS Relay
* AUTHOR: Harvest Derived
static PF waisReadReply;
static CWCB waisSendComplete;
static PF waisSendRequest;
-#if OLD_CODE
-static STABH waisAbort;
-#endif
static void
waisStateFree(int fdnotused, void *data)
WaisStateData *waisState = data;
if (waisState == NULL)
return;
-#if OLD_CODE
- storeUnregisterAbort(waisState->entry);
-#endif
storeUnlockObject(waisState->entry);
cbdataFree(waisState);
}
waisSendRequest(int fd, void *data)
{
WaisStateData *waisState = data;
-#if OLD_CODE
- int len = strlen(waisState->request) + 4;
- char *buf = NULL;
-#else
MemBuf mb;
-#endif
const char *Method = RequestMethodStr[waisState->method];
debug(24, 5) ("waisSendRequest: FD %d\n", fd);
-#if OLD_CODE
- if (Method)
- len += strlen(Method);
- if (waisState->request_hdr)
- len += strlen(waisState->request_hdr);
- buf = xcalloc(1, len + 1);
- if (waisState->request_hdr)
- snprintf(buf, len + 1, "%s %s %s\r\n", Method, waisState->request,
- waisState->request_hdr);
- else
- snprintf(buf, len + 1, "%s %s\r\n", Method, waisState->request);
- debug(24, 6) ("waisSendRequest: buf: %s\n", buf);
- comm_write(fd, buf, len, waisSendComplete, waisState, xfree);
-#else
memBufPrintf(&mb, "%s %s", Method, waisState->request);
if (waisState->request_hdr) {
Packer p;
memBufPrintf(&mb, "\r\n");
debug(24, 6) ("waisSendRequest: buf: %s\n", mb.buf);
comm_write_mbuf(fd, mb, waisSendComplete, waisState);
-#endif
if (EBIT_TEST(waisState->entry->flag, ENTRY_CACHABLE))
storeSetPublicKey(waisState->entry); /* Make it public */
}
waisState->entry = entry;
xstrncpy(waisState->request, url, MAX_URL);
comm_add_close_handler(waisState->fd, waisStateFree, waisState);
-#if OLD_CODE
- storeRegisterAbort(entry, waisAbort, waisState);
-#endif
storeLockObject(entry);
commSetSelect(fd, COMM_SELECT_WRITE, waisSendRequest, waisState, 0);
commSetTimeout(fd, Config.Timeout.read, waisTimeout, waisState);
}
-
-#if OLD_CODE
-static void
-waisAbort(void *data)
-{
- HttpStateData *waisState = data;
- debug(24, 1) ("waisAbort: %s\n", storeUrl(waisState->entry));
- comm_close(waisState->fd);
-}
-#endif