]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
More decoupling work:
authorrobertc <>
Tue, 9 May 2006 05:38:33 +0000 (05:38 +0000)
committerrobertc <>
Tue, 9 May 2006 05:38:33 +0000 (05:38 +0000)
 Add a URL and URLScheme class to allow separating the url parsing logic from
 HTTPRequest logic which are currently bi-dependent.
 Add HttpRequestMethod class to replace the enum method_t, start using it.
 Split squid_curtime out from globals and tools, so you can get access to time
 without dragging in other dependencies.

91 files changed:
src/ACLMethodData.cc
src/ACLProtocolData.cc
src/ACLTime.cc
src/AuthUserRequest.cc
src/DiskIO/DiskDaemon/DiskdIOStrategy.cc
src/DiskIO/DiskThreads/aiops.cc
src/ExternalACLEntry.cc
src/HttpHeader.h
src/HttpReply.cc
src/HttpRequest.cc
src/HttpRequest.h
src/HttpRequestMethod.cc [new file with mode: 0644]
src/HttpRequestMethod.h [new file with mode: 0644]
src/ICAP/ICAPModXact.cc
src/ICAP/ICAPOptions.cc
src/ICAP/ICAPServiceRep.cc
src/Makefile.am
src/SquidTime.h [new file with mode: 0644]
src/URL.h [new file with mode: 0644]
src/URLScheme.cc [new file with mode: 0644]
src/URLScheme.h [new file with mode: 0644]
src/access_log.cc
src/auth/basic/auth_basic.cc
src/cache_cf.cc
src/cache_manager.cc
src/cf_gen.cc
src/client_db.cc
src/client_side.cc
src/client_side_reply.cc
src/client_side_request.cc
src/comm.cc
src/comm_poll.cc
src/debug.cc
src/defines.h
src/delay_pools.cc
src/dns_internal.cc
src/enums.h
src/errorpage.cc
src/external_acl.cc
src/fd.cc
src/fde.cc
src/forward.cc
src/fqdncache.cc
src/fs/ufs/store_dir_ufs.cc
src/ftp.cc
src/globals.h
src/gopher.cc
src/helper.cc
src/htcp.cc
src/http.cc
src/icp_v2.cc
src/internal.cc
src/ipcache.cc
src/main.cc
src/mem.cc
src/neighbors.cc
src/net_db.cc
src/peer_digest.cc
src/pinger.cc
src/protos.h
src/refresh.cc
src/repl/heap/store_heap_replacement.cc
src/repl/lru/store_repl_lru.cc
src/send-announce.cc
src/store.cc
src/store_digest.cc
src/store_dir.cc
src/store_rebuild.cc
src/structs.h
src/tests/stub_tools.cc
src/tests/testCoss.cc
src/tests/testHeader_HttpRequestMethod.cc [new file with mode: 0644]
src/tests/testHeader_URL.cc [new file with mode: 0644]
src/tests/testHeader_URLScheme.cc [new file with mode: 0644]
src/tests/testHttpRequestMethod.cc [new file with mode: 0644]
src/tests/testHttpRequestMethod.h [new file with mode: 0644]
src/tests/testNull.cc
src/tests/testStoreController.cc
src/tests/testStoreHashIndex.cc
src/tests/testURL.cc [new file with mode: 0644]
src/tests/testURL.h [new file with mode: 0644]
src/tests/testURLScheme.cc [new file with mode: 0644]
src/tests/testURLScheme.h [new file with mode: 0644]
src/tests/testUfs.cc
src/time.cc
src/tools.cc
src/typedefs.h
src/url.cc
src/urn.cc
src/wais.cc
test-suite/Makefile.am

index 54bab8d372d05d73b170d4570c0a2d2c05385e33..427b8ff1931ce4a8b1d52262e1638bf922eae022 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ACLMethodData.cc,v 1.8 2006/04/23 11:10:31 robertc Exp $
+ * $Id: ACLMethodData.cc,v 1.9 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -37,6 +37,7 @@
 #include "squid.h"
 #include "ACLMethodData.h"
 #include "ACLChecklist.h"
+#include "HttpRequestMethod.h"
 #include "wordlist.h"
 
 ACLMethodData::ACLMethodData() : values (NULL)
@@ -88,7 +89,7 @@ ACLMethodData::parse()
 
         ;
     while ((t = strtokFile())) {
-        List<method_t> *q = new List<method_t> (urlParseMethod(t));
+        List<method_t> *q = new List<method_t> (HttpRequestMethod(t));
         *(Tail) = q;
         Tail = &q->next;
     }
index e934258395f5f1977d2707bc73a4181aeb21da4b..5575e1eb53ba78d4610f5ad95f7bb81c9a027c14 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ACLProtocolData.cc,v 1.7 2006/04/23 11:10:31 robertc Exp $
+ * $Id: ACLProtocolData.cc,v 1.8 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -37,6 +37,7 @@
 #include "squid.h"
 #include "ACLProtocolData.h"
 #include "ACLChecklist.h"
+#include "URLScheme.h"
 #include "wordlist.h"
 
 ACLProtocolData::ACLProtocolData() : values (NULL)
index f888cdace16d8f7b97714e529897b34a746740a5..828109a5c9d11697ab3bc902782ea053c905d34a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: ACLTime.cc,v 1.1 2003/02/17 07:01:34 robertc Exp $
+ * $Id: ACLTime.cc,v 1.2 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 28    Access Control
  * AUTHOR: Duane Wessels
@@ -37,6 +37,7 @@
 #include "squid.h"
 #include "ACLTime.h"
 #include "ACLTimeData.h"
+#include "SquidTime.h"
 
 ACL::Prototype ACLTime::RegistryProtoype(&ACLTime::RegistryEntry_, "time");
 ACLStrategised<time_t> ACLTime::RegistryEntry_(new ACLTimeData, ACLTimeStrategy::Instance(), "time");
index 759a4a7bf87086b58de3d551190c9eb6abbf2064..ead27d4d43b3f56202ade37b42530361184544a8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: AuthUserRequest.cc,v 1.7 2006/05/06 22:13:18 wessels Exp $
+ * $Id: AuthUserRequest.cc,v 1.8 2006/05/08 23:38:33 robertc Exp $
  *
  * DO NOT MODIFY NEXT 2 LINES:
  * arch-tag: 6803fde1-d5a2-4c29-9034-1c0c9f650eb4
@@ -51,6 +51,7 @@
 #include "AuthScheme.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
+#include "SquidTime.h"
 
 CBDATA_TYPE(auth_user_ip_t);
 
index 6986c2d89b4d36c01f9b69dcaf63729b43e53139..5c6c3062094efa81aadfd926e53696eae29c134c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: DiskdIOStrategy.cc,v 1.3 2006/05/08 19:57:30 wessels Exp $
+ * $Id: DiskdIOStrategy.cc,v 1.4 2006/05/08 23:38:34 robertc Exp $
  *
  * DEBUG: section 79    Squid-side DISKD I/O functions.
  * AUTHOR: Duane Wessels
@@ -46,6 +46,7 @@
 #include "diomsg.h"
 /* for statfs */
 #include "Store.h"
+#include "SquidTime.h"
 
 diskd_stats_t diskd_stats;
 
index 744461382c65c13e732fe3e81566b2999cf22dba..155765ab52dbfa99bb4327b1cd162f384f7ce0b6 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: aiops.cc,v 1.6 2005/07/10 15:43:30 serassio Exp $
+ * $Id: aiops.cc,v 1.7 2006/05/08 23:38:34 robertc Exp $
  *
  * DEBUG: section 43    AIOPS
  * AUTHOR: Stewart Forster <slf@connect.com.au>
@@ -51,6 +51,7 @@
 #include       <sched.h>
 #endif
 #include "CommIO.h"
+#include "SquidTime.h"
 
 #define RIDICULOUS_LENGTH      4096
 
index 88ffbe6b6b33f086bdb0a415f87d0b91e7ab4258..c6b5c31c8258dd34e3acecf544e0c32fb5de34d4 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ExternalACLEntry.cc,v 1.5 2003/08/04 22:14:40 robertc Exp $
+ * $Id: ExternalACLEntry.cc,v 1.6 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 82    External ACL
  * AUTHOR: Henrik Nordstrom, MARA Systems AB
@@ -43,6 +43,7 @@
 
 #include "squid.h"
 #include "ExternalACLEntry.h"
