From: wessels <>
Date: Tue, 17 Mar 1998 04:59:55 +0000 (+0000)
Subject: Henrik icon URL changes
X-Git-Tag: SQUID_3_0_PRE1~3829
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4162ee3be7f6161df1f74a626f64989a31051e4e;p=thirdparty%2Fsquid.git
Henrik icon URL changes
---
diff --git a/src/client_side.cc b/src/client_side.cc
index cabdd1481c..e0c2a71d33 100644
--- a/src/client_side.cc
+++ b/src/client_side.cc
@@ -1,6 +1,6 @@
/*
- * $Id: client_side.cc,v 1.227 1998/03/16 17:03:25 wessels Exp $
+ * $Id: client_side.cc,v 1.228 1998/03/16 21:59:55 wessels Exp $
*
* DEBUG: section 33 Client-side Routines
* AUTHOR: Duane Wessels
@@ -1364,7 +1364,7 @@ clientProcessMiss(clientHttpRequest * http)
ch.src_addr = http->conn->peer.sin_addr;
ch.request = r;
answer = aclCheckFast(Config.accessList.miss, &ch);
- if (answer == 0) {
+ if (answer == 0 || http->internal) {
http->al.http.code = HTTP_FORBIDDEN;
err = errorCon(ERR_FORWARDING_DENIED, HTTP_FORBIDDEN);
err->request = requestLink(r);
@@ -1542,8 +1542,17 @@ parseHttpRequest(ConnStateData * conn, method_t * method_p, int *status,
if ((t = strchr(url, '#'))) /* remove HTML anchors */
*t = '\0';
+ /* handle internal objects */
+ if (*url == '/' && strncmp(url, "/squid-internal/", 16) == 0) {
+ /* prepend our name & port */
+ url_sz = 7 + strlen(getMyHostname()) + 6 + strlen(url) + 1;
+ http->uri = xcalloc(url_sz, 1);
+ snprintf(http->uri, url_sz, "http://%s:%d%s",
+ getMyHostname(), Config.Port.http->i, url);
+ http->internal = 1;
+ }
/* see if we running in Config2.Accel.on, if so got to convert it to URL */
- if (Config2.Accel.on && *url == '/') {
+ else if (Config2.Accel.on && *url == '/') {
/* prepend the accel prefix */
if (opt_accel_uses_host && (t = mime_get_header(req_hdr, "Host"))) {
/* If a Host: header was specified, use it to build the URL
diff --git a/src/defines.h b/src/defines.h
index 50cb12349a..02ca2430a5 100644
--- a/src/defines.h
+++ b/src/defines.h
@@ -68,18 +68,18 @@
* Here are some good prime number choices. It's important not to
* choose a prime number that is too close to exact powers of 2.
*
- * HASH_SIZE 103 // prime number < 128
- * HASH_SIZE 229 // prime number < 256
- * HASH_SIZE 467 // prime number < 512
- * HASH_SIZE 977 // prime number < 1024
- * HASH_SIZE 1979 // prime number < 2048
- * HASH_SIZE 4019 // prime number < 4096
- * HASH_SIZE 6037 // prime number < 6144
- * HASH_SIZE 7951 // prime number < 8192
- * HASH_SIZE 12149 // prime number < 12288
- * HASH_SIZE 16231 // prime number < 16384
- * HASH_SIZE 33493 // prime number < 32768
- * HASH_SIZE 65357 // prime number < 65536
+ * HASH_SIZE 103 // prime number < 128
+ * HASH_SIZE 229 // prime number < 256
+ * HASH_SIZE 467 // prime number < 512
+ * HASH_SIZE 977 // prime number < 1024
+ * HASH_SIZE 1979 // prime number < 2048
+ * HASH_SIZE 4019 // prime number < 4096
+ * HASH_SIZE 6037 // prime number < 6144
+ * HASH_SIZE 7951 // prime number < 8192
+ * HASH_SIZE 12149 // prime number < 12288
+ * HASH_SIZE 16231 // prime number < 16384
+ * HASH_SIZE 33493 // prime number < 32768
+ * HASH_SIZE 65357 // prime number < 65536
*/
#define DEFAULT_HASH_SIZE 7951 /* prime number < 8192 */
@@ -153,10 +153,6 @@
#define PEER_DEAD 0
#define PEER_ALIVE 1
-#define ICON_MENU "anthony-dir.gif"
-#define ICON_DIRUP "anthony-dirup.gif"
-#define ICON_LINK "anthony-link.gif"
-
#define AUTH_MSG_SZ 4096
#define HTTP_REPLY_BUF_SZ 4096
diff --git a/src/ftp.cc b/src/ftp.cc
index 1c1b9ca9c7..268ae31d8f 100644
--- a/src/ftp.cc
+++ b/src/ftp.cc
@@ -1,6 +1,6 @@
/*
- * $Id: ftp.cc,v 1.207 1998/03/16 18:21:41 wessels Exp $
+ * $Id: ftp.cc,v 1.208 1998/03/16 21:59:58 wessels Exp $
*
* DEBUG: section 9 File Transfer Protocol (FTP)
* AUTHOR: Harvest Derived
@@ -575,10 +575,9 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
}
/* check .. as special case */
if (!strcmp(parts->name, "..")) {
- snprintf(icon, 2048, "
",
- "http://internal.squid/icons/",
- ICON_DIRUP,
- "[DIR]");
+ snprintf(icon, 2048, "
",
+ mimeGetIconURL("internal-dirup"),
+ "[DIRUP]");
if (!EBIT_TEST(flags, FTP_NO_DOTDOT) && !EBIT_TEST(flags, FTP_ROOT_DIR)) {
/* Normal directory */
snprintf(link, 2048, "%s",
@@ -624,9 +623,8 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
}
switch (parts->type) {
case 'd':
- snprintf(icon, 2048, "
",
- "http://internal.squid/icons/",
- ICON_MENU,
+ snprintf(icon, 2048, "
",
+ mimeGetIconURL("internal-dir"),
"[DIR]");
snprintf(link, 2048, "%s%s",
rfc1738_escape(parts->name),
@@ -638,9 +636,8 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
parts->date);
break;
case 'l':
- snprintf(icon, 2048, "
",
- "http://internal.squid/icons/",
- ICON_LINK,
+ snprintf(icon, 2048, "
",
+ mimeGetIconURL("internal-link"),
"[LINK]");
snprintf(link, 2048, "%s%s",
rfc1738_escape(parts->name),
@@ -656,9 +653,8 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
link2);
break;
case '\0':
- snprintf(icon, 2048, "
",
- "http://internal.squid/icons/",
- mimeGetIcon(parts->name),
+ snprintf(icon, 2048, "
",
+ mimeGetIconURL(parts->name),
"[UNKNOWN]");
snprintf(link, 2048, "%s",
rfc1738_escape(parts->name),
@@ -672,9 +668,8 @@ ftpHtmlifyListEntry(char *line, FtpStateData * ftpState)
break;
case '-':
default:
- snprintf(icon, 2048, "
",
- "http://internal.squid/icons/",
- mimeGetIcon(parts->name),
+ snprintf(icon, 2048, "
",
+ mimeGetIconURL(parts->name),
"[FILE]");
snprintf(link, 2048, "%s%s",
rfc1738_escape(parts->name),
@@ -750,8 +745,8 @@ ftpReadComplete(FtpStateData * ftpState)
if (EBIT_TEST(ftpState->flags, FTP_HTML_HEADER_SENT))
ftpListingFinish(ftpState);
if (!EBIT_TEST(ftpState->flags, FTP_PUT)) {
- storeTimestampsSet(ftpState->entry);
- storeComplete(ftpState->entry);
+ storeTimestampsSet(ftpState->entry);
+ storeComplete(ftpState->entry);
}
/* expect the "transfer complete" message on the control socket */
commSetSelect(ftpState->ctrl.fd,
@@ -936,7 +931,7 @@ ftpStart(request_t * request, StoreEntry * entry)
EBIT_SET(ftpState->flags, FTP_PASV_SUPPORTED);
EBIT_SET(ftpState->flags, FTP_REST_SUPPORTED);
if (ftpState->request->method == METHOD_PUT)
- EBIT_SET(ftpState->flags, FTP_PUT);
+ EBIT_SET(ftpState->flags, FTP_PUT);
if (!ftpCheckAuth(ftpState, request->headers)) {
/* This request is not fully authenticated */
if (request->port == 21) {
@@ -1185,7 +1180,7 @@ ftpReadControlReply(int fd, void *data)
ftpState->ctrl.last_reply = (*W)->key;
safe_free(*W);
ftpState->ctrl.offset = 0;
- debug(9,8)("ftpReadControlReply: state=%d\n",ftpState->state);
+ debug(9, 8) ("ftpReadControlReply: state=%d\n", ftpState->state);
FTP_SM_FUNCS[ftpState->state] (ftpState);
}
@@ -1378,39 +1373,40 @@ ftpReadCwd(FtpStateData * ftpState)
ftpTraverseDirectory(ftpState);
} else {
/* CWD FAILED */
- if (!EBIT_TEST(ftpState->flags, FTP_PUT))
- ftpFail(ftpState);
+ if (!EBIT_TEST(ftpState->flags, FTP_PUT))
+ ftpFail(ftpState);
else
- ftpTryMkdir(ftpState);
+ ftpTryMkdir(ftpState);
}
}
static void
-ftpTryMkdir(FtpStateData *ftpState)
+ftpTryMkdir(FtpStateData * ftpState)
{
- char *path=ftpState->filepath;
- debug(9,3)("ftpTryMkdir: with path=%s\n",path);
- snprintf(cbuf, 1024, "MKD %s\r\n", path);
- ftpWriteCommand(cbuf, ftpState);
- ftpState->state = SENT_MKDIR;
+ char *path = ftpState->filepath;
+ debug(9, 3) ("ftpTryMkdir: with path=%s\n", path);
+ snprintf(cbuf, 1024, "MKD %s\r\n", path);
+ ftpWriteCommand(cbuf, ftpState);
+ ftpState->state = SENT_MKDIR;
}
static void
-ftpReadMkdir(FtpStateData *ftpState)
-{
- char *path=ftpState->filepath;
- int code = ftpState->ctrl.replycode;
-
- debug(9,3)("Here, with code %d\n",path,code);
- if (code==257) { /* success */
- ftpSendCwd(ftpState);
- } else if (code==550) { /* dir exists */
- if (EBIT_TEST(ftpState->flags, FTP_PUT_MKDIR)) {
- EBIT_SET(ftpState->flags, FTP_PUT_MKDIR);
- ftpSendCwd(ftpState);
- } else
- ftpSendReply(ftpState);
- } else ftpSendReply(ftpState);
+ftpReadMkdir(FtpStateData * ftpState)
+{
+ char *path = ftpState->filepath;
+ int code = ftpState->ctrl.replycode;
+
+ debug(9, 3) ("Here, with code %d\n", path, code);
+ if (code == 257) { /* success */
+ ftpSendCwd(ftpState);
+ } else if (code == 550) { /* dir exists */
+ if (EBIT_TEST(ftpState->flags, FTP_PUT_MKDIR)) {
+ EBIT_SET(ftpState->flags, FTP_PUT_MKDIR);
+ ftpSendCwd(ftpState);
+ } else
+ ftpSendReply(ftpState);
+ } else
+ ftpSendReply(ftpState);
}
static void
@@ -1713,7 +1709,7 @@ ftpRestOrList(FtpStateData * ftpState)
debug(9, 3) ("This is ftpRestOrList\n");
if (EBIT_TEST(ftpState->flags, FTP_PUT)) {
- debug(9,3)("ftpRestOrList: Sending STOR request...\n");
+ debug(9, 3) ("ftpRestOrList: Sending STOR request...\n");
ftpSendStor(ftpState);
} else if (ftpState->typecode == 'D') {
/* XXX This should NOT be here */
@@ -2013,17 +2009,17 @@ static void
ftpPutStart(FtpStateData * ftpState)
{
debug(9, 3) ("ftpPutStart\n");
- pumpStart(ftpState->data.fd, ftpState->entry ,
- ftpState->request, ftpPutTransferDone, ftpState);
+ pumpStart(ftpState->data.fd, ftpState->entry,
+ ftpState->request, ftpPutTransferDone, ftpState);
}
-static void
+static void
ftpPutTransferDone(int fd, char *bufnotused, size_t size, int errflag, void *data)
{
- FtpStateData * ftpState=(FtpStateData *)data;
+ FtpStateData *ftpState = (FtpStateData *) data;
if (ftpState->data.fd >= 0) {
- comm_close(ftpState->data.fd);
- ftpState->data.fd = -1;
+ comm_close(ftpState->data.fd);
+ ftpState->data.fd = -1;
}
ftpReadComplete(ftpState);
}
diff --git a/src/gopher.cc b/src/gopher.cc
index f8dffc7866..3496fd4ae4 100644
--- a/src/gopher.cc
+++ b/src/gopher.cc
@@ -1,6 +1,6 @@
/*
- * $Id: gopher.cc,v 1.122 1998/03/05 00:42:53 wessels Exp $
+ * $Id: gopher.cc,v 1.123 1998/03/16 21:59:58 wessels Exp $
*
* DEBUG: section 10 Gopher
* AUTHOR: Harvest Derived
@@ -357,7 +357,7 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
char *host = NULL;
char *port = NULL;
char *escaped_selector = NULL;
- char *icon_type = NULL;
+ char *icon_url = NULL;
char gtype;
StoreEntry *entry = NULL;
@@ -509,39 +509,39 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
switch (gtype) {
case GOPHER_DIRECTORY:
- icon_type = "internal-gopher-menu";
+ icon_url = mimeGetIconURL("internal-menu");
break;
case GOPHER_FILE:
- icon_type = "internal-gopher-text";
+ icon_url = mimeGetIconURL("internal-text");
break;
case GOPHER_INDEX:
case GOPHER_CSO:
- icon_type = "internal-gopher-index";
+ icon_url = mimeGetIconURL("internal-index");
break;
case GOPHER_IMAGE:
case GOPHER_GIF:
case GOPHER_PLUS_IMAGE:
- icon_type = "internal-gopher-image";
+ icon_url = mimeGetIconURL("internal-image");
break;
case GOPHER_SOUND:
case GOPHER_PLUS_SOUND:
- icon_type = "internal-gopher-sound";
+ icon_url = mimeGetIconURL("internal-sound");
break;
case GOPHER_PLUS_MOVIE:
- icon_type = "internal-gopher-movie";
+ icon_url = mimeGetIconURL("internal-movie");
break;
case GOPHER_TELNET:
case GOPHER_3270:
- icon_type = "internal-gopher-telnet";
+ icon_url = mimeGetIconURL("internal-telnet");
break;
case GOPHER_BIN:
case GOPHER_MACBINHEX:
case GOPHER_DOSBIN:
case GOPHER_UUENCODED:
- icon_type = "internal-gopher-binary";
+ icon_url = mimeGetIconURL("internal-binary");
break;
default:
- icon_type = "internal-gopher-unknown";
+ icon_url = mimeGetIconURL("internal-unknown");
break;
}
@@ -550,14 +550,14 @@ gopherToHTML(GopherStateData * gopherState, char *inbuf, int len)
if ((gtype == GOPHER_TELNET) || (gtype == GOPHER_3270)) {
if (strlen(escaped_selector) != 0)
snprintf(tmpbuf, TEMP_BUF_SIZE, "
%s\n",
- icon_type, escaped_selector, host, name);
+ icon_url, escaped_selector, host, name);
else
snprintf(tmpbuf, TEMP_BUF_SIZE, "
%s\n",
- icon_type, host, name);
+ icon_url, host, name);
} else {
snprintf(tmpbuf, TEMP_BUF_SIZE, "
%s\n",
- icon_type, host, gtype, escaped_selector, name);
+ icon_url, host, gtype, escaped_selector, name);
}
safe_free(escaped_selector);
strcat(outbuf, tmpbuf);
diff --git a/src/mime.cc b/src/mime.cc
index 092ed42a24..e84d76cc07 100644
--- a/src/mime.cc
+++ b/src/mime.cc
@@ -1,6 +1,6 @@
/*
- * $Id: mime.cc,v 1.54 1998/03/06 23:22:30 wessels Exp $
+ * $Id: mime.cc,v 1.55 1998/03/16 21:59:59 wessels Exp $
*
* DEBUG: section 25 MIME Parsing
* AUTHOR: Harvest Derived
@@ -275,6 +275,20 @@ mimeGetIcon(const char *fn)
return m->icon;
}
+char *
+mimeGetIconURL(const char *fn)
+{
+ char *icon = mimeGetIcon(fn);
+ static char iconurl[256];
+ if (icon == NULL)
+ return NULL;
+ snprintf(iconurl, 256, "http://%s:%d/squid-internal/icons/%s",
+ getMyHostname(),
+ Config.Port.http->i,
+ icon);
+ return iconurl;
+}
+
char *
mimeGetContentType(const char *fn)
{
@@ -407,9 +421,6 @@ mimeInit(char *filename)
*/
for (m = MimeTable; m != NULL; m = m->next)
mimeLoadIconFile(m->icon);
- mimeLoadIconFile(ICON_MENU);
- mimeLoadIconFile(ICON_DIRUP);
- mimeLoadIconFile(ICON_LINK);
debug(25, 1) ("Loaded Icons.\n");
}
@@ -428,7 +439,8 @@ mimeLoadIconFile(const char *icon)
const char *type = mimeGetContentType(icon);
if (type == NULL)
fatal("Unknown icon format while reading mime.conf\n");
- snprintf(url, MAX_URL, "http://internal.squid/icons/%s", icon);
+ snprintf(url, MAX_URL, "http://%s:%d/squid-internal/icons/%s",
+ getMyHostname(), Config.Port.http->i, icon);
key = storeKeyPublic(url, METHOD_GET);
if (storeGet(key))
return;
diff --git a/src/protos.h b/src/protos.h
index 0076dde483..2400bcb8c7 100644
--- a/src/protos.h
+++ b/src/protos.h
@@ -465,6 +465,7 @@ extern void mimeInit(char *filename);
extern char *mimeGetContentEncoding(const char *fn);
extern char *mimeGetContentType(const char *fn);
extern char *mimeGetIcon(const char *fn);
+extern char *mimeGetIconURL(const char *fn);
extern char mimeGetTransferMode(const char *fn);
extern int mcastSetTtl(int, int);
diff --git a/src/structs.h b/src/structs.h
index cdd47158fd..64f4cb5e6b 100644
--- a/src/structs.h
+++ b/src/structs.h
@@ -654,6 +654,7 @@ struct _clientHttpRequest {
log_type log_type;
http_status http_code;
int accel;
+ int internal; /* Set to true on /squid-internal/ request, to prevent looping */
struct timeval start;
float http_ver;
int redirect_state;