]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
TRACE support
authorwessels <>
Tue, 17 Dec 1996 14:16:51 +0000 (14:16 +0000)
committerwessels <>
Tue, 17 Dec 1996 14:16:51 +0000 (14:16 +0000)
src/cache_cf.cc
src/client.cc
src/client_side.cc
src/http.cc
src/ssl.cc
src/store.cc
src/tunnel.cc
src/url.cc

index 952bcf348c3148ae335384537e3861a782e60503..6ee06934ba79f582bb2495571efc78e0926de235 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: cache_cf.cc,v 1.156 1996/12/17 04:06:02 wessels Exp $
+ * $Id: cache_cf.cc,v 1.157 1996/12/17 07:16:51 wessels Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -908,7 +908,7 @@ parseCacheAnnounceLine(void)
     GetInteger(i);
     Config.Announce.rate = i * 3600;   /* hours to seconds */
     if (Config.Announce.rate > 0)
-       Config.Announce.on = 1;
+       Config.Announce.on = 1;
 }
 
 static void
index fd27c9558730d8d1edf702cfd134a057009afa20..03013e74a636bcd1c0e98091fbca0590b90680e8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client.cc,v 1.15 1996/11/06 23:14:23 wessels Exp $
+ * $Id: client.cc,v 1.16 1996/12/17 07:16:52 wessels Exp $
  *
  * DEBUG: section 0     WWW Client
  * AUTHOR: Harvest Derived
@@ -139,6 +139,7 @@ main(int argc, char *argv[])
     const char *method = "GET";
     extern char *optarg;
     time_t ims = 0;
+    int max_forwards = -1;
 
     /* set the defaults */
     strcpy(hostname, "localhost");
@@ -152,7 +153,7 @@ main(int argc, char *argv[])
        strcpy(url, argv[argc - 1]);
        if (url[0] == '-')
            usage(argv[0]);
-       while ((c = getopt(argc, argv, "fsrnp:c:h:i:m:?")) != -1)
+       while ((c = getopt(argc, argv, "fsrnp:c:h:i:m:t:?")) != -1)
            switch (c) {
            case 'h':           /* host:arg */
            case 'c':           /* backward compat */
@@ -177,6 +178,10 @@ main(int argc, char *argv[])
            case 'm':
                method = xstrdup(optarg);
                break;
+           case 't':
+               method = xstrdup("TRACE");
+               max_forwards = atoi(optarg);
+               break;
            case '?':           /* usage */
            default:
                usage(argv[0]);
@@ -211,6 +216,10 @@ main(int argc, char *argv[])
        sprintf(buf, "If-Modified-Since: %s\r\n", mkrfc1123(ims));
        strcat(msg, buf);
     }
+    if (max_forwards > -1) {
+       sprintf(buf, "Max-Forwards: %d\r\n", max_forwards);
+       strcat(msg, buf);
+    }
     sprintf(buf, "\r\n");
     strcat(msg, buf);
 
index 9e4166b33f49282bb25caa829b5d7562c0840025..46a3b3d24eac16507307fae1f34dc09c4bd2b012 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.74 1996/12/14 18:56:03 wessels Exp $
+ * $Id: client_side.cc,v 1.75 1996/12/17 07:16:53 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -559,3 +559,30 @@ modifiedSince(StoreEntry * entry, request_t * request)
        return 1;
     }
 }
+
+char *
+clientConstructTraceEcho(icpStateData * icpState)
+{
+    LOCAL_ARRAY(char, line, 256);
+    LOCAL_ARRAY(char, buf, 8192);
+    size_t len;
+    memset(buf, '\0', 8192);
+    sprintf(buf, "HTTP/1.0 200 OK\r\n");
+    sprintf(line, "Date: %s\r\n", mkrfc1123(squid_curtime));
+    strcat(buf, line);
+    sprintf(line, "Server: Squid/%s\r\n", SQUID_VERSION);
+    strcat(buf, line);
+    sprintf(line, "Content-Type: message/http\r\n");
+    strcat(buf, line);
+    strcat(buf, "\r\n");
+    len = strlen(buf);
+    httpBuildRequestHeader(icpState->request,
+       icpState->request,
+       NULL,                   /* entry */
+       icpState->request_hdr,
+       NULL,                   /* in_len */
+       buf + len,
+       8192 - len,
+       icpState->fd);
+    return buf;
+}
index d653994a1fcdfb23efead022e7a4e45dd6c45100..1ee4446755ec875398bc73842b47cee59ae874ba 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: http.cc,v 1.138 1996/12/16 16:25:44 wessels Exp $
+ * $Id: http.cc,v 1.139 1996/12/17 07:16:54 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -712,6 +712,7 @@ httpBuildRequestHeader(request_t * request,
     size_t l;
     int hdr_flags = 0;
     int cc_flags = 0;
+    int n;
     const char *url = NULL;
 
     debug(11, 3, "httpBuildRequestHeader: INPUT:\n%s\n", hdr_in);
@@ -761,6 +762,12 @@ httpBuildRequestHeader(request_t * request,
        } else if (strncasecmp(xbuf, "If-Modified-Since:", 18) == 0) {
            if (EBIT_TEST(hdr_flags, HDR_IMS))
                continue;
+       } else if (strncasecmp(xbuf, "Max-Forwards:", 13) == 0) {
+           if (orig_request->method == METHOD_TRACE) {
+               for (s = xbuf + 13; *s && isspace(*s); s++);
+               n = atoi(s);
+               sprintf(xbuf, "Max-Forwards: %d", n - 1);
+           }
        }
        httpAppendRequestHeader(hdr_out, xbuf, &len, out_sz - 512);
     }