+#include "SquidTime.h"
 
 /******************************************************************
  * external_acl cache
index c840935d3dd6948f87b84e6c0bd2fbd5a9a6e560..f97bf44b120135eb4b6220f490911f0cd9ba549f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpHeader.h,v 1.12 2006/05/08 20:59:28 wessels Exp $
+ * $Id: HttpHeader.h,v 1.13 2006/05/08 23:38:33 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -149,8 +149,22 @@ class HttpVersion;
 
 class HttpHdrContRange;
 
+class HttpHdrCc;
+
 class HttpHdrSc;
 
+/*iteration for headers; use HttpHeaderPos as opaque type, do not interpret */
+typedef ssize_t HttpHeaderPos;
+
+/* use this and only this to initialize HttpHeaderPos */
+#define HttpHeaderInitPos (-1)
+
+/* these two are defined in  structs.h */
+
+typedef struct _TimeOrTag TimeOrTag;
+
+typedef struct _ETag ETag;
+
 class HttpHeaderEntry
 {
 
index b46107ecfe30a3caa45ee55fc69ce98b5a7618ec..8a3e6b6cd5747749f5ba65fa9cb64b16af52eea0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpReply.cc,v 1.87 2006/05/08 20:59:28 wessels Exp $
+ * $Id: HttpReply.cc,v 1.88 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 58    HTTP Reply (Response)
  * AUTHOR: Alex Rousskov
@@ -34,6 +34,7 @@
  */
 
 #include "squid.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "HttpReply.h"
 #include "HttpHdrContRange.h"
index 0a243c6e66021055cd8a52d284347f8904af3c66..f2106aa1fc4eafc546dcb2f44996e0f156e3fe00 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpRequest.cc,v 1.65 2006/05/06 22:13:18 wessels Exp $
+ * $Id: HttpRequest.cc,v 1.66 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 73    HTTP Request
  * AUTHOR: Duane Wessels
@@ -152,7 +152,7 @@ HttpRequest::sanityCheckStartLine(MemBuf *buf, http_status *error)
      * superfluous and could just go away.
      */
 
-    if (METHOD_NONE == urlParseMethod(buf->content())) {
+    if (METHOD_NONE == HttpRequestMethod(buf->content())) {
         debug(73, 3)("HttpRequest::sanityCheckStartLine: did not find HTTP request method\n");
         return false;
     }
@@ -164,7 +164,7 @@ bool
 HttpRequest::parseFirstLine(const char *start, const char *end)
 {
     const char *t = start + strcspn(start, w_space);
-    method = urlParseMethod(start, t);
+    method = HttpRequestMethod(start, t);
 
     if (METHOD_NONE == method)
         return false;
index 1a34c067d6e7fa5addb50d6e8c198efe31d7ed42..6add8ee3d3f2c6c2433e5fed26831539f66cf1e0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpRequest.h,v 1.21 2006/05/03 14:04:44 robertc Exp $
+ * $Id: HttpRequest.h,v 1.22 2006/05/08 23:38:33 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -38,6 +38,7 @@
 #include "client_side.h"
 #include "HierarchyLogEntry.h"
 #include "BodyReader.h"
+#include "HttpRequestMethod.h"
 
 /*  Http Request */
 extern int httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConnection);
diff --git a/src/HttpRequestMethod.cc b/src/HttpRequestMethod.cc
new file mode 100644 (file)
index 0000000..1f8940e
--- /dev/null
@@ -0,0 +1,177 @@
+
+/*
+ * $Id: HttpRequestMethod.cc,v 1.1 2006/05/08 23:38:33 robertc Exp $
+ *
+ * DEBUG: section 73    HTTP Request
+ * AUTHOR: Duane Wessels
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ * Copyright (c) 2003, Robert Collins <robertc@squid-cache.org>
+ */
+
+#include "squid.h"
+#include "HttpRequestMethod.h"
+#include "wordlist.h"
+
+const char *RequestMethodStr[] =
+    {
+        "NONE",
+        "GET",
+        "POST",
+        "PUT",
+        "HEAD",
+        "CONNECT",
+        "TRACE",
+        "PURGE",
+        "OPTIONS",
+        "DELETE",
+        "PROPFIND",
+        "PROPPATCH",
+        "MKCOL",
+        "COPY",
+        "MOVE",
+        "LOCK",
+        "UNLOCK",
+        "BMOVE",
+        "BDELETE",
+        "BPROPFIND",
+        "BPROPPATCH",
+        "BCOPY",
+        "SEARCH",
+        "SUBSCRIBE",
+        "UNSUBSCRIBE",
+        "POLL",
+        "REPORT",
+        "%EXT00",
+        "%EXT01",
+        "%EXT02",
+        "%EXT03",
+        "%EXT04",
+        "%EXT05",
+        "%EXT06",
+        "%EXT07",
+        "%EXT08",
+        "%EXT09",
+        "%EXT10",
+        "%EXT11",
+        "%EXT12",
+        "%EXT13",
+        "%EXT14",
+        "%EXT15",
+        "%EXT16",
+        "%EXT17",
+        "%EXT18",
+        "%EXT19",
+        "ERROR"
+    };
+
+static
+method_t &operator++ (method_t &aMethod)
+{
+    int tmp = (int)aMethod;
+    aMethod = (method_t)(++tmp);
+    return aMethod;
+}
+
+/*
+ * Construct a HttpRequestMethod from a NULL terminated string such as "GET"
+ * or from a range of chars, * such as "GET" from "GETFOOBARBAZ" 
+ * (pass in pointer to G and pointer to F.)
+ */
+HttpRequestMethod::HttpRequestMethod(char const *begin, char const *end) : theMethod (METHOD_NONE)
+{
+    if (begin == NULL)
+        return;
+
+    /*
+     * This check for '%' makes sure that we don't
+     * match one of the extension method placeholders,
+     * which have the form %EXT[0-9][0-9]
+     */
+
+    if (*begin == '%')
+        return;
+
+    /*
+     * if e is NULL, b must be NULL terminated and we
+     * make e point to the first whitespace character
+     * after b.
+     */
+    if (NULL == end)
+        end = begin + strcspn(begin, w_space);
+
+    for (++theMethod; theMethod < METHOD_ENUM_END; ++theMethod) {
+        if (0 == strncasecmp(begin, RequestMethodStr[theMethod], end-begin))
+            return;
+    }
+
+    /* reset to none */
+    theMethod = METHOD_NONE;
+}
+
+void
+HttpRequestMethod::AddExtension(const char *mstr)
+{
+    method_t method = METHOD_NONE;
+
+    for (++method; method < METHOD_ENUM_END; ++method) {
+        if (0 == strcmp(mstr, RequestMethodStr[method])) {
+            debug(23, 2) ("Extension method '%s' already exists\n", mstr);
+            return;
+        }
+
+        if (0 != strncmp("%EXT", RequestMethodStr[method], 4))
+            continue;
+
+        /* Don't free statically allocated "%EXTnn" string */
+        RequestMethodStr[method] = xstrdup(mstr);
+
+        debug(23, 1) ("Extension method '%s' added, enum=%d\n", mstr, (int) method);
+
+        return;
+    }
+
+    debug(23, 1) ("WARNING: Could not add new extension method '%s' due to lack of array space\n", mstr);
+}
+
+void
+HttpRequestMethod::Configure(SquidConfig &Config)
+{
+    wordlist *w = Config.ext_methods;
+
+    while (w) {
+        char *s;
+
+        for (s = w->key; *s; s++)
+            *s = xtoupper(*s);
+
+        AddExtension(w->key);
+
+        w = w->next;
+    }
+}
diff --git a/src/HttpRequestMethod.h b/src/HttpRequestMethod.h
new file mode 100644 (file)
index 0000000..d19c91f
--- /dev/null
@@ -0,0 +1,147 @@
+
+/*
+ * $Id: HttpRequestMethod.h,v 1.1 2006/05/08 23:38:33 robertc Exp $
+ *
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#ifndef SQUID_HTTPREQUESTMETHOD_H
+#define SQUID_HTTPREQUESTMETHOD_H
+
+#include <iosfwd>
+
+enum _method_t {
+    METHOD_NONE,               /* 000 */
+    METHOD_GET,                        /* 001 */
+    METHOD_POST,               /* 010 */
+    METHOD_PUT,                        /* 011 */
+    METHOD_HEAD,               /* 100 */
+    METHOD_CONNECT,            /* 101 */
+    METHOD_TRACE,              /* 110 */
+    METHOD_PURGE,              /* 111 */
+    METHOD_OPTIONS,
+    METHOD_DELETE,             /* RFC2616 section 9.7 */
+    METHOD_PROPFIND,
+    METHOD_PROPPATCH,
+    METHOD_MKCOL,
+    METHOD_COPY,
+    METHOD_MOVE,
+    METHOD_LOCK,
+    METHOD_UNLOCK,
+    METHOD_BMOVE,
+    METHOD_BDELETE,
+    METHOD_BPROPFIND,
+    METHOD_BPROPPATCH,
+    METHOD_BCOPY,
+    METHOD_SEARCH,
+    METHOD_SUBSCRIBE,
+    METHOD_UNSUBSCRIBE,
+    METHOD_POLL,
+    METHOD_REPORT,
+    METHOD_EXT00,
+    METHOD_EXT01,
+    METHOD_EXT02,
+    METHOD_EXT03,
+    METHOD_EXT04,
+    METHOD_EXT05,
+    METHOD_EXT06,
+    METHOD_EXT07,
+    METHOD_EXT08,
+    METHOD_EXT09,
+    METHOD_EXT10,
+    METHOD_EXT11,
+    METHOD_EXT12,
+    METHOD_EXT13,
+    METHOD_EXT14,
+    METHOD_EXT15,
+    METHOD_EXT16,
+    METHOD_EXT17,
+    METHOD_EXT18,
+    METHOD_EXT19,
+    METHOD_ENUM_END
+};
+
+typedef enum _method_t method_t;
+
+/* For the definition of NULL */
+#include "squid.h"
+
+extern const char *RequestMethodStr[];
+
+/* forward decls */
+
+typedef struct _SquidConfig SquidConfig;
+
+
+/* This class represents an HTTP Request METHOD - i.e.
+ * PUT, POST, GET etc. It has a runtime extensionf acility to allow it to
+ * efficiently support new methods
+ */
+
+class HttpRequestMethod
+{
+
+public:
+    static void AddExtension(const char *methodString);
+    static void Configure(SquidConfig &Config);
+
+    HttpRequestMethod() : theMethod(METHOD_NONE) {}
+
+    HttpRequestMethod(method_t const aMethod) : theMethod(aMethod) {}
+
+    HttpRequestMethod(char const * begin, char const * end=NULL);
+
+    operator method_t() const {return theMethod; }
+
+    HttpRequestMethod & operator = (method_t const aMethod)
+    {
+        theMethod = aMethod;
+        return *this;
+    }
+
+    bool operator != (method_t const & aMethod) { return theMethod != aMethod;}
+
+    /* Get a char string representation of the method. */
+    char const *const_str() const { return RequestMethodStr[theMethod]; }
+
+private:
+    method_t theMethod;
+
+};
+
+inline bool operator != (HttpRequestMethod const &left, method_t const &right) { return right != left; }
+
+inline std::ostream &
+operator << (std::ostream &os, HttpRequestMethod const &method)
+{
+    os << method.const_str();
+    return os;
+}
+
+#endif /* SQUID_HTTPREQUESTMETHOD_H */
index 75379587c27543f5e2f0b617dde4cdcd913a07bb..565ce9ff24b3fdc4dfaa5bf3ae0cadba3b0ee206 100644 (file)
@@ -15,6 +15,7 @@
 #include "TextException.h"
 #include "AuthUserRequest.h"
 #include "ICAPConfig.h"
+#include "SquidTime.h"
 
 // flow and terminology:
 //     HTTP| --> receive --> encode --> write --> |network
index 43a523bbab4c6d87e53da5be4cb16e2dadfe5ad9..0ffae1b28c4ed959bb7ebf2d5b0958390da18767 100644 (file)
@@ -3,6 +3,7 @@
 #include "ICAPOptions.h"
 #include "TextException.h"
 #include "ICAPConfig.h"
+#include "SquidTime.h"
 
 extern ICAPConfig TheICAPConfig;
 
index 7ddcad7e2d7d3df7e18b8439a430fb8df3017527..cbd18e76bd030568dc529197d5a655e46406641d 100644 (file)
@@ -8,6 +8,7 @@
 #include "ICAPOptions.h"
 #include "ICAPOptXact.h"
 #include "ConfigParser.h"
+#include "SquidTime.h"
 
 CBDATA_CLASS_INIT(ICAPServiceRep);
 
index 803d0c38e5289b15040946f68ecab3598eb1515b..c05e0bab501980b56db80a0add598d5cae58b810 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.am,v 1.141 2006/05/06 12:38:01 serassio Exp $
+#  $Id: Makefile.am,v 1.142 2006/05/08 23:38:33 robertc Exp $
 #
 #  Uncomment and customize the following to suit your needs:
 #
@@ -201,7 +201,7 @@ libexec_PROGRAMS = \
        $(UNLINKD) \
        cachemgr$(CGIEXT)
 
-cf_gen_SOURCES = cf_gen.cc defines.h debug.cc
+cf_gen_SOURCES = cf_gen.cc defines.h debug.cc time.cc
 nodist_cf_gen_SOURCES = globals.cc
 nodist_cf_gen_HEADER = cf_gen_defines.h
 cf_gen.$(OBJEXT): cf_gen_defines.h
@@ -442,6 +442,8 @@ squid_SOURCES = \
        HttpReply.h \
        HttpRequest.cc \
        HttpRequest.h \
+       HttpRequestMethod.cc \
+       HttpRequestMethod.h \
        HttpVersion.h \
        icmp.cc \
        ICP.h \
@@ -539,6 +541,9 @@ squid_SOURCES = \
        typedefs.h \
        $(UNLINKDSOURCE) \
        url.cc \
+       URL.h \
+       URLScheme.cc \
+       URLScheme.h \
        urn.cc \
        useragent.cc \
        wais.cc \
@@ -633,6 +638,7 @@ unlinkd_CXXFLAGS = -DUNLINK_DAEMON
 pinger_SOURCES = \
        pinger.cc \
        debug.cc \
+       time.cc \
        SquidNew.cc 
 
 dnsserver_SOURCES = dnsserver.cc SquidNew.cc
@@ -740,7 +746,7 @@ ufsdump_SOURCES = \
        HttpMsg.cc \
        HttpReply.cc \
        HttpRequest.cc \
-       HttpRequest.h \
+       HttpRequestMethod.cc \
        icmp.cc \
        icp_v2.cc \
        icp_v3.cc \
@@ -800,6 +806,7 @@ ufsdump_SOURCES = \
        tools.cc \
        typedefs.h \
        $(UNLINKDSOURCE) \
+       URLScheme.cc \
        urn.cc \
        useragent.cc \
        wais.cc \
@@ -1041,6 +1048,7 @@ check_PROGRAMS+= \
        tests/testHttpRequest \
        tests/testStore \
        tests/testString \
+       tests/testURL \
        @STORE_TESTS@
 
 tests_testAuth_SOURCES= tests/testAuth.cc tests/testMain.cc  tests/testAuth.h $(TESTSOURCES) \
@@ -1058,8 +1066,11 @@ tests_testAuth_SOURCES= tests/testAuth.cc tests/testMain.cc  tests/testAuth.h $(
        tests/stub_comm.cc \
        tests/stub_http.cc \
        HttpMsg.cc \
+       HttpRequestMethod.cc \
        tests/stub_mime.cc \
        tests/stub_access_log.cc \
+       time.cc \
+       URLScheme.cc \
        wordlist.cc
 ##     acl.cc cache_cf.cc tools.cc \
 ##     helper.cc String.cc cbdata.cc HttpHeaderTools.cc store.cc cache_manager.cc \
@@ -1133,6 +1144,7 @@ tests_testACLMaxUserIP_SOURCES= \
        tests/testACLMaxUserIP.cc \
        tests/testACLMaxUserIP.h \
        tests/testMain.cc \
+       time.cc \
        mem.cc \
        MemBuf.cc \
        wordlist.cc \
@@ -1148,7 +1160,12 @@ tests_testACLMaxUserIP_DEPENDENCIES = \
 
 ## a demonstration test that does nothing but shows the salient points
 ## involved in writing tests.
-tests_testBoilerplate_SOURCES= tests/testBoilerplate.cc tests/testMain.cc tests/testBoilerplate.h $(TESTSOURCES)
+tests_testBoilerplate_SOURCES = \
+       tests/testBoilerplate.cc \
+       tests/testMain.cc \
+       tests/testBoilerplate.h \
+       $(TESTSOURCES) \
+       time.cc
 tests_testBoilerplate_LDADD= \
        -L../lib -lmiscutil \
        @SQUID_CPPUNIT_LA@ \
@@ -1171,7 +1188,10 @@ HEADERS_TO_TEST = \
        tests/testHeader_HttpHeader.cc \
        tests/testHeader_HttpHeaderRange.cc \
        tests/testHeader_HttpReply.cc \
+       tests/testHeader_HttpRequestMethod.cc \
        tests/testHeader_StoreEntryStream.cc \
+       tests/testHeader_URL.cc \
+       tests/testHeader_URLScheme.cc \
        tests/testHeader_wordlist.cc
 tests_testHeaders_SOURCES= tests/testMain.cc $(HEADERS_TO_TEST)
 tests_testHeaders_LDADD= \
@@ -1184,6 +1204,16 @@ tests_testHeaders_DEPENDENCIES = \
 
 ## Tests of the HttpRequest module.
 tests_testHttpRequest_SOURCES = \
+       debug.cc \
+       globals.cc \
+       HttpRequest.cc \
+       HttpRequestMethod.cc \
+       mem.cc \
+       String.cc \
+       tests/testHttpRequest.cc \
+       tests/testHttpRequestMethod.cc \
+       tests/testMain.cc \
+       time.cc \
        access_log.cc \
        acl.cc \
        acl_noncore.cc \
@@ -1216,7 +1246,6 @@ tests_testHttpRequest_SOURCES = \
        ConfigOption.cc \
        ConfigParser.cc \
        $(DELAY_POOL_SOURCE) \
-       debug.cc \
        disk.cc \
        $(DNSSOURCE) \
        event.cc \
@@ -1230,7 +1259,6 @@ tests_testHttpRequest_SOURCES = \
        forward.cc \
        fqdncache.cc \
        ftp.cc \
-       globals.cc \
        gopher.cc \
        helper.cc \
        htcp.cc \
@@ -1244,7 +1272,6 @@ tests_testHttpRequest_SOURCES = \
        HttpHdrSc.cc \
        HttpHdrScTarget.cc \
        HttpMsg.cc \
-       HttpRequest.cc \
        HttpReply.cc \
        HttpStatusLine.cc \
        icmp.cc \
@@ -1259,7 +1286,6 @@ tests_testHttpRequest_SOURCES = \
        list.cc \
        logfile.cc \
        multicast.cc \
-       mem.cc \
        mem_node.cc \
        MemBuf.cc \
        MemObject.cc \
@@ -1300,16 +1326,13 @@ tests_testHttpRequest_SOURCES = \
        StoreMetaURL.cc \
        StoreMetaVary.cc \
        StoreSwapLogData.cc \
-       String.cc \
-       time.cc \
        tools.cc \
        tunnel.cc \
        SwapDir.cc \
        url.cc \
+       URLScheme.cc \
        urn.cc \
        useragent.cc \
-       tests/testHttpRequest.cc \
-       tests/testMain.cc \
        wais.cc \
        whois.cc \
        wordlist.cc
@@ -1334,6 +1357,7 @@ tests_testHttpRequest_DEPENDENCIES =  $(top_builddir)/lib/libmiscutil.a \
 
 # TODO:mime.cc drags in HttpReply.cc
 # delay pools need client_side_request.cc
+# store_key_md5 wants the method.
 STORE_TEST_SOURCES=\
        $(TESTSOURCES) \
        $(DELAY_POOL_SOURCE) \
@@ -1342,6 +1366,7 @@ STORE_TEST_SOURCES=\
        HttpMsg.cc \
        store_dir.cc \
        store.cc \
+       HttpRequestMethod.cc \
        store_key_md5.cc \
        string_arrays.c \
        Parsing.cc \
@@ -1365,6 +1390,8 @@ STORE_TEST_SOURCES=\
        refresh.cc \
        tests/stub_store_client.cc \
        tests/stub_tools.cc \
+       time.cc \
+       URLScheme.cc \
        wordlist.cc
 
 ## why so many sources? well httpHeaderTools requites ACLChecklist & friends.
@@ -1404,7 +1431,8 @@ tests_testString_SOURCES= \
        tests/testMain.cc \
        tests/testString.cc \
        tests/testString.h \
-       $(TESTSOURCES)
+       $(TESTSOURCES) \
+       time.cc 
 
 tests_testString_LDADD= \
        -L../lib -lmiscutil \
@@ -1496,3 +1524,155 @@ tests_testNull_LDADD= \
 tests_testNull_LDFLAGS = $(LIBADD_DL)
 tests_testNull_DEPENDENCIES = \
        $(SWAP_TEST_DS)
+
+## Tests of the URL module.
+## TODO: Trim this down once the insanity is over.
+tests_testURL_SOURCES = \
+       debug.cc \
+       url.cc \
+       URLScheme.cc \
+       globals.cc \
+       HttpRequest.cc \
+       HttpRequestMethod.cc \
+       mem.cc \
+       String.cc \
+       tests/testURL.cc \
+       tests/testURL.h \
+       tests/testURLScheme.cc \
+       tests/testURLScheme.h \
+       tests/testMain.cc \
+       time.cc \
+       access_log.cc \
+       acl.cc \
+       acl_noncore.cc \
+       ACLChecklist.cc \
+       ACLProxyAuth.cc \
+       ACLStringData.cc \
+       ACLRegexData.cc \
+       ACLUserData.cc \
+       AuthConfig.cc \
+       authenticate.cc \
+       AuthUser.cc \
+       AuthUserRequest.cc \
+       AuthScheme.cc \
+       BodyReader.cc \
+       cache_manager.cc \
+       cache_cf.cc \
+       CacheDigest.cc \
+       carp.cc \
+       cbdata.cc \
+       client_db.cc \
+       client_side.cc \
+       client_side_reply.cc \
+       client_side_request.cc \
+       clientStream.cc \
+       comm.cc \
+       comm_select.cc \
+       comm_poll.cc \
+        comm_epoll.cc \
+       comm_kqueue.cc \
+       ConfigOption.cc \
+       ConfigParser.cc \
+       $(DELAY_POOL_SOURCE) \
+       disk.cc \
+       $(DNSSOURCE) \
+       event.cc \
+       errorpage.cc \
+       $(ESI_SOURCE) \
+       ETag.cc \
+       external_acl.cc \
+       ExternalACLEntry.cc \
+       fd.cc \
+       fde.cc \
+       forward.cc \
+       fqdncache.cc \
+       ftp.cc \
+       gopher.cc \
+       helper.cc \
+       htcp.cc \
+       http.cc \
+       HttpBody.cc \
+       HttpHeader.cc \
+       HttpHeaderTools.cc \
+       HttpHdrCc.cc \
+       HttpHdrContRange.cc \
+       HttpHdrRange.cc \
+       HttpHdrSc.cc \
+       HttpHdrScTarget.cc \
+       HttpMsg.cc \
+       HttpReply.cc \
+       HttpStatusLine.cc \
+       icmp.cc \
+       icp_v2.cc \
+       icp_v3.cc \
+       $(IDENT_SOURCE) \
+       ipc.cc \
+       ipcache.cc \
+       IPInterception.cc \
+       int.cc \
+       internal.cc \
+       list.cc \
+       logfile.cc \
+       multicast.cc \
+       mem_node.cc \
+       MemBuf.cc \
+       MemObject.cc \
+       mime.cc \
+       neighbors.cc \
+       net_db.cc \
+       Packer.cc \
+       Parsing.cc \
+       pconn.cc \
+       peer_digest.cc \
+       peer_select.cc \
+       redirect.cc \
+       refresh.cc \
+       Server.cc \
+       $(SNMP_SOURCE) \
+       $(SSL_SOURCE) \
+       stat.cc \
+       StatHist.cc \
+       stmem.cc \
+       store.cc \
+       store_client.cc \
+       store_digest.cc \
+       store_dir.cc \
+       store_io.cc \
+       store_key_md5.cc \
+       store_log.cc \
+       store_rebuild.cc \
+       store_swapin.cc \
+       store_swapmeta.cc \
+       store_swapout.cc \
+       StoreFileSystem.cc \
+       StoreIOState.cc \
+       StoreMeta.cc \
+       StoreMetaMD5.cc \
+       StoreMetaSTD.cc \
+       StoreMetaUnpacker.cc \
+       StoreMetaURL.cc \
+       StoreMetaVary.cc \
+       StoreSwapLogData.cc \
+       tools.cc \
+       tunnel.cc \
+       SwapDir.cc \
+       urn.cc \
+       wais.cc \
+       whois.cc \
+       wordlist.cc
+nodist_tests_testURL_SOURCES = \
+       repl_modules.cc \
+       string_arrays.c
+tests_testURL_LDADD = \
+       @REPL_OBJS@ \
+       @ICAP_LIBS@ \
+       @SSLLIB@ \
+       -L../lib -lmiscutil \
+       @XTRA_LIBS@ \
+       @SQUID_CPPUNIT_LA@ \
+       @SNMPLIB@ 
+tests_testURL_LDFLAGS = $(LIBADD_DL)
+tests_testURL_DEPENDENCIES =  $(top_builddir)/lib/libmiscutil.a \
+       @REPL_OBJS@ \
+       @SQUID_CPPUNIT_LA@ \
+       @ICAP_LIBS@
diff --git a/src/SquidTime.h b/src/SquidTime.h
new file mode 100644 (file)
index 0000000..45954e6
--- /dev/null
@@ -0,0 +1,45 @@
+
+/*
+ * $Id: SquidTime.h,v 1.1 2006/05/08 23:38:33 robertc Exp $
+ *
+ * DEBUG: section 21    Time Functions
+ * AUTHOR: Harvest Derived
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#ifndef   SQUID_TIME_H
+#define   SQUID_TIME_H
+
+#include "squid.h"
+
+extern time_t squid_curtime;   /* 0 */
+
+time_t getCurrentTime(void);
+
+#endif /* SQUID_TIME_H */
diff --git a/src/URL.h b/src/URL.h
new file mode 100644 (file)
index 0000000..7ae5166
--- /dev/null
+++ b/src/URL.h
@@ -0,0 +1,75 @@
+
+/*
+ * $Id: URL.h,v 1.1 2006/05/08 23:38:33 robertc Exp $
+ *
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#ifndef SQUID_SRC_URL_H
+#define SQUID_SRC_URL_H
+
+#include "squid.h"
+#include "MemPool.h"
+#include "URLScheme.h"
+
+/* The URL class represents a UniformResourceLocation */
+
+class URL
+{
+
+public:
+
+    MEMPROXY_CLASS(URL);
+    URL();
+    URL(URLScheme const &);
+    URLScheme const & getScheme() const {return scheme; }
+
+private:
+    /* the scheme of this URL. This has the 'type code' smell about it.
+     * In future we may want to make the methods that dispatch based on 
+     * the scheme virtual and have a class per protocol. 
+     * on the other hand, having Protocol as an explicit concept is useful,
+     * see for instance the ACLProtocol acl type. One way to represent this
+     * is to have one prototype URL with no host etc for each scheme, 
+     * another is to have an explicit scheme class, and then each URL class
+     * could be a subclass of the scheme. Another way is one instance of 
+     * a URLScheme class instance for each URLScheme we support, and one URL
+     * class for each manner of treating the scheme : a Hierarchical URL, a
+     * non-hierarchical URL etc. 
+     * Deferring the decision, its a type code for now. RBC 20060507.
+     *
+     * In order to make taking any of these routes easy, scheme is private 
+     * and immutable, only settable at construction time,
+     */
+    URLScheme const scheme;
+};
+
+MEMPROXY_CLASS_INLINE(URL);
+
+#endif /* SQUID_SRC_URL_H_H */
diff --git a/src/URLScheme.cc b/src/URLScheme.cc
new file mode 100644 (file)
index 0000000..c4bff4a
--- /dev/null
@@ -0,0 +1,58 @@
+
+/*
+ * $Id: URLScheme.cc,v 1.1 2006/05/08 23:38:33 robertc Exp $
+ *
+ * DEBUG: section 23    URL Scheme parsing
+ * AUTHOR: Robert Collins
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#include "squid.h"
+#include "URLScheme.h"
+#include "wordlist.h"
+
+const char *ProtocolStr[] =
+    {
+        "NONE",
+        "http",
+        "ftp",
+        "gopher",
+        "wais",
+        "cache_object",
+        "icp",
+#if USE_HTCP
+        "htcp",
+#endif
+        "urn",
+        "whois",
+        "internal",
+        "https",
+        "TOTAL"
+    };
+
diff --git a/src/URLScheme.h b/src/URLScheme.h
new file mode 100644 (file)
index 0000000..e6d8f7f
--- /dev/null
@@ -0,0 +1,80 @@
+
+/*
+ * $Id: URLScheme.h,v 1.1 2006/05/08 23:38:33 robertc Exp $
+ *
+ *
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *  
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+#ifndef SQUID_URLSCHEME_H
+#define SQUID_URLSCHEME_H
+
+#include <iosfwd>
+
+/* For the definition of NULL and protocol_t */
+#include "squid.h"
+
+extern const char *ProtocolStr[];
+
+/* This class represents a URL Scheme such as HTTPS, HTTP, WAIS etc.
+ * It does not represent the PROTOCOL that such schemes refer to.
+ */
+
+class URLScheme
+{
+
+public:
+    URLScheme() : theScheme(PROTO_NONE) {}
+
+    URLScheme(protocol_t const aScheme) : theScheme(aScheme) {}
+
+    operator protocol_t() const { return theScheme; }
+
+    bool operator != (protocol_t const & aProtocol) const { return theScheme != aProtocol;}
+
+    /* Get a char string representation of the scheme. */
+    char const *const_str() const { return ProtocolStr[theScheme]; }
+
+private:
+    /* This is a typecode for now - TODO make the varying methods virtual
+     * Doing that without doubling the storage size will require having
+     * something like a flyweight. perhaps the strategy pattern is appropiate:
+     * one strategy per scheme, and an object that is nothing but a pointer
+     * into the registry of schemes.
+     */
+    protocol_t theScheme;
+};
+
+inline std::ostream &
+operator << (std::ostream &os, URLScheme const &scheme)
+{
+    os << scheme.const_str();
+    return os;
+}
+
+#endif /* SQUID_URLSCHEME_H */
index dae1bc70cc47a405b4727a2515896f80a7f1dde9..402288c62bdc77d53816dfecd2f29fa92d57ceb1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: access_log.cc,v 1.111 2006/05/06 22:13:18 wessels Exp $
+ * $Id: access_log.cc,v 1.112 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 46    Access Log
  * AUTHOR: Duane Wessels
@@ -45,6 +45,7 @@
 #include "HttpReply.h"
 #include "HttpRequest.h"
 #include "MemBuf.h"
+#include "SquidTime.h"
 
 static void accessLogSquid(AccessLogEntry * al, Logfile * logfile);
 static void accessLogCommon(AccessLogEntry * al, Logfile * logfile);
@@ -1718,7 +1719,7 @@ mcast_encode(unsigned int *ibuf, size_t isize, const unsigned int *key)
 
 #if HEADERS_LOG
 void
-headersLog(int cs, int pq, method_t m, void *data)
+headersLog(int cs, int pq, method_t method, void *data)
 {
     HttpReply *rep;
     HttpRequest *req;
index 84217c87f8b6cf5ef0a66317680f5b7d7f0bceea..f55fe929bc1461e037b5fac78700af71ef4f1739 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth_basic.cc,v 1.40 2006/04/23 11:10:32 robertc Exp $
+ * $Id: auth_basic.cc,v 1.41 2006/05/08 23:38:35 robertc Exp $
  *
  * DEBUG: section 29    Authenticator
  * AUTHOR: Duane Wessels
@@ -44,6 +44,7 @@
 #include "HttpReply.h"
 #include "basicScheme.h"
 #include "wordlist.h"
+#include "SquidTime.h"
 
 static void
 authenticateStateFree(AuthenticateStateData * r)
index 431b00eb658cac8b9b94a4bc4c02fd79d5e8a021..6ae21ae36056ad122b45541a3c069a2265b99464 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_cf.cc,v 1.494 2006/04/28 05:05:43 wessels Exp $
+ * $Id: cache_cf.cc,v 1.495 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 3     Configuration File Parsing
  * AUTHOR: Harvest Derived
@@ -598,7 +598,7 @@ configDoConfigure(void)
         Config2.effectiveGroupID = grp->gr_gid;
     }
 
-    urlExtMethodConfigure();
+    HttpRequestMethod::Configure(Config);
 #if USE_SSL
 
     debug(3, 1) ("Initializing https proxy context\n");
index 58af2e5bbe475d976158606465a1187292c67eae..df5fab278ed517817e09b7944bb708f5fc6ba546 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cache_manager.cc,v 1.39 2006/05/06 22:13:18 wessels Exp $
+ * $Id: cache_manager.cc,v 1.40 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 16    Cache Manager Objects
  * AUTHOR: Duane Wessels
@@ -38,6 +38,7 @@
 #include "HttpRequest.h"
 #include "Store.h"
 #include "fde.h"
+#include "SquidTime.h"
 #include "wordlist.h"
 
 #define MGR_PASSWD_SZ 128
index 43cd7c9510e7cf83b133a08367fd1954362677e6..b188af5af3935e8ec9a6c1345d17c500c88d38d8 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: cf_gen.cc,v 1.57 2005/11/03 20:21:57 serassio Exp $
+ * $Id: cf_gen.cc,v 1.58 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: none          Generate squid.conf.default and cf_parser.h
  * AUTHOR: Max Okumoto
@@ -49,6 +49,7 @@
  *****************************************************************************/
 
 #include "squid.h"
+#include "SquidTime.h"
 #include "cf_gen_defines.h"
 
 #define MAX_LINE       1024    /* longest configuration line */
@@ -111,18 +112,6 @@ static void gen_free(Entry *, FILE *);
 static void gen_conf(Entry *, FILE *);
 static void gen_default_if_none(Entry *, FILE *);
 
-time_t
-getCurrentTime(void)
-{
-#if GETTIMEOFDAY_NO_TZP
-    gettimeofday(&current_time);
-#else
-
-    gettimeofday(&current_time, NULL);
-#endif
-
-    return squid_curtime = current_time.tv_sec;
-}
 
 static void
 lineAdd(Line ** L, const char *str)
index 524f67b2853800db27b4ac9ed2e26e0d1d7beee8..b8f2b25a7dbb04c363ad5fd614bfaae32db3791b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_db.cc,v 1.64 2005/09/03 10:05:46 serassio Exp $
+ * $Id: client_db.cc,v 1.65 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 0     Client Database
  * AUTHOR: Duane Wessels
@@ -34,6 +34,7 @@
  */
 
 #include "squid.h"
+#include "SquidTime.h"
 #include "Store.h"
 
 
index 3e73fbe196423a21f3e6a9783e2c1b7c810a3f7e..9b7558f68af4c2383376cca8dbb268db84dc49aa 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side.cc,v 1.722 2006/05/06 22:13:18 wessels Exp $
+ * $Id: client_side.cc,v 1.723 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 33    Client-side Routines
  * AUTHOR: Duane Wessels
@@ -73,6 +73,7 @@
 #include "client_side_reply.h"
 #include "ClientRequestContext.h"
 #include "MemBuf.h"
+#include "SquidTime.h"
 
 #if LINGERING_CLOSE
 #define comm_close comm_lingering_close
@@ -1616,7 +1617,7 @@ clientParseRequestMethod(char *inbuf, method_t * method_p, ConnStateData::Pointe
         return parseHttpRequestAbort(conn, "error:invalid-request");
     }
 
-    *method_p = urlParseMethod(mstr);
+    *method_p = HttpRequestMethod(mstr);
 
     if (*method_p == METHOD_NONE) {
         debug(33, 1) ("clientParseRequestMethod: Unsupported method '%s'\n", mstr);
index de5dae337c8511d81b4f056f518a2fc58893de55..93b5074192b6afa7c26956c7dbd73c1423013a25 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_reply.cc,v 1.104 2006/05/07 15:13:24 wessels Exp $
+ * $Id: client_side_reply.cc,v 1.105 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 88    Client-side Reply Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -56,6 +56,7 @@
 #include "DelayPools.h"
 #endif
 #include "client_side.h"
+#include "SquidTime.h"
 
 CBDATA_CLASS_INIT(clientReplyContext);
 
index f7cb8f8e481e39fc3c9804e915257ed5ba442894..2650461bad40f1be851cfee0374f9adfc714e2d9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: client_side_request.cc,v 1.64 2006/05/06 22:13:18 wessels Exp $
+ * $Id: client_side_request.cc,v 1.65 2006/05/08 23:38:33 robertc Exp $
  * 
  * DEBUG: section 85    Client-side Request Routines
  * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c)
@@ -54,6 +54,7 @@
 #include "HttpReply.h"
 #include "MemObject.h"
 #include "ClientRequestContext.h"
+#include "SquidTime.h"
 #include "wordlist.h"
 
 #if ICAP_CLIENT
index f40a42457d82ce42f059d49c309b931f215855c7..e3c31c46ba66bac4c043f9482bc6288271f6751b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm.cc,v 1.414 2006/05/05 21:00:28 wessels Exp $
+ * $Id: comm.cc,v 1.415 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 5     Socket Functions
  * AUTHOR: Harvest Derived
@@ -43,6 +43,7 @@
 #include "ConnectionDetail.h"
 #include "MemBuf.h"
 #include "pconn.h"
+#include "SquidTime.h"
 
 #if defined(_SQUID_CYGWIN_)
 #include <sys/ioctl.h>
index a5af95c2dbbf653cad49ba95db057bd2a24c2603..0643c16902b2abc9e2a5477cda7f08a094b53598 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: comm_poll.cc,v 1.14 2006/01/24 15:32:02 hno Exp $
+ * $Id: comm_poll.cc,v 1.15 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 5     Socket Functions
  *
@@ -33,6 +33,7 @@
  */
 
 #include "squid.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "fde.h"
 
index 6d4f481776d3b7cd96407dcaf0f3e509a9069344..9fe6f652764675878474ef379f792555cc1718bf 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: debug.cc,v 1.97 2005/04/06 18:44:25 serassio Exp $
+ * $Id: debug.cc,v 1.98 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 0     Debug Routines
  * AUTHOR: Harvest Derived
@@ -35,6 +35,7 @@
 
 #include "squid.h"
 #include "Debug.h"
+#include "SquidTime.h"
 #include <sstream>
 
 int Debug::Levels[MAX_DEBUG_SECTIONS];
index 30493e20aaf3baf4f9007b1422ea925d406ff3d3..5bf9264f5176b002b4c19a673fe7c6dae417a691 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: defines.h,v 1.118 2005/08/27 18:34:31 serassio Exp $
+ * $Id: defines.h,v 1.119 2006/05/08 23:38:33 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
 #define DEFAULT_SQUID_ERROR_DIR "/usr/local/squid/etc/errors"
 #endif
 
-/* use this and only this to initialize HttpHeaderPos */
-#define HttpHeaderInitPos (-1)
-
 /* handy to determine the #elements in a static array */
 #define countof(arr) (sizeof(arr)/sizeof(*arr))
 
index 4f4127ef27dc861c39ac84e59db69eec04b1cd85..10e9d97e63cc86f46edf00313f8722fc095e0726 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: delay_pools.cc,v 1.44 2006/02/26 14:34:27 serassio Exp $
+ * $Id: delay_pools.cc,v 1.45 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 77    Delay Pools
  * AUTHOR: Robert Collins <robertc@squid-cache.org>
@@ -51,6 +51,7 @@
 #include "DelayId.h"
 #include "Array.h"
 #include "SquidString.h"
+#include "SquidTime.h"
 #include "CommonPool.h"
 #include "CompositePoolNode.h"
 #include "DelayPool.h"
index 81e2e02501d7ed3975c050d663ec0ddf633bbcd3..a21576371f78abc5348ff20dbc8583c1ae3d7a5d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: dns_internal.cc,v 1.87 2006/04/23 11:10:31 robertc Exp $
+ * $Id: dns_internal.cc,v 1.88 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 78    DNS lookups; interacts with lib/rfc1035.c
  * AUTHOR: Duane Wessels
@@ -35,6 +35,7 @@
 
 #include "config.h"
 #include "squid.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "comm.h"
 #include "MemBuf.h"
index 4a2e8aed1e7dce651b43f974a20286215d38ca49..7f694af08ca7b5591e29995c5401f14e37c3d991 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: enums.h,v 1.249 2006/04/23 11:10:31 robertc Exp $
+ * $Id: enums.h,v 1.250 2006/05/08 23:38:33 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -235,57 +235,6 @@ typedef enum {
     STORE_DISK_CLIENT
 } store_client_t;
 
-typedef enum {
-    METHOD_NONE,               /* 000 */
-    METHOD_GET,                        /* 001 */
-    METHOD_POST,               /* 010 */
-    METHOD_PUT,                        /* 011 */
-    METHOD_HEAD,               /* 100 */
-    METHOD_CONNECT,            /* 101 */
-    METHOD_TRACE,              /* 110 */
-    METHOD_PURGE,              /* 111 */
-    METHOD_OPTIONS,
-    METHOD_DELETE,             /* RFC2616 section 9.7 */
-    METHOD_PROPFIND,
-    METHOD_PROPPATCH,
-    METHOD_MKCOL,
-    METHOD_COPY,
-    METHOD_MOVE,
-    METHOD_LOCK,
-    METHOD_UNLOCK,
-    METHOD_BMOVE,
-    METHOD_BDELETE,
-    METHOD_BPROPFIND,
-    METHOD_BPROPPATCH,
-    METHOD_BCOPY,
-    METHOD_SEARCH,
-    METHOD_SUBSCRIBE,
-    METHOD_UNSUBSCRIBE,
-    METHOD_POLL,
-    METHOD_REPORT,
-    METHOD_EXT00,
-    METHOD_EXT01,
-    METHOD_EXT02,
-    METHOD_EXT03,
-    METHOD_EXT04,
-    METHOD_EXT05,
-    METHOD_EXT06,
-    METHOD_EXT07,
-    METHOD_EXT08,
-    METHOD_EXT09,
-    METHOD_EXT10,
-    METHOD_EXT11,
-    METHOD_EXT12,
-    METHOD_EXT13,
-    METHOD_EXT14,
-    METHOD_EXT15,
-    METHOD_EXT16,
-    METHOD_EXT17,
-    METHOD_EXT18,
-    METHOD_EXT19,
-    METHOD_ENUM_END
-} method_t;
-
 typedef enum {
     PROTO_NONE,
     PROTO_HTTP,
index e58ab4f78c6fb76f0916849e78dfd1a0174c7b61..0d6dd16730082f8b29323d7a0df316e543105893 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: errorpage.cc,v 1.211 2006/05/06 22:13:18 wessels Exp $
+ * $Id: errorpage.cc,v 1.212 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 4     Error Generation
  * AUTHOR: Duane Wessels
 
 #include "squid.h"
 #include "AuthUserRequest.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
 #include "MemObject.h"
 #include "fde.h"
 #include "MemBuf.h"
+#include "URLScheme.h"
 #include "wordlist.h"
 
 /* local types */
@@ -704,7 +706,7 @@ errorConvert(char token, ErrorState * err)
         break;
 
     case 'M':
-        p = r ? RequestMethodStr[r->method] : "[unkown method]";
+        p = r ? RequestMethodStr[r->method] : "[unknown method]";
 
         break;
 
@@ -723,7 +725,7 @@ errorConvert(char token, ErrorState * err)
         break;
 
     case 'P':
-        p = r ? ProtocolStr[r->protocol] : "[unkown protocol]";
+        p = r ? ProtocolStr[r->protocol] : "[unknown protocol]";
         break;
 
     case 'R':
index 8bccd9b6fff2e07a9a18718e367e77814568d267..3d0d320880821daea6f425fc9d08ede764e5d3ff 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: external_acl.cc,v 1.69 2006/05/06 22:13:18 wessels Exp $
+ * $Id: external_acl.cc,v 1.70 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 82    External ACL
  * AUTHOR: Henrik Nordstrom, MARA Systems AB
@@ -44,6 +44,7 @@
 #include "ExternalACL.h"
 #include "ExternalACLEntry.h"
 #include "AuthUserRequest.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "fde.h"
 #include "ACLChecklist.h"
@@ -55,6 +56,7 @@
 #include "HttpRequest.h"
 #include "authenticate.h"
 #include "MemBuf.h"
+#include "URLScheme.h"
 #include "wordlist.h"
 
 #ifndef DEFAULT_EXTERNAL_ACL_TTL
index fa17b6365bff0d126b4e070f507f901a78cb7a97..0c4a25505101c02760b94a7baa498c02e7d57b34 100644 (file)
--- a/src/fd.cc
+++ b/src/fd.cc
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fd.cc,v 1.53 2005/08/27 18:40:20 serassio Exp $
+ * $Id: fd.cc,v 1.54 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 51    Filedescriptor Functions
  * AUTHOR: Duane Wessels
@@ -35,6 +35,7 @@
 
 #include "squid.h"
 #include "fde.h"
+#include "SquidTime.h"
 
 int default_read_method(int, char *, int);
 int default_write_method(int, const char *, int);
index 69534d24ac707bde68838f515ad85d940e9ea742..ad1cbec04ef6ee7fe4f1e8fa710d5e35cf829ede 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fde.cc,v 1.3 2005/12/06 23:03:34 wessels Exp $
+ * $Id: fde.cc,v 1.4 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section ??   FDE
  * AUTHOR: Robert Collins
@@ -35,6 +35,7 @@
 
 #include "squid.h"
 #include "fde.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "comm.h"
 
index b391598bad227f9a99ce019b352375f6a5bbc3f6..4c775e286cf1701a4c4948072355c83e07b2866f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: forward.cc,v 1.141 2006/05/08 17:37:34 wessels Exp $
+ * $Id: forward.cc,v 1.142 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 17    Request Forwarding
  * AUTHOR: Duane Wessels
@@ -36,6 +36,7 @@
 
 #include "squid.h"
 #include "forward.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "HttpRequest.h"
 #include "fde.h"
index 8165ac58cdca47e85353ce084cb8ce7852bb0764..ae6bcd6ffd39b4d9c83c8066479c3dc2c3651e85 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: fqdncache.cc,v 1.166 2006/04/23 11:10:31 robertc Exp $
+ * $Id: fqdncache.cc,v 1.167 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 35    FQDN Cache
  * AUTHOR: Harvest Derived
@@ -34,6 +34,7 @@
  */
 
 #include "squid.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "wordlist.h"
 
index b16b2cfef2f4d9f93746d94356c35608795422f8..32712e6263320f77a95e8ffef863403c6f115de1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir_ufs.cc,v 1.71 2006/04/23 11:10:34 robertc Exp $
+ * $Id: store_dir_ufs.cc,v 1.72 2006/05/08 23:38:35 robertc Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -42,6 +42,7 @@
 #include "DiskIO/DiskIOStrategy.h"
 #include "DiskIO/DiskIOModule.h"
 #include "Parsing.h"
+#include "SquidTime.h"
 
 #include "SwapDir.h"
 int UFSSwapDir::NumberOfUFSDirs = 0;
index b12e5337b87e0a3211e118ba49a2fbb02e823363..e3461d2e729a278343f8010aa41f74ed2839d41a 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ftp.cc,v 1.395 2006/05/08 18:22:03 wessels Exp $
+ * $Id: ftp.cc,v 1.396 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 9     File Transfer Protocol (FTP)
  * AUTHOR: Harvest Derived
@@ -51,6 +51,8 @@
 #include "Server.h"
 #include "MemBuf.h"
 #include "wordlist.h"
+#include "SquidTime.h"
+#include "URLScheme.h"
 
 #if ICAP_CLIENT
 #include "ICAP/ICAPClientRespmodPrecache.h"
index dc86f679ca4593e19a3f730d885c19fa6b84940e..8a9d5635824085f56e85853f286fe166220530f7 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: globals.h,v 1.134 2006/04/22 05:29:19 robertc Exp $
+ * $Id: globals.h,v 1.135 2006/05/08 23:38:33 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -47,8 +47,6 @@ extern char ThisCache[SQUIDHOSTNAMELEN << 1];
 extern char ThisCache2[SQUIDHOSTNAMELEN << 1];
 extern char config_input_line[BUFSIZ];
 extern const char *DefaultConfigFile;  /* DEFAULT_CONFIG_FILE */
-extern const char *RequestMethodStr[];
-extern const char *ProtocolStr[];
 extern const char *cfg_filename;       /* NULL */
 extern const char *const appname;      /* "squid" */
 extern const char *const dash_str;     /* "-" */
@@ -118,7 +116,6 @@ extern struct IN_ADDR theOutSNMPAddr;
 extern struct timeval current_time;
 
 extern struct timeval squid_start;
-extern time_t squid_curtime;   /* 0 */
 extern int shutting_down;      /* 0 */
 extern int reconfiguring;      /* 0 */
 extern int store_dirs_rebuilding;      /* 1 */
index 697a3a380393c87152015c80f95592e473dadee3..d9cefb289f2daee57c55333395398544e72904e2 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: gopher.cc,v 1.194 2006/04/02 14:32:35 serassio Exp $
+ * $Id: gopher.cc,v 1.195 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 10    Gopher
  * AUTHOR: Harvest Derived
@@ -43,6 +43,7 @@
 #endif
 #include "MemBuf.h"
 #include "forward.h"
+#include "SquidTime.h"
 
 /* gopher type code from rfc. Anawat. */
 #define GOPHER_FILE         '0'
index 8b2c29897be167ea3e7e385777cee79413c6b1f9..b34e13fc9eb82d8b690236c8848b2c1c00894139 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: helper.cc,v 1.73 2006/04/23 11:10:31 robertc Exp $
+ * $Id: helper.cc,v 1.74 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 84    Helper process maintenance
  * AUTHOR: Harvest Derived?
@@ -35,6 +35,7 @@
 
 #include "squid.h"
 #include "helper.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "comm.h"
 #include "MemBuf.h"
index 28689be66d3a2b2765d1d4b79eb5701d9a6c1577..f579588ff0afccefacedcfebfce78274660dcacc 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: htcp.cc,v 1.65 2006/05/06 22:38:13 wessels Exp $
+ * $Id: htcp.cc,v 1.66 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 31    Hypertext Caching Protocol
  * AUTHOR: Duane Wesssels
@@ -35,6 +35,7 @@
 
 #include "squid.h"
 #include "htcp.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "StoreClient.h"
 #include "HttpRequest.h"
@@ -804,7 +805,7 @@ htcpHandleNop(htcpDataHeader * hdr, char *buf, int sz, struct sockaddr_in *from)
 void
 htcpSpecifier::checkHit()
 {
-    method_t m = urlParseMethod(method);
+    method_t m = HttpRequestMethod(method);
     char *blk_end;
     checkHitRequest = HttpRequest::CreateFromUrlAndMethod(uri, m);
 
index 5ed629577aa76b9b05b01684ac94b6ab2b59a59a..990b527a1aba8b8f6cae0b3070705e5a63878ac0 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.496 2006/05/08 20:59:28 wessels Exp $
+ * $Id: http.cc,v 1.497 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -59,6 +59,7 @@
 #include "ICAP/ICAPConfig.h"
 extern ICAPConfig TheICAPConfig;
 #endif
+#include "SquidTime.h"
 
 CBDATA_CLASS_INIT(HttpStateData);
 
index 79dbbb21b967ee27b70db7b7c3eac58426e6999f..42ed6a2612abbb514f8f9bcae8176e0340769a4e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: icp_v2.cc,v 1.92 2006/05/03 14:04:44 robertc Exp $
+ * $Id: icp_v2.cc,v 1.93 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 12    Internet Cache Protocol
  * AUTHOR: Duane Wessels
@@ -42,6 +42,7 @@
 #include "ACL.h"
 #include "AccessLogEntry.h"
 #include "wordlist.h"
+#include "SquidTime.h"
 
 static void icpLogIcp(struct IN_ADDR, log_type, int, const char *, int);
 
index 6a12912dea2dd274c2aa2505af5849fadeb6be19..996391a15702e9138ad2bf4c4b256aca685e1a8e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: internal.cc,v 1.39 2006/04/23 11:10:31 robertc Exp $
+ * $Id: internal.cc,v 1.40 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 76    Internal Squid Object handling
  * AUTHOR: Duane, Alex, Henrik
@@ -38,6 +38,7 @@
 #include "HttpRequest.h"
 #include "HttpReply.h"
 #include "MemBuf.h"
+#include "SquidTime.h"
 #include "wordlist.h"
 
 /* called when we "miss" on an internal object;
index 41f6a563724b9cee7457dcb1ba0d17a2b28e4ebb..0202738c5f6d03c32d9482432f34cba64c8f3fc6 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: ipcache.cc,v 1.253 2006/04/23 11:10:31 robertc Exp $
+ * $Id: ipcache.cc,v 1.254 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 14    IP Cache
  * AUTHOR: Harvest Derived
@@ -34,6 +34,7 @@
  */
 
 #include "squid.h"
+#include "SquidTime.h"
 #include "Store.h"
 #include "wordlist.h"
 
index eecea8eaf7412bff5509cb9495a66f729a183e6a..b9e240b68636eebbf1bec91f4d4518ce20bd9b83 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: main.cc,v 1.419 2006/05/05 23:33:21 wessels Exp $
+ * $Id: main.cc,v 1.420 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 1     Startup and Main Loop
  * AUTHOR: Harvest Derived
@@ -46,6 +46,7 @@
 #include "StoreFileSystem.h"
 #include "DiskIO/DiskIOModule.h"
 #include "comm.h"
+#include "SquidTime.h"
 #include "SwapDir.h"
 #include "forward.h"
 
index 0669a337b4499305beca8fa0b4ee3675752035f7..bc3579471f222ff619673cdc39eb47cb25709c72 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: mem.cc,v 1.93 2006/05/03 14:04:44 robertc Exp $
+ * $Id: mem.cc,v 1.94 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 13    High Level Memory Pool Management
  * AUTHOR: Harvest Derived
@@ -43,6 +43,7 @@
 #include "Store.h"
 #include "StoreEntryStream.h"
 #include "MemBuf.h"
+#include "SquidTime.h"
 
 /* module globals */
 
index 12aab5eb5dd3d1927dbf1c716133f6ceb97e5e02..88f1a1ef13ba774b238ebe315803aa0971d3b528 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: neighbors.cc,v 1.334 2006/05/03 14:04:44 robertc Exp $
+ * $Id: neighbors.cc,v 1.335 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 15    Neighbor Routines
  * AUTHOR: Harvest Derived
@@ -41,6 +41,7 @@
 #include "ACLChecklist.h"
 #include "htcp.h"
 #include "PeerSelectState.h"
+#include "SquidTime.h"
 
 /* count mcast group peers every 15 minutes */
 #define MCAST_COUNT_RATE 900
index 89386f81389c1d7ebbf3505b92c17c02493fbf80..8b8dadcda60738d56df2d92f0303ef6dfc22fdab 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: net_db.cc,v 1.186 2006/05/03 14:04:44 robertc Exp $
+ * $Id: net_db.cc,v 1.187 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 38    Network Measurement Database
  * AUTHOR: Duane Wessels
@@ -49,6 +49,7 @@
 #include "MemObject.h"
 #include "fde.h"
 #include "forward.h"
+#include "SquidTime.h"
 #include "wordlist.h"
 
 #if USE_ICMP
index 2e77ad673d566ac3c619c90824f297bf1922406a..452f65fbaf09c23a6d7c7a04238ce0b6d235cebe 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: peer_digest.cc,v 1.112 2006/05/06 22:13:18 wessels Exp $
+ * $Id: peer_digest.cc,v 1.113 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 72    Peer Digest Routines
  * AUTHOR: Alex Rousskov
@@ -40,6 +40,7 @@
 #include "HttpRequest.h"
 #include "HttpReply.h"
 #include "MemObject.h"
+#include "SquidTime.h"
 #include "StoreClient.h"
 #include "forward.h"
 
index 318094289015ae95b83564bd725cb5ba75ba4fee..45bcc7fbf117ffc8a833a9923c1d49768d1eee7e 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: pinger.cc,v 1.54 2005/04/18 21:52:42 hno Exp $
+ * $Id: pinger.cc,v 1.55 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 42    ICMP Pinger program
  * AUTHOR: Duane Wessels
@@ -34,6 +34,7 @@
  */
 
 #include "squid.h"
+#include "SquidTime.h"
 
 #if USE_ICMP
 
@@ -582,20 +583,6 @@ pingerSendtoSquid(pingerReplyData * preply)
     }
 }
 
-time_t
-getCurrentTime(void)
-{
-#if GETTIMEOFDAY_NO_TZP
-    gettimeofday(&current_time);
-#else
-
-    gettimeofday(&current_time, NULL);
-#endif
-
-    return squid_curtime = current_time.tv_sec;
-}
-
-
 int
 main(int argc, char *argv[])
 {
index 92230ee1e4a0b1aa07b2682e342bf84ffd4cbc92..7ba88cac021be56c174b01d2859e2ded0c8ec41c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: protos.h,v 1.529 2006/05/08 20:59:28 wessels Exp $
+ * $Id: protos.h,v 1.530 2006/05/08 23:38:33 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
  * yet.
  */
 #include "Packer.h"
+/* for routines that have not moved out their proper homes yet.
+ * grep for method_t in this file - if none found remove this include.
+ */
+#include "HttpRequestMethod.h"
 
 #if FORW_VIA_DB
 SQUIDCEXTERN void fvdbCountVia(const char *key);
@@ -669,7 +673,6 @@ SQUIDCEXTERN void no_suid(void);
 SQUIDCEXTERN void writePidFile(void);
 SQUIDCEXTERN void setSocketShutdownLifetimes(int);
 SQUIDCEXTERN void setMaxFD(void);
-SQUIDCEXTERN time_t getCurrentTime(void);
 SQUIDCEXTERN int percent(int, int);
 SQUIDCEXTERN double dpercent(double, double);
 SQUIDCEXTERN void squid_signal(int sig, SIGHDLR *, int flags);
@@ -702,7 +705,6 @@ SQUIDCEXTERN void unlinkdUnlink(const char *);
 SQUIDCEXTERN char *url_convert_hex(char *org_url, int allocate);
 SQUIDCEXTERN char *url_escape(const char *url);
 SQUIDCEXTERN protocol_t urlParseProtocol(const char *, const char *e = NULL);
-SQUIDCEXTERN method_t urlParseMethod(const char *, const char *e = NULL);
 SQUIDCEXTERN void urlInitialize(void);
 SQUIDCEXTERN HttpRequest *urlParse(method_t, char *, HttpRequest *request = NULL);
 SQUIDCEXTERN const char *urlCanonical(HttpRequest *);
index 0d945ee6e7993c78742b513e265cb16acd48bb9f..a72ca5753d009b62f2df138398143cd495976ea1 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: refresh.cc,v 1.70 2006/04/27 17:26:20 wessels Exp $
+ * $Id: refresh.cc,v 1.71 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 22    Refresh Calculation
  * AUTHOR: Harvest Derived
@@ -42,6 +42,7 @@
 #include "MemObject.h"
 #include "HttpRequest.h"
 #include "HttpReply.h"
+#include "SquidTime.h"
 
 typedef enum {
     rcHTTP,
index 3bf01d346866d57f546e48d7c21c03dd940a30ba..b8f932037b48906019b20bd8f6fd01a8923ef421 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_heap_replacement.cc,v 1.13 2003/09/29 10:24:00 robertc Exp $
+ * $Id: store_heap_replacement.cc,v 1.14 2006/05/08 23:38:35 robertc Exp $
  *
  * DEBUG: section 20    Storage Manager Heap-based replacement
  * AUTHOR: John Dilley
@@ -46,6 +46,7 @@
 #include "store_heap_replacement.h"
 #include "Store.h"
 #include "MemObject.h"
+#include "SquidTime.h"
 
 /*
  * Key generation function to implement the LFU-DA policy (Least
index 8f1ec5e4d3c179ba3b2fb0759038f2ac16441b08..22208d865aea79bcbab44b090daf5626334bc9c9 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_repl_lru.cc,v 1.16 2004/08/30 05:12:33 robertc Exp $
+ * $Id: store_repl_lru.cc,v 1.17 2006/05/08 23:38:35 robertc Exp $
  *
  * DEBUG: section ?     LRU Removal policy
  * AUTHOR: Henrik Nordstrom
@@ -36,6 +36,7 @@
 #include "squid.h"
 #include "Store.h"
 #include "MemObject.h"
+#include "SquidTime.h"
 
 REMOVALPOLICYCREATE createRemovalPolicy_lru;
 
index 83c84e9afcd9538cc8148999f88d9bf7e5481d30..8abb86e0d51064535a43b930288a3b29f2c73338 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: send-announce.cc,v 1.65 2003/02/21 22:50:10 robertc Exp $
+ * $Id: send-announce.cc,v 1.66 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 27    Cache Announcer
  * AUTHOR: Duane Wessels
@@ -35,6 +35,7 @@
 
 #include "squid.h"
 #include "fde.h"
+#include "SquidTime.h"
 
 static IPH send_announce;
 
index 9107cfa5087b2abb4250ac6c42201fa64b17a9ea..39ac8d520799755d9439fa59f073a9944d46f078 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store.cc,v 1.588 2006/05/06 22:13:18 wessels Exp $
+ * $Id: store.cc,v 1.589 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 20    Storage Manager
  * AUTHOR: Harvest Derived
@@ -47,6 +47,7 @@
 #include "DelayPools.h"
 #endif
 #include "Stack.h"
+#include "SquidTime.h"
 
 static STMCB storeWriteComplete;
 
index a30f6d59cbf2c5bb954993afbb62118a4ea2f81e..cb642b576364a8141ac438ba8b6d781d155e898d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_digest.cc,v 1.64 2006/05/03 14:04:44 robertc Exp $
+ * $Id: store_digest.cc,v 1.65 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 71    Store Digest Manager
  * AUTHOR: Alex Rousskov
@@ -47,6 +47,7 @@
 #include "HttpRequest.h"
 #include "HttpReply.h"
 #include "MemObject.h"
+#include "SquidTime.h"
 #include "StoreSearch.h"
 
 /*
index cd831732cdb6a9151b29cef53287f7085762cc89..9cab425b9cfb205f7bb0147641c0dd6c6dbf791b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_dir.cc,v 1.152 2006/03/08 10:34:04 hno Exp $
+ * $Id: store_dir.cc,v 1.153 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 47    Store Directory Routines
  * AUTHOR: Duane Wessels
@@ -36,6 +36,7 @@
 #include "squid.h"
 #include "Store.h"
 #include "MemObject.h"
+#include "SquidTime.h"
 #include "SwapDir.h"
 
 #if HAVE_STATVFS
index 6e999d1112428e9acdce0f26b74d2d543ffeaaf0..b65a7e6b2adf44ade577e7d9e85ba1df38f73889 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: store_rebuild.cc,v 1.82 2005/01/03 16:08:26 robertc Exp $
+ * $Id: store_rebuild.cc,v 1.83 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 20    Store Rebuild Routines
  * AUTHOR: Duane Wessels
@@ -37,6 +37,7 @@
 #include "Store.h"
 #include "SwapDir.h"
 #include "StoreSearch.h"
+#include "SquidTime.h"
 
 static struct _store_rebuild_data counts;
 
index de443cf4fe68f40a9a01dfb558cc35d2bdd4d17a..68a767f5e17f89e7de8cc1b9f211c45e9509de46 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.541 2006/05/08 20:59:28 wessels Exp $
+ * $Id: structs.h,v 1.542 2006/05/08 23:38:33 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -836,8 +836,10 @@ class HttpHdrExtField
 
 /* http cache control header field */
 
-struct _HttpHdrCc
+class HttpHdrCc
 {
+
+public:
     int mask;
     int max_age;
     int s_maxage;
index be6a7dce974c21d1f7d069a301820beaf06578d1..edcfc389f579fb8e79d66cd3b69da0d8b8a5c96b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: stub_tools.cc,v 1.1 2005/01/03 16:08:27 robertc Exp $
+ * $Id: stub_tools.cc,v 1.2 2006/05/08 23:38:35 robertc Exp $
  *
  * AUTHOR: Robert Collins
  *
 
 #include "squid.h"
 
-time_t
-getCurrentTime(void)
-{
-#if GETTIMEOFDAY_NO_TZP
-    gettimeofday(&current_time);
-#else
-
-    gettimeofday(&current_time, NULL);
-#endif
-
-    current_dtime = (double) current_time.tv_sec +
-                    (double) current_time.tv_usec / 1000000.0;
-    return squid_curtime = current_time.tv_sec;
-}
-
 int
 percent(int a, int b)
 {
index 4c4f65f71ad0e3761818e88042fcc59165e20e1e..6fe474ce6f7702ac07d8f3efe70fc6bf96a8fc3e 100644 (file)
@@ -11,6 +11,7 @@
 #include "HttpHeader.h"
 #include "HttpReply.h"
 #include "StoreFileSystem.h"
+#include "SquidTime.h"
 
 #define TESTDIR "testCoss__testCossSearch"
 
diff --git a/src/tests/testHeader_HttpRequestMethod.cc b/src/tests/testHeader_HttpRequestMethod.cc
new file mode 100644 (file)
index 0000000..d107ca3
--- /dev/null
@@ -0,0 +1,4 @@
+/* This test tests that the header below can be processed on its own with
+ * no other #includes. Dont add any!
+ */
+#include "HttpRequestMethod.h"
diff --git a/src/tests/testHeader_URL.cc b/src/tests/testHeader_URL.cc
new file mode 100644 (file)
index 0000000..34b4204
--- /dev/null
@@ -0,0 +1,4 @@
+/* This test tests that the header below can be processed on its own with
+ * no other #includes. Dont add any!
+ */
+#include "URL.h"
diff --git a/src/tests/testHeader_URLScheme.cc b/src/tests/testHeader_URLScheme.cc
new file mode 100644 (file)
index 0000000..40b19cd
--- /dev/null
@@ -0,0 +1,4 @@
+/* This test tests that the header below can be processed on its own with
+ * no other #includes. Dont add any!
+ */
+#include "URLScheme.h"
diff --git a/src/tests/testHttpRequestMethod.cc b/src/tests/testHttpRequestMethod.cc
new file mode 100644 (file)
index 0000000..8709cb1
--- /dev/null
@@ -0,0 +1,117 @@
+#include "squid.h"
+#include <sstream>
+#include <cppunit/TestAssert.h>
+
+#include "Mem.h"
+#include "testHttpRequestMethod.h"
+#include "HttpRequestMethod.h"
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION( testHttpRequestMethod );
+
+
+/*
+ * We should be able to make an HttpRequestMethod straight from a string.
+ */
+void
+testHttpRequestMethod::testConstructCharStart()
+{
+    /* parse an empty string -> METHOD_NONE */
+    CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL));
+    /* parsing a literal should work */
+    CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
+}
+
+/*
+ * We can also parse precise ranges of characters 
+ */
+void
+testHttpRequestMethod::testConstructCharStartEnd()
+{
+    char const * buffer;
+    /* parse an empty string -> METHOD_NONE */
+    CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL, NULL));
+    /* parsing a literal should work */
+    CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
+    /* parsing with an explicit end should work */
+    buffer = "POSTPLUS";
+    CPPUNIT_ASSERT(METHOD_POST == HttpRequestMethod(buffer, buffer + 4));
+}
+
+/*
+ * we should be able to assign a method_t to a HttpRequestMethod
+ */
+void
+testHttpRequestMethod::testAssignFrommethod_t()
+{
+    HttpRequestMethod method;
+    method = METHOD_NONE;
+    CPPUNIT_ASSERT_EQUAL(HttpRequestMethod(METHOD_NONE), method);
+    method = METHOD_POST;
+    CPPUNIT_ASSERT_EQUAL(HttpRequestMethod(METHOD_POST), method);
+}
+
+/*
+ * a default constructed HttpRequestMethod is == METHOD_NONE
+ */
+void
+testHttpRequestMethod::testDefaultConstructor()
+{
+    CPPUNIT_ASSERT_EQUAL(HttpRequestMethod(), HttpRequestMethod(METHOD_NONE));
+}
+
+/*
+ * we should be able to construct a HttpRequestMethod from a method_t
+ */
+void
+testHttpRequestMethod::testConstructmethod_t()
+{
+    CPPUNIT_ASSERT_EQUAL(HttpRequestMethod(METHOD_NONE), HttpRequestMethod(METHOD_NONE));
+    CPPUNIT_ASSERT_EQUAL(HttpRequestMethod(METHOD_POST), HttpRequestMethod(METHOD_POST));
+    CPPUNIT_ASSERT(HttpRequestMethod(METHOD_NONE) != HttpRequestMethod(METHOD_POST));
+}
+
+/*
+ * we should be able to get a char const * version of the method.
+ */
+void
+testHttpRequestMethod::testConst_str()
+{
+    CPPUNIT_ASSERT_EQUAL(String("POST"), String(HttpRequestMethod("post").const_str()));
+}
+
+/*
+ * an HttpRequestMethod should be comparable to a method_t without false
+ * matches
+ */
+void
+testHttpRequestMethod::testEqualmethod_t()
+{
+    CPPUNIT_ASSERT(HttpRequestMethod(METHOD_NONE) == METHOD_NONE);
+    CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_POST) == METHOD_GET));
+    CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod(METHOD_GET));
+    CPPUNIT_ASSERT(not (METHOD_SEARCH == HttpRequestMethod(METHOD_TRACE)));
+}
+
+/*
+ * an HttpRequestMethod should testable for inequality without fail maatches
+ */
+void
+testHttpRequestMethod::testNotEqualmethod_t()
+{
+    CPPUNIT_ASSERT(HttpRequestMethod(METHOD_NONE) != METHOD_GET);
+    CPPUNIT_ASSERT(not (HttpRequestMethod(METHOD_POST) != METHOD_POST));
+    CPPUNIT_ASSERT(METHOD_NONE != HttpRequestMethod(METHOD_GET));
+    CPPUNIT_ASSERT(not (METHOD_SEARCH != HttpRequestMethod(METHOD_SEARCH)));
+}
+
+/*
+ * we should be able to send it to a stream and get the normalised version
+ */
+void
+testHttpRequestMethod::testStream()
+{
+    std::ostringstream buffer;
+    buffer << HttpRequestMethod("get");
+    CPPUNIT_ASSERT_EQUAL(String("GET"), String(buffer.str().c_str()));
+}
diff --git a/src/tests/testHttpRequestMethod.h b/src/tests/testHttpRequestMethod.h
new file mode 100644 (file)
index 0000000..8e79993
--- /dev/null
@@ -0,0 +1,40 @@
+
+#ifndef SQUID_SRC_TEST_HTTP_REQUEST_METHOD_H
+#define SQUID_SRC_TEST_HTTP_REQUEST_METHOD_H
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/*
+ * test HttpRequestMethod
+ */
+
+class testHttpRequestMethod : public CPPUNIT_NS::TestFixture
+{
+    CPPUNIT_TEST_SUITE( testHttpRequestMethod );
+    CPPUNIT_TEST( testAssignFrommethod_t );
+    CPPUNIT_TEST( testConstructmethod_t );
+    CPPUNIT_TEST( testConstructCharStart );
+    CPPUNIT_TEST( testConstructCharStartEnd );
+    CPPUNIT_TEST( testDefaultConstructor );
+    CPPUNIT_TEST( testEqualmethod_t );
+    CPPUNIT_TEST( testNotEqualmethod_t );
+    CPPUNIT_TEST( testConst_str );
+    CPPUNIT_TEST( testStream );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+
+protected:
+    void testAssignFrommethod_t();
+    void testConstructmethod_t();
+    void testConstructCharStart();
+    void testConstructCharStartEnd();
+    void testConst_str();
+    void testDefaultConstructor();
+    void testEqualmethod_t();
+    void testNotEqualmethod_t();
+    void testStream();
+};
+
+#endif
+
index fe6aff2589aa10fa88ed631c70e5e5ebfe85b48a..74ca9f45322fe0257417eca4b002834e2395945a 100644 (file)
@@ -11,6 +11,7 @@
 #include "HttpHeader.h"
 #include "HttpReply.h"
 #include "StoreFileSystem.h"
+#include "SquidTime.h"
 
 #define TESTDIR "testNull__testNullSearch"
 
index 0f99ab89408e7640ce0e7e0654f045c6f5f55c78..17a76fc474e09ff1474f6210903dc7a2128cef46 100644 (file)
@@ -5,6 +5,7 @@
 #include "SwapDir.h"
 #include "TestSwapDir.h"
 #include "Mem.h"
+#include "SquidTime.h"
 #include "StoreSearch.h"
 
 CPPUNIT_TEST_SUITE_REGISTRATION( testStoreController );
index e53fc7609bda0f0348abb7c7ff8bc5d723eb3fb2..0e68702707ee4f1675654407919d463ee4758a71 100644 (file)
@@ -7,6 +7,7 @@
 #include "StoreHashIndex.h"
 #include "Mem.h"
 #include "StoreSearch.h"
+#include "SquidTime.h"
 
 CPPUNIT_TEST_SUITE_REGISTRATION( testStoreHashIndex );
 
diff --git a/src/tests/testURL.cc b/src/tests/testURL.cc
new file mode 100644 (file)
index 0000000..d7beaac
--- /dev/null
@@ -0,0 +1,53 @@
+#include "squid.h"
+#include <sstream>
+#include <cppunit/TestAssert.h>
+
+#include "Mem.h"
+#include "testURL.h"
+#include "URL.h"
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION( testURL );
+
+/* stub functions to link successfully */
+void
+shut_down(int)
+{}
+
+/* end stubs */
+
+/* init memory pools */
+
+struct Initer
+{
+    Initer() {Mem::Init();}
+};
+
+static Initer ensure_mempools;
+
+/*
+ * we can construct a URL with a URLScheme.
+ * This creates a URL for that scheme.
+ */
+void
+testURL::testConstructScheme()
+{
+    CPPUNIT_ASSERT_EQUAL(URLScheme(), URL(PROTO_NONE).getScheme());
+    CPPUNIT_ASSERT_EQUAL(URLScheme(PROTO_FTP), URL(PROTO_FTP).getScheme());
+}
+
+/*
+ * a default constructed URL has scheme "NONE".
+ * Also, we should be able to use new and delete on
+ * scheme instances.
+ */
+void
+testURL::testDefaultConstructor()
+{
+    URL aUrl;
+    CPPUNIT_ASSERT_EQUAL(URLScheme(), aUrl.getScheme());
+
+    URL *urlPointer = new URL;
+    CPPUNIT_ASSERT(urlPointer != NULL);
+    delete urlPointer;
+}
diff --git a/src/tests/testURL.h b/src/tests/testURL.h
new file mode 100644 (file)
index 0000000..7ec1ce7
--- /dev/null
@@ -0,0 +1,27 @@
+
+#ifndef SQUID_SRC_TEST_URL_H
+#define SQUID_SRC_TEST_URL_H
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/*
+ * test the URL class.
+ */
+
+class testURL : public CPPUNIT_NS::TestFixture
+{
+    CPPUNIT_TEST_SUITE( testURL );
+    CPPUNIT_TEST( testConstructScheme );
+    CPPUNIT_TEST( testDefaultConstructor );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+
+protected:
+
+    void testConstructScheme();
+    void testDefaultConstructor();
+};
+
+#endif
+
diff --git a/src/tests/testURLScheme.cc b/src/tests/testURLScheme.cc
new file mode 100644 (file)
index 0000000..8d97137
--- /dev/null
@@ -0,0 +1,136 @@
+#include "squid.h"
+#include <sstream>
+#include <cppunit/TestAssert.h>
+
+#include "Mem.h"
+#include "testURLScheme.h"
+#include "URLScheme.h"
+
+
+CPPUNIT_TEST_SUITE_REGISTRATION( testURLScheme );
+
+
+#if 0
+/*
+ * We should be able to make an HttpRequestMethod straight from a string.
+ */
+void
+testHttpRequestMethod::testConstructCharStart()
+{
+    /* parse an empty string -> METHOD_NONE */
+    CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL));
+    /* parsing a literal should work */
+    CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
+}
+
+/*
+ * We can also parse precise ranges of characters 
+ */
+void
+testHttpRequestMethod::testConstructCharStartEnd()
+{
+    char const * buffer;
+    /* parse an empty string -> METHOD_NONE */
+    CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL, NULL));
+    /* parsing a literal should work */
+    CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL));
+    /* parsing with an explicit end should work */
+    buffer = "POSTPLUS";
+    CPPUNIT_ASSERT(METHOD_POST == HttpRequestMethod(buffer, buffer + 4));
+}
+
+#endif
+
+/*
+ * we should be able to assign a protocol_t to a URLScheme for ease
+ * of code conversion
+ */
+void
+testURLScheme::testAssignFromprotocol_t()
+{
+    URLScheme scheme;
+    scheme = PROTO_NONE;
+    CPPUNIT_ASSERT_EQUAL(URLScheme(), scheme);
+    scheme = PROTO_HTTPS;
+    CPPUNIT_ASSERT_EQUAL(URLScheme(PROTO_HTTPS), scheme);
+}
+
+/*
+ * We should be able to get a protocol_t from a URLScheme for ease
+ * of migration
+ */
+void
+testURLScheme::testCastToprotocol_t()
+{
+    /* explicit cast */
+    protocol_t protocol = (protocol_t) URLScheme();
+    CPPUNIT_ASSERT_EQUAL(PROTO_NONE, protocol);
+    /* and implicit */
+    protocol = URLScheme(PROTO_HTTP);
+    CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, protocol);
+}
+
+/*
+ * a default constructed URLScheme is == PROTO_NONE
+ */
+void
+testURLScheme::testDefaultConstructor()
+{
+    CPPUNIT_ASSERT_EQUAL(URLScheme(), URLScheme(PROTO_NONE));
+}
+
+/*
+ * we should be able to construct a URLScheme from the old 'protocol_t' enum.
+ */
+void
+testURLScheme::testConstructprotocol_t()
+{
+    CPPUNIT_ASSERT_EQUAL(URLScheme(PROTO_NONE), URLScheme(PROTO_NONE));
+    CPPUNIT_ASSERT_EQUAL(URLScheme(PROTO_CACHEOBJ), URLScheme(PROTO_CACHEOBJ));
+    CPPUNIT_ASSERT(URLScheme(PROTO_NONE) != URLScheme(PROTO_CACHEOBJ));
+}
+
+/*
+ * we should be able to get a char const * version of the method.
+ */
+void
+testURLScheme::testConst_str()
+{
+    CPPUNIT_ASSERT_EQUAL(String("wais"), String(URLScheme(PROTO_WAIS).const_str()));
+}
+
+/*
+ * a URLScheme replaces protocol_t, so we should be able to test for equality on 
+ * either the left or right hand side seamlessly.
+ */
+void
+testURLScheme::testEqualprotocol_t()
+{
+    CPPUNIT_ASSERT(URLScheme() == PROTO_NONE);
+    CPPUNIT_ASSERT(not (URLScheme(PROTO_WAIS) == PROTO_HTTP));
+    CPPUNIT_ASSERT(PROTO_HTTP == URLScheme(PROTO_HTTP));
+    CPPUNIT_ASSERT(not (PROTO_CACHEOBJ == URLScheme(PROTO_HTTP)));
+}
+
+/*
+ * a URLScheme should testable for inequality with a protocol_t.
+ */
+void
+testURLScheme::testNotEqualprotocol_t()
+{
+    CPPUNIT_ASSERT(URLScheme(PROTO_NONE) != PROTO_HTTP);
+    CPPUNIT_ASSERT(not (URLScheme(PROTO_HTTP) != PROTO_HTTP));
+    CPPUNIT_ASSERT(PROTO_NONE != URLScheme(PROTO_HTTP));
+    CPPUNIT_ASSERT(not (PROTO_WAIS != URLScheme(PROTO_WAIS)));
+}
+
+/*
+ * we should be able to send it to a stream and get the normalised version
+ */
+void
+testURLScheme::testStream()
+{
+    std::ostringstream buffer;
+    buffer << URLScheme(PROTO_HTTP);
+    CPPUNIT_ASSERT_EQUAL(String("http"), String(buffer.str().c_str()));
+}
diff --git a/src/tests/testURLScheme.h b/src/tests/testURLScheme.h
new file mode 100644 (file)
index 0000000..fe8ba2b
--- /dev/null
@@ -0,0 +1,50 @@
+
+#ifndef SQUID_SRC_TEST_URL_SCHEME_H
+#define SQUID_SRC_TEST_URL_SCHEME_H
+
+#include <cppunit/extensions/HelperMacros.h>
+
+/*
+ * test URLScheme
+ */
+
+class testURLScheme : public CPPUNIT_NS::TestFixture
+{
+    CPPUNIT_TEST_SUITE( testURLScheme );
+    CPPUNIT_TEST( testAssignFromprotocol_t );
+    CPPUNIT_TEST( testCastToprotocol_t );
+    CPPUNIT_TEST( testConstructprotocol_t );
+#if 0
+
+    CPPUNIT_TEST( testConstructCharStart );
+    CPPUNIT_TEST( testConstructCharStartEnd );
+#endif
+
+    CPPUNIT_TEST( testDefaultConstructor );
+    CPPUNIT_TEST( testEqualprotocol_t );
+    CPPUNIT_TEST( testNotEqualprotocol_t );
+    CPPUNIT_TEST( testConst_str );
+    CPPUNIT_TEST( testStream );
+    CPPUNIT_TEST_SUITE_END();
+
+public:
+
+protected:
+    void testAssignFromprotocol_t();
+    void testCastToprotocol_t();
+    void testConstructprotocol_t();
+#if 0
+
+    void testConstructCharStart();
+    void testConstructCharStartEnd();
+#endif
+
+    void testConst_str();
+    void testDefaultConstructor();
+    void testEqualprotocol_t();
+    void testNotEqualprotocol_t();
+    void testStream();
+};
+
+#endif
+
index 1efcb5cc211eb0cac260b064c122936c3b215746..2e8c74789a5938371664c625c5cfe0a94800c928 100644 (file)
@@ -9,6 +9,7 @@
 #include "Mem.h"
 #include "HttpHeader.h"
 #include "HttpReply.h"
