From 985c86bcee07adc0faaf8aa5551cc05f4eefd564 Mon Sep 17 00:00:00 2001 From: robertc <> Date: Tue, 9 May 2006 05:38:33 +0000 Subject: [PATCH] More decoupling work: 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. --- src/ACLMethodData.cc | 5 +- src/ACLProtocolData.cc | 3 +- src/ACLTime.cc | 3 +- src/AuthUserRequest.cc | 3 +- src/DiskIO/DiskDaemon/DiskdIOStrategy.cc | 3 +- src/DiskIO/DiskThreads/aiops.cc | 3 +- src/ExternalACLEntry.cc | 3 +- src/HttpHeader.h | 16 +- src/HttpReply.cc | 3 +- src/HttpRequest.cc | 6 +- src/HttpRequest.h | 3 +- src/HttpRequestMethod.cc | 177 +++++++++++++++++++ src/HttpRequestMethod.h | 147 +++++++++++++++ src/ICAP/ICAPModXact.cc | 1 + src/ICAP/ICAPOptions.cc | 1 + src/ICAP/ICAPServiceRep.cc | 1 + src/Makefile.am | 206 ++++++++++++++++++++-- src/SquidTime.h | 45 +++++ src/URL.h | 75 ++++++++ src/URLScheme.cc | 58 ++++++ src/URLScheme.h | 80 +++++++++ src/access_log.cc | 5 +- src/auth/basic/auth_basic.cc | 3 +- src/cache_cf.cc | 4 +- src/cache_manager.cc | 3 +- src/cf_gen.cc | 15 +- src/client_db.cc | 3 +- src/client_side.cc | 5 +- src/client_side_reply.cc | 3 +- src/client_side_request.cc | 3 +- src/comm.cc | 3 +- src/comm_poll.cc | 3 +- src/debug.cc | 3 +- src/defines.h | 5 +- src/delay_pools.cc | 3 +- src/dns_internal.cc | 3 +- src/enums.h | 53 +----- src/errorpage.cc | 8 +- src/external_acl.cc | 4 +- src/fd.cc | 3 +- src/fde.cc | 3 +- src/forward.cc | 3 +- src/fqdncache.cc | 3 +- src/fs/ufs/store_dir_ufs.cc | 3 +- src/ftp.cc | 4 +- src/globals.h | 5 +- src/gopher.cc | 3 +- src/helper.cc | 3 +- src/htcp.cc | 5 +- src/http.cc | 3 +- src/icp_v2.cc | 3 +- src/internal.cc | 3 +- src/ipcache.cc | 3 +- src/main.cc | 3 +- src/mem.cc | 3 +- src/neighbors.cc | 3 +- src/net_db.cc | 3 +- src/peer_digest.cc | 3 +- src/pinger.cc | 17 +- src/protos.h | 8 +- src/refresh.cc | 3 +- src/repl/heap/store_heap_replacement.cc | 3 +- src/repl/lru/store_repl_lru.cc | 3 +- src/send-announce.cc | 3 +- src/store.cc | 3 +- src/store_digest.cc | 3 +- src/store_dir.cc | 3 +- src/store_rebuild.cc | 3 +- src/structs.h | 6 +- src/tests/stub_tools.cc | 17 +- src/tests/testCoss.cc | 1 + src/tests/testHeader_HttpRequestMethod.cc | 4 + src/tests/testHeader_URL.cc | 4 + src/tests/testHeader_URLScheme.cc | 4 + src/tests/testHttpRequestMethod.cc | 117 ++++++++++++ src/tests/testHttpRequestMethod.h | 40 +++++ src/tests/testNull.cc | 1 + src/tests/testStoreController.cc | 1 + src/tests/testStoreHashIndex.cc | 1 + src/tests/testURL.cc | 53 ++++++ src/tests/testURL.h | 27 +++ src/tests/testURLScheme.cc | 136 ++++++++++++++ src/tests/testURLScheme.h | 50 ++++++ src/tests/testUfs.cc | 1 + src/time.cc | 5 +- src/tools.cc | 3 +- src/typedefs.h | 7 +- src/url.cc | 171 ++---------------- src/urn.cc | 3 +- src/wais.cc | 3 +- test-suite/Makefile.am | 4 +- 91 files changed, 1390 insertions(+), 351 deletions(-) create mode 100644 src/HttpRequestMethod.cc create mode 100644 src/HttpRequestMethod.h create mode 100644 src/SquidTime.h create mode 100644 src/URL.h create mode 100644 src/URLScheme.cc create mode 100644 src/URLScheme.h create mode 100644 src/tests/testHeader_HttpRequestMethod.cc create mode 100644 src/tests/testHeader_URL.cc create mode 100644 src/tests/testHeader_URLScheme.cc create mode 100644 src/tests/testHttpRequestMethod.cc create mode 100644 src/tests/testHttpRequestMethod.h create mode 100644 src/tests/testURL.cc create mode 100644 src/tests/testURL.h create mode 100644 src/tests/testURLScheme.cc create mode 100644 src/tests/testURLScheme.h diff --git a/src/ACLMethodData.cc b/src/ACLMethodData.cc index 54bab8d372..427b8ff193 100644 --- a/src/ACLMethodData.cc +++ b/src/ACLMethodData.cc @@ -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 *q = new List (urlParseMethod(t)); + List *q = new List (HttpRequestMethod(t)); *(Tail) = q; Tail = &q->next; } diff --git a/src/ACLProtocolData.cc b/src/ACLProtocolData.cc index e934258395..5575e1eb53 100644 --- a/src/ACLProtocolData.cc +++ b/src/ACLProtocolData.cc @@ -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) diff --git a/src/ACLTime.cc b/src/ACLTime.cc index f888cdace1..828109a5c9 100644 --- a/src/ACLTime.cc +++ b/src/ACLTime.cc @@ -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 ACLTime::RegistryEntry_(new ACLTimeData, ACLTimeStrategy::Instance(), "time"); diff --git a/src/AuthUserRequest.cc b/src/AuthUserRequest.cc index 759a4a7bf8..ead27d4d43 100644 --- a/src/AuthUserRequest.cc +++ b/src/AuthUserRequest.cc @@ -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); diff --git a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc index 6986c2d89b..5c6c306209 100644 --- a/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc +++ b/src/DiskIO/DiskDaemon/DiskdIOStrategy.cc @@ -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; diff --git a/src/DiskIO/DiskThreads/aiops.cc b/src/DiskIO/DiskThreads/aiops.cc index 744461382c..155765ab52 100644 --- a/src/DiskIO/DiskThreads/aiops.cc +++ b/src/DiskIO/DiskThreads/aiops.cc @@ -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 @@ -51,6 +51,7 @@ #include #endif #include "CommIO.h" +#include "SquidTime.h" #define RIDICULOUS_LENGTH 4096 diff --git a/src/ExternalACLEntry.cc b/src/ExternalACLEntry.cc index 88ffbe6b6b..c6b5c31c82 100644 --- a/src/ExternalACLEntry.cc +++ b/src/ExternalACLEntry.cc @@ -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 diff --git a/src/HttpHeader.h b/src/HttpHeader.h index c840935d3d..f97bf44b12 100644 --- a/src/HttpHeader.h +++ b/src/HttpHeader.h @@ -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 { diff --git a/src/HttpReply.cc b/src/HttpReply.cc index b46107ecfe..8a3e6b6cd5 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -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" diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 0a243c6e66..f2106aa1fc 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -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; diff --git a/src/HttpRequest.h b/src/HttpRequest.h index 1a34c067d6..6add8ee3d3 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -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 index 0000000000..1f8940e09c --- /dev/null +++ b/src/HttpRequestMethod.cc @@ -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 + */ + +#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 index 0000000000..d19c91f783 --- /dev/null +++ b/src/HttpRequestMethod.h @@ -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 + +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 */ diff --git a/src/ICAP/ICAPModXact.cc b/src/ICAP/ICAPModXact.cc index 75379587c2..565ce9ff24 100644 --- a/src/ICAP/ICAPModXact.cc +++ b/src/ICAP/ICAPModXact.cc @@ -15,6 +15,7 @@ #include "TextException.h" #include "AuthUserRequest.h" #include "ICAPConfig.h" +#include "SquidTime.h" // flow and terminology: // HTTP| --> receive --> encode --> write --> |network diff --git a/src/ICAP/ICAPOptions.cc b/src/ICAP/ICAPOptions.cc index 43a523bbab..0ffae1b28c 100644 --- a/src/ICAP/ICAPOptions.cc +++ b/src/ICAP/ICAPOptions.cc @@ -3,6 +3,7 @@ #include "ICAPOptions.h" #include "TextException.h" #include "ICAPConfig.h" +#include "SquidTime.h" extern ICAPConfig TheICAPConfig; diff --git a/src/ICAP/ICAPServiceRep.cc b/src/ICAP/ICAPServiceRep.cc index 7ddcad7e2d..cbd18e76bd 100644 --- a/src/ICAP/ICAPServiceRep.cc +++ b/src/ICAP/ICAPServiceRep.cc @@ -8,6 +8,7 @@ #include "ICAPOptions.h" #include "ICAPOptXact.h" #include "ConfigParser.h" +#include "SquidTime.h" CBDATA_CLASS_INIT(ICAPServiceRep); diff --git a/src/Makefile.am b/src/Makefile.am index 803d0c38e5..c05e0bab50 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -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 index 0000000000..45954e633c --- /dev/null +++ b/src/SquidTime.h @@ -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 index 0000000000..7ae51661dc --- /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 index 0000000000..c4bff4a1bd --- /dev/null +++ b/src/URLScheme.cc @@ -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 index 0000000000..e6d8f7f883 --- /dev/null +++ b/src/URLScheme.h @@ -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 + +/* 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 */ diff --git a/src/access_log.cc b/src/access_log.cc index dae1bc70cc..402288c62b 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -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; diff --git a/src/auth/basic/auth_basic.cc b/src/auth/basic/auth_basic.cc index 84217c87f8..f55fe929bc 100644 --- a/src/auth/basic/auth_basic.cc +++ b/src/auth/basic/auth_basic.cc @@ -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) diff --git a/src/cache_cf.cc b/src/cache_cf.cc index 431b00eb65..6ae21ae360 100644 --- a/src/cache_cf.cc +++ b/src/cache_cf.cc @@ -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"); diff --git a/src/cache_manager.cc b/src/cache_manager.cc index 58af2e5bbe..df5fab278e 100644 --- a/src/cache_manager.cc +++ b/src/cache_manager.cc @@ -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 diff --git a/src/cf_gen.cc b/src/cf_gen.cc index 43cd7c9510..b188af5af3 100644 --- a/src/cf_gen.cc +++ b/src/cf_gen.cc @@ -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(¤t_time); -#else - - gettimeofday(¤t_time, NULL); -#endif - - return squid_curtime = current_time.tv_sec; -} static void lineAdd(Line ** L, const char *str) diff --git a/src/client_db.cc b/src/client_db.cc index 524f67b285..b8f2b25a7d 100644 --- a/src/client_db.cc +++ b/src/client_db.cc @@ -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" diff --git a/src/client_side.cc b/src/client_side.cc index 3e73fbe196..9b7558f68a 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -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); diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index de5dae337c..93b5074192 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -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); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index f7cb8f8e48..2650461bad 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -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 diff --git a/src/comm.cc b/src/comm.cc index f40a42457d..e3c31c46ba 100644 --- a/src/comm.cc +++ b/src/comm.cc @@ -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 diff --git a/src/comm_poll.cc b/src/comm_poll.cc index a5af95c2db..0643c16902 100644 --- a/src/comm_poll.cc +++ b/src/comm_poll.cc @@ -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" diff --git a/src/debug.cc b/src/debug.cc index 6d4f481776..9fe6f65276 100644 --- a/src/debug.cc +++ b/src/debug.cc @@ -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 int Debug::Levels[MAX_DEBUG_SECTIONS]; diff --git a/src/defines.h b/src/defines.h index 30493e20aa..5bf9264f51 100644 --- a/src/defines.h +++ b/src/defines.h @@ -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/ @@ -221,9 +221,6 @@ #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)) diff --git a/src/delay_pools.cc b/src/delay_pools.cc index 4f4127ef27..10e9d97e63 100644 --- a/src/delay_pools.cc +++ b/src/delay_pools.cc @@ -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 @@ -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" diff --git a/src/dns_internal.cc b/src/dns_internal.cc index 81e2e02501..a21576371f 100644 --- a/src/dns_internal.cc +++ b/src/dns_internal.cc @@ -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" diff --git a/src/enums.h b/src/enums.h index 4a2e8aed1e..7f694af08c 100644 --- a/src/enums.h +++ b/src/enums.h @@ -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, diff --git a/src/errorpage.cc b/src/errorpage.cc index e58ab4f78c..0d6dd16730 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -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 @@ -42,12 +42,14 @@ #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': diff --git a/src/external_acl.cc b/src/external_acl.cc index 8bccd9b6ff..3d0d320880 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -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 diff --git a/src/fd.cc b/src/fd.cc index fa17b6365b..0c4a255051 100644 --- 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); diff --git a/src/fde.cc b/src/fde.cc index 69534d24ac..ad1cbec04e 100644 --- a/src/fde.cc +++ b/src/fde.cc @@ -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" diff --git a/src/forward.cc b/src/forward.cc index b391598bad..4c775e286c 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -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" diff --git a/src/fqdncache.cc b/src/fqdncache.cc index 8165ac58cd..ae6bcd6ffd 100644 --- a/src/fqdncache.cc +++ b/src/fqdncache.cc @@ -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" diff --git a/src/fs/ufs/store_dir_ufs.cc b/src/fs/ufs/store_dir_ufs.cc index b16b2cfef2..32712e6263 100644 --- a/src/fs/ufs/store_dir_ufs.cc +++ b/src/fs/ufs/store_dir_ufs.cc @@ -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; diff --git a/src/ftp.cc b/src/ftp.cc index b12e5337b8..e3461d2e72 100644 --- a/src/ftp.cc +++ b/src/ftp.cc @@ -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" diff --git a/src/globals.h b/src/globals.h index dc86f679ca..8a9d563582 100644 --- a/src/globals.h +++ b/src/globals.h @@ -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 */ diff --git a/src/gopher.cc b/src/gopher.cc index 697a3a3803..d9cefb289f 100644 --- a/src/gopher.cc +++ b/src/gopher.cc @@ -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' diff --git a/src/helper.cc b/src/helper.cc index 8b2c29897b..b34e13fc9e 100644 --- a/src/helper.cc +++ b/src/helper.cc @@ -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" diff --git a/src/htcp.cc b/src/htcp.cc index 28689be66d..f579588ff0 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -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); diff --git a/src/http.cc b/src/http.cc index 5ed629577a..990b527a1a 100644 --- a/src/http.cc +++ b/src/http.cc @@ -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); diff --git a/src/icp_v2.cc b/src/icp_v2.cc index 79dbbb21b9..42ed6a2612 100644 --- a/src/icp_v2.cc +++ b/src/icp_v2.cc @@ -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); diff --git a/src/internal.cc b/src/internal.cc index 6a12912dea..996391a157 100644 --- a/src/internal.cc +++ b/src/internal.cc @@ -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; diff --git a/src/ipcache.cc b/src/ipcache.cc index 41f6a56372..0202738c5f 100644 --- a/src/ipcache.cc +++ b/src/ipcache.cc @@ -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" diff --git a/src/main.cc b/src/main.cc index eecea8eaf7..b9e240b686 100644 --- a/src/main.cc +++ b/src/main.cc @@ -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" diff --git a/src/mem.cc b/src/mem.cc index 0669a337b4..bc3579471f 100644 --- a/src/mem.cc +++ b/src/mem.cc @@ -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 */ diff --git a/src/neighbors.cc b/src/neighbors.cc index 12aab5eb5d..88f1a1ef13 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -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 diff --git a/src/net_db.cc b/src/net_db.cc index 89386f8138..8b8dadcda6 100644 --- a/src/net_db.cc +++ b/src/net_db.cc @@ -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 diff --git a/src/peer_digest.cc b/src/peer_digest.cc index 2e77ad673d..452f65fbaf 100644 --- a/src/peer_digest.cc +++ b/src/peer_digest.cc @@ -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" diff --git a/src/pinger.cc b/src/pinger.cc index 3180942890..45bcc7fbf1 100644 --- a/src/pinger.cc +++ b/src/pinger.cc @@ -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(¤t_time); -#else - - gettimeofday(¤t_time, NULL); -#endif - - return squid_curtime = current_time.tv_sec; -} - - int main(int argc, char *argv[]) { diff --git a/src/protos.h b/src/protos.h index 92230ee1e4..7ba88cac02 100644 --- a/src/protos.h +++ b/src/protos.h @@ -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/ @@ -38,6 +38,10 @@ * 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 *); diff --git a/src/refresh.cc b/src/refresh.cc index 0d945ee6e7..a72ca5753d 100644 --- a/src/refresh.cc +++ b/src/refresh.cc @@ -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, diff --git a/src/repl/heap/store_heap_replacement.cc b/src/repl/heap/store_heap_replacement.cc index 3bf01d3468..b8f932037b 100644 --- a/src/repl/heap/store_heap_replacement.cc +++ b/src/repl/heap/store_heap_replacement.cc @@ -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 diff --git a/src/repl/lru/store_repl_lru.cc b/src/repl/lru/store_repl_lru.cc index 8f1ec5e4d3..22208d865a 100644 --- a/src/repl/lru/store_repl_lru.cc +++ b/src/repl/lru/store_repl_lru.cc @@ -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; diff --git a/src/send-announce.cc b/src/send-announce.cc index 83c84e9afc..8abb86e0d5 100644 --- a/src/send-announce.cc +++ b/src/send-announce.cc @@ -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; diff --git a/src/store.cc b/src/store.cc index 9107cfa508..39ac8d5207 100644 --- a/src/store.cc +++ b/src/store.cc @@ -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; diff --git a/src/store_digest.cc b/src/store_digest.cc index a30f6d59cb..cb642b5763 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -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" /* diff --git a/src/store_dir.cc b/src/store_dir.cc index cd831732cd..9cab425b9c 100644 --- a/src/store_dir.cc +++ b/src/store_dir.cc @@ -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 diff --git a/src/store_rebuild.cc b/src/store_rebuild.cc index 6e999d1112..b65a7e6b2a 100644 --- a/src/store_rebuild.cc +++ b/src/store_rebuild.cc @@ -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; diff --git a/src/structs.h b/src/structs.h index de443cf4fe..68a767f5e1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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; diff --git a/src/tests/stub_tools.cc b/src/tests/stub_tools.cc index be6a7dce97..edcfc389f5 100644 --- a/src/tests/stub_tools.cc +++ b/src/tests/stub_tools.cc @@ -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 * @@ -33,21 +33,6 @@ #include "squid.h" -time_t -getCurrentTime(void) -{ -#if GETTIMEOFDAY_NO_TZP - gettimeofday(¤t_time); -#else - - gettimeofday(¤t_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) { diff --git a/src/tests/testCoss.cc b/src/tests/testCoss.cc index 4c4f65f71a..6fe474ce6f 100644 --- a/src/tests/testCoss.cc +++ b/src/tests/testCoss.cc @@ -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 index 0000000000..d107ca3b6e --- /dev/null +++ b/src/tests/testHeader_HttpRequestMethod.cc @@ -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 index 0000000000..34b420442b --- /dev/null +++ b/src/tests/testHeader_URL.cc @@ -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 index 0000000000..40b19cdefc --- /dev/null +++ b/src/tests/testHeader_URLScheme.cc @@ -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 index 0000000000..8709cb1e6a --- /dev/null +++ b/src/tests/testHttpRequestMethod.cc @@ -0,0 +1,117 @@ +#include "squid.h" +#include +#include + +#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 index 0000000000..8e79993d31 --- /dev/null +++ b/src/tests/testHttpRequestMethod.h @@ -0,0 +1,40 @@ + +#ifndef SQUID_SRC_TEST_HTTP_REQUEST_METHOD_H +#define SQUID_SRC_TEST_HTTP_REQUEST_METHOD_H + +#include + +/* + * 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 + diff --git a/src/tests/testNull.cc b/src/tests/testNull.cc index fe6aff2589..74ca9f4532 100644 --- a/src/tests/testNull.cc +++ b/src/tests/testNull.cc @@ -11,6 +11,7 @@ #include "HttpHeader.h" #include "HttpReply.h" #include "StoreFileSystem.h" +#include "SquidTime.h" #define TESTDIR "testNull__testNullSearch" diff --git a/src/tests/testStoreController.cc b/src/tests/testStoreController.cc index 0f99ab8940..17a76fc474 100644 --- a/src/tests/testStoreController.cc +++ b/src/tests/testStoreController.cc @@ -5,6 +5,7 @@ #include "SwapDir.h" #include "TestSwapDir.h" #include "Mem.h" +#include "SquidTime.h" #include "StoreSearch.h" CPPUNIT_TEST_SUITE_REGISTRATION( testStoreController ); diff --git a/src/tests/testStoreHashIndex.cc b/src/tests/testStoreHashIndex.cc index e53fc7609b..0e68702707 100644 --- a/src/tests/testStoreHashIndex.cc +++ b/src/tests/testStoreHashIndex.cc @@ -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 index 0000000000..d7beaac983 --- /dev/null +++ b/src/tests/testURL.cc @@ -0,0 +1,53 @@ +#include "squid.h" +#include +#include + +#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 index 0000000000..7ec1ce7f27 --- /dev/null +++ b/src/tests/testURL.h @@ -0,0 +1,27 @@ + +#ifndef SQUID_SRC_TEST_URL_H +#define SQUID_SRC_TEST_URL_H + +#include + +/* + * 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 index 0000000000..8d97137849 --- /dev/null +++ b/src/tests/testURLScheme.cc @@ -0,0 +1,136 @@ +#include "squid.h" +#include +#include + +#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 index 0000000000..fe8ba2b7de --- /dev/null +++ b/src/tests/testURLScheme.h @@ -0,0 +1,50 @@ + +#ifndef SQUID_SRC_TEST_URL_SCHEME_H +#define SQUID_SRC_TEST_URL_SCHEME_H + +#include + +/* + * 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 + diff --git a/src/tests/testUfs.cc b/src/tests/testUfs.cc index 1efcb5cc21..2e8c74789a 100644 --- a/src/tests/testUfs.cc +++ b/src/tests/testUfs.cc @@ -9,6 +9,7 @@ #include "Mem.h" #include "HttpHeader.h" #include "HttpReply.h" +#include "SquidTime.h" #define TESTDIR "testUfs__testUfsSearch" diff --git a/src/time.cc b/src/time.cc index 13661c2d3d..3198517655 100644 --- a/src/time.cc +++ b/src/time.cc @@ -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) diff --git a/src/tools.cc b/src/tools.cc index 377660ff43..b15f7435dc 100644 --- a/src/tools.cc +++ b/src/tools.cc @@ -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 diff --git a/src/typedefs.h b/src/typedefs.h index 6b796c99cb..bef3b33b3c 100644 --- a/src/typedefs.h +++ b/src/typedefs.h @@ -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 *); diff --git a/src/url.cc b/src/url.cc index dd5b03b309..c57ce05c12 100644 --- a/src/url.cc +++ b/src/url.cc @@ -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 @@ -33,80 +33,9 @@ * */ -#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) +{} diff --git a/src/urn.cc b/src/urn.cc index 1b50db3163..208af668ad 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -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 diff --git a/src/wais.cc b/src/wais.cc index 98afbc014e..983ec22d39 100644 --- a/src/wais.cc +++ b/src/wais.cc @@ -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 { diff --git a/test-suite/Makefile.am b/test-suite/Makefile.am index edff69b297..21c536126b 100644 --- a/test-suite/Makefile.am +++ b/test-suite/Makefile.am @@ -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) -- 2.39.5