From a90eae1863730bee82b9182c8d21794d277e9f03 Mon Sep 17 00:00:00 2001 From: wessels <> Date: Tue, 4 Feb 1997 06:03:04 +0000 Subject: [PATCH] support for PURGE method --- src/acl.cc | 8 +++----- src/client_side.cc | 42 +++++++++++++++++++++++++++++++++++++++++- src/url.cc | 7 +++++-- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/acl.cc b/src/acl.cc index 8b49c9bc53..4c978bbf8f 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,5 +1,5 @@ /* - * $Id: acl.cc,v 1.80 1997/02/03 22:05:11 wessels Exp $ + * $Id: acl.cc,v 1.81 1997/02/03 23:03:04 wessels Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -196,6 +196,8 @@ aclParseMethodList(void *curlist) while ((t = strtokFile())) { q = xcalloc(1, sizeof(intlist)); q->i = (int) urlParseMethod(t); + if (q->i == METHOD_PURGE) + Config.Options.enable_purge = 1; *(Tail) = q; Tail = &q->next; } @@ -351,10 +353,6 @@ aclSplayIpCompare(struct in_addr addr, struct _acl_ip_data *data) else rc = 0; } - debug(28,0,"aclSplayIpCompare: key=%s\n", inet_ntoa(addr)); - debug(28,0,"aclSplayIpCompare: addr1=%s\n", inet_ntoa(data->addr1)); - debug(28,0,"aclSplayIpCompare: addr2=%s\n", inet_ntoa(data->addr2)); - debug(28,0,"aclSplayIpCompare: returning %d\n", rc); return rc; } diff --git a/src/client_side.cc b/src/client_side.cc index 9f805b39b8..40608e00d0 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.85 1997/01/24 20:39:49 wessels Exp $ + * $Id: client_side.cc,v 1.86 1997/02/03 23:03:05 wessels Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -608,3 +608,43 @@ clientConstructTraceEcho(icpStateData * icpState) icpState->http_code = 200; return buf; } + +void +clientPurgeRequest(icpStateData * icpState) +{ + char *buf; + int fd = icpState->fd; + LOCAL_ARRAY(char, msg, 8192); + LOCAL_ARRAY(char, line, 256); + StoreEntry *entry; +debug(0,0,"Config.Options.enable_purge = %d\n", Config.Options.enable_purge); + if (!Config.Options.enable_purge) { + buf = access_denied_msg(icpState->http_code = 401, + icpState->method, + icpState->url, + fd_table[fd].ipaddr); + icpSendERROR(fd, LOG_TCP_DENIED, buf, icpState, icpState->http_code); + return; + } + icpState->log_type = TCP_MISS; + if ((entry = storeGet(icpState->url)) == NULL) { + sprintf(msg, "HTTP/1.0 404 Not Found\r\n"); + icpState->http_code = 404; + } else { + storeRelease(entry); + sprintf(msg, "HTTP/1.0 200 OK\r\n"); + icpState->http_code = 200; + } + sprintf(line, "Date: %s\r\n", mkrfc1123(squid_curtime)); + strcat(msg, line); + sprintf(line, "Server: Squid/%s\r\n", SQUID_VERSION); + strcat(msg, line); + strcat(msg, "\r\n"); + comm_write(fd, + msg, + strlen(msg), + 30, + icpSendERRORComplete, + (void *) icpState, + NULL); +} diff --git a/src/url.cc b/src/url.cc index bababaadce..9a83d9372a 100644 --- a/src/url.cc +++ b/src/url.cc @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.51 1996/12/17 07:16:59 wessels Exp $ + * $Id: url.cc,v 1.52 1997/02/03 23:03:08 wessels Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -39,7 +39,8 @@ const char *RequestMethodStr[] = "PUT", "HEAD", "CONNECT", - "TRACE" + "TRACE", + "PURGE" }; static char *ProtocolStr[] = @@ -143,6 +144,8 @@ urlParseMethod(const char *s) return METHOD_CONNECT; } else if (strcasecmp(s, "TRACE") == 0) { return METHOD_TRACE; + } else if (strcasecmp(s, "PURGE") == 0) { + return METHOD_PURGE; } return METHOD_NONE; } -- 2.47.3