+#include "SquidTime.h"
 
 #define TESTDIR "testUfs__testUfsSearch"
 
index 13661c2d3d4c84894861da885a7e109000041eab..31985176551caef4e8277645bf0f20251a19e2fe 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: time.cc,v 1.1 2006/05/03 14:04:44 robertc Exp $
+ * $Id: time.cc,v 1.2 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 21    Time Functions
  * AUTHOR: Harvest Derived
@@ -33,8 +33,9 @@
  *
  */
 
-#include "squid.h"
+#include "SquidTime.h"
 
+time_t squid_curtime = 0;
 
 time_t
 getCurrentTime(void)
index 377660ff4373347cf744093c0ac63b4d52c97c36..b15f7435dc55c204bbbe7aa91c05c76de2027b92 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: tools.cc,v 1.267 2006/05/03 14:04:44 robertc Exp $
+ * $Id: tools.cc,v 1.268 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 21    Misc Functions
  * AUTHOR: Harvest Derived
@@ -38,6 +38,7 @@
 #include "fde.h"
 #include "MemBuf.h"
 #include "wordlist.h"
+#include "SquidTime.h"
 
 #if HAVE_SYS_PRCTL_H
 #include <sys/prctl.h>
index 6b796c99cbdcf81dc74c0b2989d3aaf3cf6f93f1..bef3b33b3c998da0c464a2f5434a274cb19c938b 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: typedefs.h,v 1.183 2006/05/08 20:59:28 wessels Exp $
+ * $Id: typedefs.h,v 1.184 2006/05/08 23:38:33 robertc Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -117,7 +117,7 @@ class HttpHeaderFieldInfo;
 
 class HttpHeader;
 