index c491f3efd4066cda8df00f8c53743f5a6c2d4244..f6775cd0e3935878bfa6d03c66f669d6218742e0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ssl.cc,v 1.30 1996/12/16 16:23:42 wessels Exp $
+ * $Id: ssl.cc,v 1.31 1996/12/17 07:16:57 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -487,30 +487,30 @@ sslSelectNeighbor(int fd, const ipcache_addrs * ia, void *data)
     edge *g = NULL;
     int fw_ip_match = IP_ALLOW;
     if (ia && Config.firewall_ip_list)
-        fw_ip_match = ip_access_check(ia->in_addrs[ia->cur], Config.firewall_ip_list);
+       fw_ip_match = ip_access_check(ia->in_addrs[ia->cur], Config.firewall_ip_list);
     if ((e = Config.sslProxy)) {
-        hierarchyNote(request, HIER_SSL_PARENT, 0, e->host);
+       hierarchyNote(request, HIER_SSL_PARENT, 0, e->host);
     } else if (matchInsideFirewall(request->host)) {
-        hierarchyNote(request, HIER_DIRECT, 0, request->host);
+       hierarchyNote(request, HIER_DIRECT, 0, request->host);
     } else if (fw_ip_match == IP_DENY) {
-        hierarchyNote(request, HIER_DIRECT, 0, request->host);
+       hierarchyNote(request, HIER_DIRECT, 0, request->host);
     } else if ((e = getDefaultParent(request))) {
-        hierarchyNote(request, HIER_DEFAULT_PARENT, 0, e->host);
+       hierarchyNote(request, HIER_DEFAULT_PARENT, 0, e->host);
     } else if ((e = getSingleParent(request))) {
-        hierarchyNote(request, HIER_SINGLE_PARENT, 0, e->host);
+       hierarchyNote(request, HIER_SINGLE_PARENT, 0, e->host);
     } else if ((e = getFirstUpParent(request))) {
-        hierarchyNote(request, HIER_FIRSTUP_PARENT, 0, e->host);
+       hierarchyNote(request, HIER_FIRSTUP_PARENT, 0, e->host);
     }
     sslState->proxying = e ? 1 : 0;
     sslState->host = e ? e->host : request->host;
     if (e == NULL) {
-        sslState->port = request->port;
+       sslState->port = request->port;
     } else if (e->http_port != 0) {
-        sslState->port = e->http_port;
+       sslState->port = e->http_port;
     } else if ((g = neighborFindByName(e->host))) {
-        sslState->port = g->http_port;
+       sslState->port = g->http_port;
     } else {
-        sslState->port = CACHE_HTTP_PORT;
+       sslState->port = CACHE_HTTP_PORT;
     }
     ipcache_nbgethostbyname(sslState->host,
        sslState->server.fd,
index dff2fc2a7a7f07a5cf5c4d387ce672af97633085..aaf8f96513551d5b02057bcba36405e3c42d856c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.180 1996/12/15 03:29:44 wessels Exp $
+ * $Id: store.cc,v 1.181 1996/12/17 07:16:58 wessels Exp $
  *
  * DEBUG: section 20    Storeage Manager
  * AUTHOR: Harvest Derived
@@ -669,6 +669,11 @@ storeGeneratePublicKey(const char *url, method_t method)
        return key_temp_buffer;
        /* NOTREACHED */
        break;
+    case METHOD_TRACE:
+       sprintf(key_temp_buffer, "/trace/%s", url);
+       return key_temp_buffer;
+       /* NOTREACHED */
+       break;
     default:
        debug_trap("storeGeneratePublicKey: Unsupported request method");
        break;
index fd0ca148449895447197798a066f13b00430fbff..c9b7f4d76a3164bc9db18590c88ef8400445a61b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tunnel.cc,v 1.30 1996/12/16 16:23:42 wessels Exp $
+ * $Id: tunnel.cc,v 1.31 1996/12/17 07:16:57 wessels Exp $
  *
  * DEBUG: section 26    Secure Sockets Layer Proxy
  * AUTHOR: Duane Wessels
@@ -487,30 +487,30 @@ sslSelectNeighbor(int fd, const ipcache_addrs * ia, void *data)
     edge *g = NULL;
     int fw_ip_match = IP_ALLOW;
     if (ia && Config.firewall_ip_list)
-        fw_ip_match = ip_access_check(ia->in_addrs[ia->cur], Config.firewall_ip_list);
+       fw_ip_match = ip_access_check(ia->in_addrs[ia->cur], Config.firewall_ip_list);
     if ((e = Config.sslProxy)) {
-        hierarchyNote(request, HIER_SSL_PARENT, 0, e->host);
+       hierarchyNote(request, HIER_SSL_PARENT, 0, e->host);
     } else if (matchInsideFirewall(request->host)) {
-        hierarchyNote(request, HIER_DIRECT, 0, request->host);
+       hierarchyNote(request, HIER_DIRECT, 0, request->host);
     } else if (fw_ip_match == IP_DENY) {
-        hierarchyNote(request, HIER_DIRECT, 0, request->host);
+       hierarchyNote(request, HIER_DIRECT, 0, request->host);
     } else if ((e = getDefaultParent(request))) {
-        hierarchyNote(request, HIER_DEFAULT_PARENT, 0, e->host);
+       hierarchyNote(request, HIER_DEFAULT_PARENT, 0, e->host);
     } else if ((e = getSingleParent(request))) {
-        hierarchyNote(request, HIER_SINGLE_PARENT, 0, e->host);
+       hierarchyNote(request, HIER_SINGLE_PARENT, 0, e->host);
     } else if ((e = getFirstUpParent(request))) {
-        hierarchyNote(request, HIER_FIRSTUP_PARENT, 0, e->host);
+       hierarchyNote(request, HIER_FIRSTUP_PARENT, 0, e->host);
     }
     sslState->proxying = e ? 1 : 0;
     sslState->host = e ? e->host : request->host;
     if (e == NULL) {
-        sslState->port = request->port;
+       sslState->port = request->port;
     } else if (e->http_port != 0) {
-        sslState->port = e->http_port;
+       sslState->port = e->http_port;
     } else if ((g = neighborFindByName(e->host))) {
-        sslState->port = g->http_port;
+       sslState->port = g->http_port;
     } else {
-        sslState->port = CACHE_HTTP_PORT;
+       sslState->port = CACHE_HTTP_PORT;
     }
     ipcache_nbgethostbyname(sslState->host,
        sslState->server.fd,
index 2d94dd904776cfd9e9df3e625eb604e688ea17b8..bababaadcef61c140c55f5a207a76aa549e0e8ff 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: url.cc,v 1.50 1996/12/05 21:23:57 wessels Exp $
+ * $Id: url.cc,v 1.51 1996/12/17 07:16:59 wessels Exp $
  *
  * DEBUG: section 23    URL Parsing
  * AUTHOR: Duane Wessels
@@ -38,7 +38,8 @@ const char *RequestMethodStr[] =
     "POST",
     "PUT",
     "HEAD",
-    "CONNECT"
+    "CONNECT",
+    "TRACE"
 };
 
 static char *ProtocolStr[] =
@@ -140,6 +141,8 @@ urlParseMethod(const char *s)
        return METHOD_HEAD;
     } else if (strcasecmp(s, "CONNECT") == 0) {
        return METHOD_CONNECT;
+    } else if (strcasecmp(s, "TRACE") == 0) {
+       return METHOD_TRACE;
     }
     return METHOD_NONE;
 }
@@ -252,6 +255,7 @@ urlParse(method_t method, char *url)
     request->port = (u_short) port;
     xstrncpy(request->urlpath, urlpath, MAX_URL);
     request->max_age = -1;
+    request->max_forwards = -1;
     return request;
 }
 
@@ -324,6 +328,8 @@ urlCheckRequest(const request_t * r)
     int rc = 0;
     if (r->method == METHOD_CONNECT)
        return 1;
+    if (r->method == METHOD_TRACE)
+       return 1;
     switch (r->protocol) {
     case PROTO_HTTP:
     case PROTO_CACHEOBJ: