]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
removed lots of alex #if 0 code
authorwessels <>
Thu, 5 Mar 1998 07:16:24 +0000 (07:16 +0000)
committerwessels <>
Thu, 5 Mar 1998 07:16:24 +0000 (07:16 +0000)
src/client_side.cc

index 1c61a46fea06f01ace6d8f6349f9ac94ddf31636..47bd82845f5aaf0a07731f95fea2f47c43a6fbfb 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.219 1998/03/03 00:31:04 rousskov Exp $
+ * $Id: client_side.cc,v 1.220 1998/03/05 00:16:24 wessels Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -46,9 +46,6 @@ static PF clientReadRequest;
 static PF connStateFree;
 static PF requestTimeout;
 static STCB clientGetHeadersForIMS;
-#if 0
-static char *clientConstruct304reply(struct _http_reply *);
-#endif
 static int CheckQuickAbort2(const clientHttpRequest *);
 static int clientCheckTransferDone(clientHttpRequest *);
 static void CheckQuickAbort(clientHttpRequest *);
@@ -66,11 +63,7 @@ static STCB clientCacheHit;
 static void clientParseRequestHeaders(clientHttpRequest *);
 static void clientProcessRequest(clientHttpRequest *);
 static void clientProcessExpired(void *data);
-#if 0
-static char *clientConstructProxyAuthReply(clientHttpRequest * http);
-#else
 static HttpReply *clientConstructProxyAuthReply(clientHttpRequest * http);
-#endif
 static int clientCachable(clientHttpRequest * http);
 static int clientHierarchical(clientHttpRequest * http);
 static int isTcpHit(log_type code);
@@ -114,57 +107,6 @@ clientAccessCheck(void *data)
     aclNBCheck(http->acl_checklist, clientAccessCheckDone, http);
 }
 