-typedef struct _HttpHdrCc HttpHdrCc;
+class HttpHdrCc;
 
 typedef struct _TimeOrTag TimeOrTag;
 
@@ -304,9 +304,6 @@ typedef int Ctx;
 /* in case we want to change it later */
 typedef ssize_t mb_size_t;
 
-/*iteration for headers; use HttpHeaderPos as opaque type, do not interpret */
-typedef ssize_t HttpHeaderPos;
-
 typedef RemovalPolicy *REMOVALPOLICYCREATE(wordlist * args);
 
 typedef int STDIRSELECT(const StoreEntry *);
index dd5b03b3095ac1650a7ff9012123149b9d83a67b..c57ce05c121794504ae071db52ab86ec65df381f 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: url.cc,v 1.153 2006/05/03 14:04:44 robertc Exp $
+ * $Id: url.cc,v 1.154 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 23    URL Parsing
  * AUTHOR: Duane Wessels
  *
  */
 
-#include "squid.h"
+#include "URL.h"
 #include "HttpRequest.h"
-#include "wordlist.h"
-
-const char *RequestMethodStr[] =
-    {
-        "NONE",
-        "GET",
-        "POST",
-        "PUT",
-        "HEAD",
-        "CONNECT",
-        "TRACE",
-        "PURGE",
-        "OPTIONS",
-        "DELETE",
-        "PROPFIND",
-        "PROPPATCH",
-        "MKCOL",
-        "COPY",
-        "MOVE",
-        "LOCK",
-        "UNLOCK",
-        "BMOVE",
-        "BDELETE",
-        "BPROPFIND",
-        "BPROPPATCH",
-        "BCOPY",
-        "SEARCH",
-        "SUBSCRIBE",
-        "UNSUBSCRIBE",
-        "POLL",
-        "REPORT",
-        "%EXT00",
-        "%EXT01",
-        "%EXT02",
-        "%EXT03",
-        "%EXT04",
-        "%EXT05",
-        "%EXT06",
-        "%EXT07",
-        "%EXT08",
-        "%EXT09",
-        "%EXT10",
-        "%EXT11",
-        "%EXT12",
-        "%EXT13",
-        "%EXT14",
-        "%EXT15",
-        "%EXT16",
-        "%EXT17",
-        "%EXT18",
-        "%EXT19",
-        "ERROR"
-    };
-
-const char *ProtocolStr[] =
-    {
-        "NONE",
-        "http",
-        "ftp",
-        "gopher",
-        "wais",
-        "cache_object",
-        "icp",
-#if USE_HTCP
-        "htcp",
-#endif
-        "urn",
-        "whois",
-        "internal",
-        "https",
-        "TOTAL"
-    };
+#include "URLScheme.h"
 
 static HttpRequest *urnParse(method_t method, char *urn);
 #if CHECK_HOSTNAMES
