--- /dev/null
+Index: squid/src/ftp.c
+diff -c squid/src/ftp.c:1.316.2.21 squid/src/ftp.c:1.316.2.22
+*** squid/src/ftp.c:1.316.2.21 Sun Feb 20 20:35:08 2005
+--- squid/src/ftp.c Fri Mar 4 04:19:53 2005
+***************
+*** 595,601 ****
+ p->type = 0;
+ while (ct && *ct) {
+ time_t t;
+! int l = strcspn(ct + 1, ",");
+ char *tmp;
+ if (l < 1)
+ goto blank;
+--- 595,601 ----
+ p->type = 0;
+ while (ct && *ct) {
+ time_t t;
+! int l = strcspn(ct, ",");
+ char *tmp;
+ if (l < 1)
+ goto blank;
+***************
+*** 608,614 ****
+ break;
+ case 'm':
+ t = (time_t) strtol(ct + 1, &tmp, 0);
+! if (*tmp || (tmp == ct + 1))
+ break; /* not a valid integer */
+ p->date = xstrdup(ctime(&t));
+ *(strstr(p->date, "\n")) = '\0';
+--- 608,614 ----
+ break;
+ case 'm':
+ t = (time_t) strtol(ct + 1, &tmp, 0);
+! if (tmp != ct + l)
+ break; /* not a valid integer */
+ p->date = xstrdup(ctime(&t));
+ *(strstr(p->date, "\n")) = '\0';
+***************
+*** 1800,1815 ****
+ /* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */
+ /* ANSI sez [^0-9] is undefined, it breaks on Watcom cc */
+ debug(9, 5) ("scanning: %s\n", ftpState->ctrl.last_reply);
+! buf = strstr(ftpState->ctrl.last_reply, "(");
+! if (!buf) {
+! debug(9, 1) ("Unsafe PASV reply from %s: '%s'\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply);
+! ftpSendPort(ftpState);
+! return;
+! }
+! buf++; /* skip ( */
+ n = sscanf(buf, "%d,%d,%d,%d,%d,%d", &h1, &h2, &h3, &h4, &p1, &p2);
+ if (n != 6 || p1 < 0 || p2 < 0 || p1 > 255 || p2 > 255) {
+! debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply);
+ ftpSendPort(ftpState);
+ return;
+ }
+--- 1800,1809 ----
+ /* 227 Entering Passive Mode (h1,h2,h3,h4,p1,p2). */
+ /* ANSI sez [^0-9] is undefined, it breaks on Watcom cc */
+ debug(9, 5) ("scanning: %s\n", ftpState->ctrl.last_reply);
+! buf = ftpState->ctrl.last_reply + strcspn(ftpState->ctrl.last_reply, "0123456789");
+ n = sscanf(buf, "%d,%d,%d,%d,%d,%d", &h1, &h2, &h3, &h4, &p1, &p2);
+ if (n != 6 || p1 < 0 || p2 < 0 || p1 > 255 || p2 > 255) {
+! debug(9, 1) ("Odd PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply);
+ ftpSendPort(ftpState);
+ return;
+ }
+***************
+*** 1826,1848 ****
+ return;
+ }
+ if (Config.Ftp.sanitycheck) {
+- if (strcmp(fd_table[ftpState->ctrl.fd].ipaddr, ipaddr) != 0) {
+- debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply);
+- ftpSendPort(ftpState);
+- return;
+- }
+ if (port < 1024) {
+ debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply);
+ ftpSendPort(ftpState);
+ return;
+ }
+ }
+- debug(9, 5) ("ftpReadPasv: connecting to %s, port %d\n", ipaddr, port);
+ ftpState->data.port = port;
+! ftpState->data.host = xstrdup(ipaddr);
+ safe_free(ftpState->ctrl.last_command);
+ safe_free(ftpState->ctrl.last_reply);
+ ftpState->ctrl.last_command = xstrdup("Connect to server data port");
+ commConnectStart(fd, ipaddr, port, ftpPasvCallback, ftpState);
+ }
+
+--- 1820,1840 ----
+ return;
+ }
+ if (Config.Ftp.sanitycheck) {
+ if (port < 1024) {
+ debug(9, 1) ("Unsafe PASV reply from %s: %s\n", fd_table[ftpState->ctrl.fd].ipaddr, ftpState->ctrl.last_reply);
+ ftpSendPort(ftpState);
+ return;
+ }
+ }
+ ftpState->data.port = port;
+! if (Config.Ftp.sanitycheck)
+! ftpState->data.host = xstrdup(fd_table[ftpState->ctrl.fd].ipaddr);
+! else
+! ftpState->data.host = xstrdup(ipaddr);
+ safe_free(ftpState->ctrl.last_command);
+ safe_free(ftpState->ctrl.last_reply);
+ ftpState->ctrl.last_command = xstrdup("Connect to server data port");
++ debug(9, 5) ("ftpReadPasv: connecting to %s, port %d\n", ftpState->data.host, ftpState->data.port);
+ commConnectStart(fd, ipaddr, port, ftpPasvCallback, ftpState);
+ }
+
--- /dev/null
+Index: squid/src/ftp.c
+diff -c squid/src/ftp.c:1.316.2.22 squid/src/ftp.c:1.316.2.23
+*** squid/src/ftp.c:1.316.2.22 Fri Mar 4 04:19:53 2005
+--- squid/src/ftp.c Fri Mar 4 04:53:55 2005
+***************
+*** 1648,1653 ****
+--- 1648,1654 ----
+ debug(9, 3) ("Directory path did not end in /\n");
+ strCat(ftpState->title_url, "/");
+ ftpState->flags.isdir = 1;
++ ftpState->flags.use_base = 1;
+ }
+ ftpSendPasv(ftpState);
+ }
+***************
+*** 2123,2129 ****
+ ftpSendList(FtpStateData * ftpState)
+ {
+ if (ftpState->filepath) {
+- ftpState->flags.use_base = 1;
+ snprintf(cbuf, 1024, "LIST %s\r\n", ftpState->filepath);
+ } else {
+ snprintf(cbuf, 1024, "LIST\r\n");
+--- 2124,2129 ----
--- /dev/null
+Index: squid/src/client_side.c
+diff -c squid/src/client_side.c:1.561.2.71 squid/src/client_side.c:1.561.2.72
+*** squid/src/client_side.c:1.561.2.71 Sun Feb 20 12:07:45 2005
+--- squid/src/client_side.c Wed Mar 2 19:18:29 2005
+***************
+*** 572,577 ****
+--- 572,578 ----
+ }
+ } else {
+ /* the client can handle this reply, whatever it is */
++ http->flags.hit = 0;
+ http->log_type = LOG_TCP_REFRESH_MISS;
+ if (HTTP_NOT_MODIFIED == mem->reply->sline.status) {
+ httpReplyUpdateOnNotModified(http->old_entry->mem_obj->reply,
+***************
+*** 1265,1271 ****
+ HttpHeader *hdr = rep ? &rep->header : 0;
+ const char *range_err = NULL;
+ request_t *request = http->request;
+- int is_hit = isTcpHit(http->log_type);
+ assert(request->range);
+ /* check if we still want to do ranges */
+ if (!rep)
+--- 1266,1271 ----
+***************
+*** 1286,1292 ****
+ range_err = "too complex range header";
+ else if (!request->flags.cachable) /* from we_do_ranges in http.c */
+ range_err = "non-cachable request";
+! else if (!is_hit && httpHdrRangeOffsetLimit(http->request->range))
+ range_err = "range outside range_offset_limit";
+ /* get rid of our range specs on error */
+ if (range_err) {
+--- 1286,1292 ----
+ range_err = "too complex range header";
+ else if (!request->flags.cachable) /* from we_do_ranges in http.c */
+ range_err = "non-cachable request";
+! else if (!http->flags.hit && httpHdrRangeOffsetLimit(http->request->range))
+ range_err = "range outside range_offset_limit";
+ /* get rid of our range specs on error */
+ if (range_err) {
+***************
+*** 1343,1349 ****
+ clientBuildReplyHeader(clientHttpRequest * http, HttpReply * rep)
+ {
+ HttpHeader *hdr = &rep->header;
+- int is_hit = isTcpHit(http->log_type);
+ request_t *request = http->request;
+ #if DONT_FILTER_THESE
+ /* but you might want to if you run Squid as an HTTP accelerator */
+--- 1343,1348 ----
+***************
+*** 1354,1360 ****
+ /* here: Keep-Alive is a field-name, not a connection directive! */
+ httpHeaderDelByName(hdr, "Keep-Alive");
+ /* remove Set-Cookie if a hit */
+! if (is_hit)
+ httpHeaderDelById(hdr, HDR_SET_COOKIE);
+ /* handle Connection header */
+ if (httpHeaderHas(hdr, HDR_CONNECTION)) {
+--- 1353,1359 ----
+ /* here: Keep-Alive is a field-name, not a connection directive! */
+ httpHeaderDelByName(hdr, "Keep-Alive");
+ /* remove Set-Cookie if a hit */
+! if (http->flags.hit)
+ httpHeaderDelById(hdr, HDR_SET_COOKIE);
+ /* handle Connection header */
+ if (httpHeaderHas(hdr, HDR_CONNECTION)) {
+***************
+*** 1383,1389 ****
+ /*
+ * Add a estimated Age header on cache hits.
+ */
+! if (is_hit) {
+ /*
+ * Remove any existing Age header sent by upstream caches
+ * (note that the existing header is passed along unmodified
+--- 1382,1388 ----
+ /*
+ * Add a estimated Age header on cache hits.
+ */
+! if (http->flags.hit) {
+ /*
+ * Remove any existing Age header sent by upstream caches
+ * (note that the existing header is passed along unmodified
+***************
+*** 1431,1437 ****
+ authenticateFixHeader(rep, request->auth_user_request, request, http->flags.accel, 0);
+ /* Append X-Cache */
+ httpHeaderPutStrf(hdr, HDR_X_CACHE, "%s from %s",
+! is_hit ? "HIT" : "MISS", getMyHostname());
+ #if USE_CACHE_DIGESTS
+ /* Append X-Cache-Lookup: -- temporary hack, to be removed @?@ @?@ */
+ httpHeaderPutStrf(hdr, HDR_X_CACHE_LOOKUP, "%s from %s:%d",
+--- 1430,1436 ----
+ authenticateFixHeader(rep, request->auth_user_request, request, http->flags.accel, 0);
+ /* Append X-Cache */
+ httpHeaderPutStrf(hdr, HDR_X_CACHE, "%s from %s",
+! http->flags.hit ? "HIT" : "MISS", getMyHostname());
+ #if USE_CACHE_DIGESTS
+ /* Append X-Cache-Lookup: -- temporary hack, to be removed @?@ @?@ */
+ httpHeaderPutStrf(hdr, HDR_X_CACHE_LOOKUP, "%s from %s:%d",
+***************
+*** 1505,1510 ****
+--- 1504,1510 ----
+ MemObject *mem;
+ request_t *r = http->request;
+ debug(33, 3) ("clientCacheHit: %s, %d bytes\n", http->uri, (int) size);
++ http->flags.hit = 0;
+ if (http->entry == NULL) {
+ memFree(buf, MEM_CLIENT_SOCK_BUF);
+ debug(33, 3) ("clientCacheHit: request aborted\n");
+***************
+*** 1592,1597 ****
+--- 1592,1598 ----
+ clientPurgeRequest(http);
+ return;
+ }
++ http->flags.hit = 1;
+ if (checkNegativeHit(e)) {
+ http->log_type = LOG_TCP_NEGATIVE_HIT;
+ clientSendMoreData(data, buf, size);
+***************
+*** 2276,2281 ****
+--- 2277,2283 ----
+ char *url = http->uri;
+ request_t *r = http->request;
+ ErrorState *err = NULL;
++ http->flags.hit = 0;
+ debug(33, 4) ("clientProcessOnlyIfCachedMiss: '%s %s'\n",
+ RequestMethodStr[r->method], url);
+ http->al.http.code = HTTP_GATEWAY_TIMEOUT;
+Index: squid/src/structs.h
+diff -c squid/src/structs.h:1.408.2.37 squid/src/structs.h:1.408.2.38
+*** squid/src/structs.h:1.408.2.37 Tue Feb 22 17:06:35 2005
+--- squid/src/structs.h Wed Mar 2 19:18:29 2005
+***************
+*** 1099,1104 ****
+--- 1099,1105 ----
+ unsigned int internal:1;
+ unsigned int done_copying:1;
+ unsigned int purging:1;
++ unsigned int hit:1;
+ } flags;
+ struct {
+ http_status status;