-#if 0                          /* reimplemented using new interfaces */
-static char *
-clientConstructProxyAuthReply(clientHttpRequest * http)
-{
-    LOCAL_ARRAY(char, buf, 8192);
-    LOCAL_ARRAY(char, content, 4096);
-    char *hdr;
-    memset(buf, '\0', 8192);
-    memset(content, '\0', 4096);
-    snprintf(content, 4096,
-       "<TITLE>Cache Access Denied</TITLE>\n"
-       "<H2>Cache Access Denied</H2>\n"
-       "<P>\n"
-       "Sorry, you are not currently allowed to request:\n"
-       "<PRE>    %s</PRE>\n"
-       "from this cache until you have authenticated yourself.\n"
-       "\n<p>"
-       "You need to use Netscape version 2.0 or greater, or Microsoft\n"
-       "Internet Explorer 3.0 or an HTTP/1.1 compliant browser for this\n"
-       "to work.  Please contact the <a href=\"mailto:%s\">cache\n"
-       "administrator</a> if you have difficulties authenticating\n"
-       "yourself, or\n"
-       "<a href=\"http://%s/cgi-bin/chpasswd.cgi\">change</a> your\n"
-       "default password.\n"
-       "<P>\n"
-       "%s\n"
-       "<HR>\n"
-       "<ADDRESS>\n"
-       "Generated by %s/%s@%s\n"
-       "</ADDRESS>\n",
-       http->uri,
-       Config.adminEmail,
-       getMyHostname(),
-       Config.errHtmlText,
-       appname,
-       version_string,
-       getMyHostname());
-    hdr = httpReplyHeader(1.0,
-       HTTP_PROXY_AUTHENTICATION_REQUIRED,
-       "text/html",
-       strlen(content),
-       0,
-       squid_curtime);
-    snprintf(buf, 8192, "%s%s\r\n%s",
-       hdr,
-       proxy_auth_line,
-       content);
-    return buf;
-}
-#endif
-
 static HttpReply *
 clientConstructProxyAuthReply(clientHttpRequest * http)
 {
@@ -206,6 +148,7 @@ clientAccessCheckDone(int answer, void *data)
     clientHttpRequest *http = data;
     char *redirectUrl = NULL;
     ErrorState *err = NULL;
+    HttpReply *rep;
     debug(33, 5) ("clientAccessCheckDone: '%s' answer=%d\n", http->uri, answer);
     http->acl_checklist = NULL;
     if (answer == ACCESS_ALLOWED) {
@@ -217,18 +160,11 @@ clientAccessCheckDone(int answer, void *data)
        http->al.http.code = HTTP_PROXY_AUTHENTICATION_REQUIRED;
        http->log_type = LOG_TCP_DENIED;
        http->entry = clientCreateStoreEntry(http, http->request->method, 0);
-#if 0
-       const char *buf = clientConstructProxyAuthReply(http);
-       storeAppend(http->entry, buf, strlen(buf));
-#else
-       {
-           /* create appropreate response */
-           HttpReply *rep = clientConstructProxyAuthReply(http);
-           httpReplySwapOut(rep, http->entry);
-           /* do not need it anymore */
-           httpReplyDestroy(rep);
-       }
-#endif
+       /* create appropreate response */
+       rep = clientConstructProxyAuthReply(http);
+       httpReplySwapOut(rep, http->entry);
+       /* do not need it anymore */
+       httpReplyDestroy(rep);
     } else {
        debug(33, 5) ("Access Denied: %s\n", http->uri);
        http->log_type = LOG_TCP_DENIED;
@@ -502,18 +438,10 @@ void
 clientPurgeRequest(clientHttpRequest * http)
 {
     int fd = http->conn->fd;
-#if 0
-    char *msg;
-#endif
     StoreEntry *entry;
     ErrorState *err = NULL;
     const cache_key *k;
-#if 0
-    int len;
-    FREE *freefunc;
-#endif
     MemBuf mb;
-
     debug(33, 3) ("Config.onoff.enable_purge = %d\n", Config.onoff.enable_purge);
     if (!Config.onoff.enable_purge) {
        http->log_type = LOG_TCP_DENIED;
@@ -532,15 +460,8 @@ clientPurgeRequest(clientHttpRequest * http)
        storeRelease(entry);
        http->http_code = HTTP_OK;
     }
-#if 0                          /* new interface */
-    msg = httpReplyHeader(1.0, http->http_code, NULL, 0, 0, -1);
-    if ((int) strlen(msg) < 8190)
-       strcat(msg, "\r\n");
-    comm_write(fd, xstrdup(msg), strlen(msg), clientWriteComplete, http, xfree);
-#else
     mb = httpPackedReply(1.0, http->http_code, NULL, 0, 0, -1);
     comm_write_mbuf(fd, mb, clientWriteComplete, http);
-#endif
 }
 
 int
@@ -1088,11 +1009,7 @@ clientWriteComplete(int fd, char *bufnotused, size_t size, int errflag, void *da
     } else if ((done = clientCheckTransferDone(http)) != 0 || size == 0) {
        debug(33, 5) ("clientWriteComplete: FD %d transfer is DONE\n", fd);
        /* We're finished case */
-#if 0
-       if (http->entry->mem_obj->reply->content_length < 0 || !done ||
-#else
        if (httpReplyContentLen(http->entry->mem_obj->reply) < 0 || !done ||
-#endif
            EBIT_TEST(entry->flag, ENTRY_BAD_LENGTH)) {
            /* 
             * Client connection closed due to unknown or invalid
@@ -1154,10 +1071,6 @@ clientGetHeadersForIMS(void *data, char *buf, ssize_t size)
     clientHttpRequest *http = data;
     StoreEntry *entry = http->entry;
     MemObject *mem;
-#if 0
-    MemObject *mem;
-    char *reply = NULL;
-#endif
     debug(33, 3) ("clientGetHeadersForIMS: %s, %d bytes\n",
        http->uri, (int) size);
     assert(size <= SM_PAGE_SIZE);
@@ -1241,18 +1154,8 @@ clientGetHeadersForIMS(void *data, char *buf, ssize_t size)
        return;
     }
     debug(33, 4) ("clientGetHeadersForIMS: Not modified '%s'\n", storeUrl(entry));
-#if 0                          /* use new interfaces */
-    reply = clientConstruct304reply(mem->reply);
-    comm_write(http->conn->fd,
-       xstrdup(reply),
-       strlen(reply),
-       clientHandleIMSComplete,
-       http,
-       xfree);
-#else
     comm_write_mbuf(http->conn->fd, httpPacked304Reply(mem->reply),
        clientHandleIMSComplete, http);
-#endif
 }
 
 static void
@@ -1331,9 +1234,7 @@ clientProcessRequest(clientHttpRequest * http)
     StoreEntry *entry = NULL;
     request_t *r = http->request;
     int fd = http->conn->fd;
-#if 0
-    char *hdr;
-#endif
+    HttpReply *rep;
     debug(33, 4) ("clientProcessRequest: %s '%s'\n",
        RequestMethodStr[r->method],
        url);
@@ -1349,23 +1250,10 @@ clientProcessRequest(clientHttpRequest * http)
            http->entry = clientCreateStoreEntry(http, r->method, 0);
            storeReleaseRequest(http->entry);
            storeBuffer(http->entry);
-#if 0                          /* use new interface */
-           hdr = httpReplyHeader(1.0,
-               HTTP_OK,
-               "text/plain",
-               r->headers_sz,
-               0,
-               squid_curtime);
-           storeAppend(http->entry, hdr, strlen(hdr));
-           storeAppend(http->entry, "\r\n", 2);
-#else
-           {
-               HttpReply *rep = httpReplyCreate();
-               httpReplySetHeaders(rep, 1.0, HTTP_OK, NULL, "text/plain", r->headers_sz, 0, squid_curtime);
-               httpReplySwapOut(rep, http->entry);
-               httpReplyDestroy(rep);
-           }
-#endif
+           rep = httpReplyCreate();
+           httpReplySetHeaders(rep, 1.0, HTTP_OK, NULL, "text/plain", r->headers_sz, 0, squid_curtime);
+           httpReplySwapOut(rep, http->entry);
+           httpReplyDestroy(rep);
            storeAppend(http->entry, r->headers, r->headers_sz);
            storeComplete(http->entry);
            return;
@@ -1972,11 +1860,7 @@ CheckQuickAbort2(const clientHttpRequest * http)
        return 1;
     if (http->entry->mem_obj == NULL)
        return 1;
-#if 0
-    expectlen = http->entry->mem_obj->reply->content_length;
-#else
     expectlen = httpReplyContentLen(http->entry->mem_obj->reply);
-#endif
     curlen = http->entry->mem_obj->inmem_hi;
     minlen = Config.quickAbort.min;
     if (minlen < 0)
@@ -2082,40 +1966,6 @@ clientCheckTransferDone(clientHttpRequest * http)
        return 1;
 }
 
-#if 0                          /* moved to HttpReply */
-static char *
-clientConstruct304reply(http_reply * source)
-{
-    LOCAL_ARRAY(char, line, 256);
-    LOCAL_ARRAY(char, reply, 8192);
-    memset(reply, '\0', 8192);
-    strcpy(reply, "HTTP/1.0 304 Not Modified\r\n");
-    if (source->date > -1) {
-       snprintf(line, 256, "Date: %s\r\n", mkrfc1123(source->date));
-       strcat(reply, line);
-    }
-    if ((int) strlen(source->content_type) > 0) {
-       snprintf(line, 256, "Content-type: %s\r\n", source->content_type);
-       strcat(reply, line);
-    }
-    if (source->content_length) {
-       snprintf(line, 256, "Content-length: %d\r\n", source->content_length);
-       strcat(reply, line);
-    }
-    if (source->expires > -1) {
-       snprintf(line, 256, "Expires: %s\r\n", mkrfc1123(source->expires));
-       strcat(reply, line);
-    }
-    if (source->last_modified > -1) {
-       snprintf(line, 256, "Last-modified: %s\r\n",
-           mkrfc1123(source->last_modified));
-       strcat(reply, line);
-    }
-    strcat(reply, "\r\n");
-    return reply;
-}
-#endif
-
 /*
  * This function is designed to serve a fairly specific purpose.
  * Occasionally our vBNS-connected caches can talk to each other, but not