@@ -159,7 +88,10 @@ void
 urlInitialize(void)
 {
     debug(23, 5) ("urlInitialize: Initializing...\n");
-    assert(sizeof(ProtocolStr) == (PROTO_MAX + 1) * sizeof(char *));
+    /* this ensures that the number of protocol strings is the same as
+     * the enum slots allocated because the last enum is always 'TOTAL'.
+     */
+    assert(strcmp(ProtocolStr[PROTO_MAX], "TOTAL") == 0);
     /*
      * These test that our matchDomainName() function works the
      * way we expect it to.
@@ -184,47 +116,6 @@ urlInitialize(void)
     /* more cases? */
 }
 
-method_t &operator++ (method_t &aMethod)
-{
-    int tmp = (int)aMethod;
-    aMethod = (method_t)(++tmp);
-    return aMethod;
-}
-
-/*
- * urlParseMethod() takes begin and end pointers, but for backwards
- * compatibility, end defaults to NULL, in which case we assume begin
- * is NULL-terminated.
- */
-method_t
-urlParseMethod(const char *b, const char *e)
-{
-    method_t method = METHOD_NONE;
-    /*
-     * This check for '%' makes sure that we don't
-     * match one of the extension method placeholders,
-     * which have the form %EXT[0-9][0-9]
-     */
-
-    if (*b == '%')
-        return METHOD_NONE;
-
-    /*
-     * if e is NULL, b must be NULL terminated and we
-     * make e point to the first whitespace character
-     * after b.
-     */
-    if (NULL == e)
-        e = b + strcspn(b, w_space);
-
-    for (++method; method < METHOD_ENUM_END; ++method) {
-        if (0 == strncasecmp(b, RequestMethodStr[method], e-b))
-            return method;
-    }
-
-    return METHOD_NONE;
-}
-
 /*
  * urlParseProtocol() takes begin (b) and end (e) pointers, but for
  * backwards compatibility, e defaults to NULL, in which case we
@@ -676,6 +567,10 @@ matchDomainName(const char *h, const char *d)
     return (xtolower(h[hl]) - xtolower(d[dl]));
 }
 
+
+/*
+ * what does the return code of this mean ?
+ */
 int
 urlCheckRequest(const HttpRequest * r)
 {
@@ -836,44 +731,8 @@ URLHostName::extract(char const *aUrl)
     return Host;
 }
 
-static void
-urlExtMethodAdd(const char *mstr)
-{
-    method_t method = METHOD_NONE;
-
-    for (++method; method < METHOD_ENUM_END; ++method) {
-        if (0 == strcmp(mstr, RequestMethodStr[method])) {
-            debug(23, 2) ("Extension method '%s' already exists\n", mstr);
-            return;
-        }
-
-        if (0 != strncmp("%EXT", RequestMethodStr[method], 4))
-            continue;
-
-        /* Don't free statically allocated "%EXTnn" string */
-        RequestMethodStr[method] = xstrdup(mstr);
-
-        debug(23, 1) ("Extension method '%s' added, enum=%d\n", mstr, (int) method);
-
-        return;
-    }
-
-    debug(23, 1) ("WARNING: Could not add new extension method '%s' due to lack of array space\n", mstr);
-}
-
-void
-urlExtMethodConfigure(void)
-{
-    wordlist *w = Config.ext_methods;
+URL::URL() : scheme()
+{}
 
-    while (w) {
-        char *s;
-
-        for (s = w->key; *s; s++)
-            *s = xtoupper(*s);
-
-        urlExtMethodAdd(w->key);
-
-        w = w->next;
-    }
-}
+URL::URL(URLScheme const &aScheme): scheme(aScheme)
+{}
index 1b50db3163dfb5d363afee35ddfd4e996c57412e..208af668ad295fd03410d79fa5154567044e6e77 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: urn.cc,v 1.98 2006/05/06 22:13:18 wessels Exp $
+ * $Id: urn.cc,v 1.99 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 52    URN Parsing
  * AUTHOR: Kostas Anagnostakis
@@ -40,6 +40,7 @@
 #include "HttpRequest.h"
 #include "MemBuf.h"
 #include "forward.h"
+#include "SquidTime.h"
 
 #define        URN_REQBUF_SZ   4096
 
index 98afbc014efc8b211ac0e3221f1763de69a97d55..983ec22d39c8e180e4ec78e1b8ea12c395247331 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: wais.cc,v 1.157 2006/05/06 22:13:18 wessels Exp $
+ * $Id: wais.cc,v 1.158 2006/05/08 23:38:33 robertc Exp $
  *
  * DEBUG: section 24    WAIS Relay
  * AUTHOR: Harvest Derived
@@ -43,6 +43,7 @@
 #include "comm.h"
 #include "MemBuf.h"
 #include "forward.h"
+#include "SquidTime.h"
 
 class WaisStateData
 {
index edff69b29721490b7c5ba946f67b1abc395a4e48..21c536126b2e1360d1e4cced5c0f4d86077cb75d 100644 (file)
@@ -1,7 +1,7 @@
 #
 #  Makefile for the Squid Object Cache server
 #
-#  $Id: Makefile.am,v 1.17 2004/08/30 03:29:03 robertc Exp $
+#  $Id: Makefile.am,v 1.18 2006/05/08 23:38:36 robertc Exp $
 #
 
 AUTOMAKE_OPTIONS = subdir-objects
@@ -50,7 +50,7 @@ check_PROGRAMS= debug \
                syntheticoperators \
                VirtualDeleteOperator
 
-LDADD =$(top_builddir)/src/globals.o -L$(top_builddir)/lib -lmiscutil
+LDADD =$(top_builddir)/src/globals.o $(top_builddir)/src/time.o -L$(top_builddir)/lib -lmiscutil
 DEBUG_SOURCE = test_tools.cc
 debug_SOURCES = debug.cc $(DEBUG_SOURCE)
 ESIExpressions_SOURCES = ESIExpressions.cc $(DEBUG_SOURCE)