/*
- * $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
#include "squid.h"
#include "ACLMethodData.h"
#include "ACLChecklist.h"
+#include "HttpRequestMethod.h"
#include "wordlist.h"
ACLMethodData::ACLMethodData() : values (NULL)
;
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;
}
/*
- * $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
#include "squid.h"
#include "ACLProtocolData.h"
#include "ACLChecklist.h"
+#include "URLScheme.h"
#include "wordlist.h"
ACLProtocolData::ACLProtocolData() : values (NULL)
/*
- * $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
#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");
/*
- * $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
#include "AuthScheme.h"
#include "HttpReply.h"
#include "HttpRequest.h"
+#include "SquidTime.h"
CBDATA_TYPE(auth_user_ip_t);
/*
- * $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
#include "diomsg.h"
/* for statfs */
#include "Store.h"
+#include "SquidTime.h"
diskd_stats_t diskd_stats;
/*
- * $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>
#include <sched.h>
#endif
#include "CommIO.h"
+#include "SquidTime.h"
#define RIDICULOUS_LENGTH 4096
/*
- * $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
#include "squid.h"
#include "ExternalACLEntry.h"
+#include "SquidTime.h"
/******************************************************************
* external_acl cache
/*
- * $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/
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
{
/*
- * $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
*/
#include "squid.h"
+#include "SquidTime.h"
#include "Store.h"
#include "HttpReply.h"
#include "HttpHdrContRange.h"
/*
- * $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
* 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;
}
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;
/*
- * $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/
#include "client_side.h"
#include "HierarchyLogEntry.h"
#include "BodyReader.h"
+#include "HttpRequestMethod.h"
/* Http Request */
extern int httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConnection);
--- /dev/null
+
+/*
+ * $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;
+ }
+}
--- /dev/null
+
+/*
+ * $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 */
#include "TextException.h"
#include "AuthUserRequest.h"
#include "ICAPConfig.h"
+#include "SquidTime.h"
// flow and terminology:
// HTTP| --> receive --> encode --> write --> |network
#include "ICAPOptions.h"
#include "TextException.h"
#include "ICAPConfig.h"
+#include "SquidTime.h"
extern ICAPConfig TheICAPConfig;
#include "ICAPOptions.h"
#include "ICAPOptXact.h"
#include "ConfigParser.h"
+#include "SquidTime.h"
CBDATA_CLASS_INIT(ICAPServiceRep);
#
# 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:
#
$(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
HttpReply.h \
HttpRequest.cc \
HttpRequest.h \
+ HttpRequestMethod.cc \
+ HttpRequestMethod.h \
HttpVersion.h \
icmp.cc \
ICP.h \
typedefs.h \
$(UNLINKDSOURCE) \
url.cc \
+ URL.h \
+ URLScheme.cc \
+ URLScheme.h \
urn.cc \
useragent.cc \
wais.cc \
pinger_SOURCES = \
pinger.cc \
debug.cc \
+ time.cc \
SquidNew.cc
dnsserver_SOURCES = dnsserver.cc SquidNew.cc
HttpMsg.cc \
HttpReply.cc \
HttpRequest.cc \
- HttpRequest.h \
+ HttpRequestMethod.cc \
icmp.cc \
icp_v2.cc \
icp_v3.cc \
tools.cc \
typedefs.h \
$(UNLINKDSOURCE) \
+ URLScheme.cc \
urn.cc \
useragent.cc \
wais.cc \
tests/testHttpRequest \
tests/testStore \
tests/testString \
+ tests/testURL \
@STORE_TESTS@
tests_testAuth_SOURCES= tests/testAuth.cc tests/testMain.cc tests/testAuth.h $(TESTSOURCES) \
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 \
tests/testACLMaxUserIP.cc \
tests/testACLMaxUserIP.h \
tests/testMain.cc \
+ time.cc \
mem.cc \
MemBuf.cc \
wordlist.cc \
## 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@ \
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= \
## 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 \
ConfigOption.cc \
ConfigParser.cc \
$(DELAY_POOL_SOURCE) \
- debug.cc \
disk.cc \
$(DNSSOURCE) \
event.cc \
forward.cc \
fqdncache.cc \
ftp.cc \
- globals.cc \
gopher.cc \
helper.cc \
htcp.cc \
HttpHdrSc.cc \
HttpHdrScTarget.cc \
HttpMsg.cc \
- HttpRequest.cc \
HttpReply.cc \
HttpStatusLine.cc \
icmp.cc \
list.cc \
logfile.cc \
multicast.cc \
- mem.cc \
mem_node.cc \
MemBuf.cc \
MemObject.cc \
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
# 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) \
HttpMsg.cc \
store_dir.cc \
store.cc \
+ HttpRequestMethod.cc \
store_key_md5.cc \
string_arrays.c \
Parsing.cc \
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.
tests/testMain.cc \
tests/testString.cc \
tests/testString.h \
- $(TESTSOURCES)
+ $(TESTSOURCES) \
+ time.cc
tests_testString_LDADD= \
-L../lib -lmiscutil \
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@
--- /dev/null
+
+/*
+ * $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 */
--- /dev/null
+
+/*
+ * $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 */
--- /dev/null
+
+/*
+ * $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"
+ };
+
--- /dev/null
+
+/*
+ * $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 */
/*
- * $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
#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);
#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;
/*
- * $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
#include "HttpReply.h"
#include "basicScheme.h"
#include "wordlist.h"
+#include "SquidTime.h"
static void
authenticateStateFree(AuthenticateStateData * r)
/*
- * $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
Config2.effectiveGroupID = grp->gr_gid;
}
- urlExtMethodConfigure();
+ HttpRequestMethod::Configure(Config);
#if USE_SSL
debug(3, 1) ("Initializing https proxy context\n");
/*
- * $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
#include "HttpRequest.h"
#include "Store.h"
#include "fde.h"
+#include "SquidTime.h"
#include "wordlist.h"
#define MGR_PASSWD_SZ 128
/*
- * $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
*****************************************************************************/
#include "squid.h"
+#include "SquidTime.h"
#include "cf_gen_defines.h"
#define MAX_LINE 1024 /* longest configuration line */
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)
/*
- * $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
*/
#include "squid.h"
+#include "SquidTime.h"
#include "Store.h"
/*
- * $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
#include "client_side_reply.h"
#include "ClientRequestContext.h"
#include "MemBuf.h"
+#include "SquidTime.h"
#if LINGERING_CLOSE
#define comm_close comm_lingering_close
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);
/*
- * $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)
#include "DelayPools.h"
#endif
#include "client_side.h"
+#include "SquidTime.h"
CBDATA_CLASS_INIT(clientReplyContext);
/*
- * $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)
#include "HttpReply.h"
#include "MemObject.h"
#include "ClientRequestContext.h"
+#include "SquidTime.h"
#include "wordlist.h"
#if ICAP_CLIENT
/*
- * $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
#include "ConnectionDetail.h"
#include "MemBuf.h"
#include "pconn.h"
+#include "SquidTime.h"
#if defined(_SQUID_CYGWIN_)
#include <sys/ioctl.h>
/*
- * $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
*
*/
#include "squid.h"
+#include "SquidTime.h"
#include "Store.h"
#include "fde.h"
/*
- * $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
#include "squid.h"
#include "Debug.h"
+#include "SquidTime.h"
#include <sstream>
int Debug::Levels[MAX_DEBUG_SECTIONS];
/*
- * $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))
/*
- * $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>
#include "DelayId.h"
#include "Array.h"
#include "SquidString.h"
+#include "SquidTime.h"
#include "CommonPool.h"
#include "CompositePoolNode.h"
#include "DelayPool.h"
/*
- * $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
#include "config.h"
#include "squid.h"
+#include "SquidTime.h"
#include "Store.h"
#include "comm.h"
#include "MemBuf.h"
/*
- * $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/
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,
/*
- * $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 */
break;
case 'M':
- p = r ? RequestMethodStr[r->method] : "[unkown method]";
+ p = r ? RequestMethodStr[r->method] : "[unknown method]";
break;
break;
case 'P':
- p = r ? ProtocolStr[r->protocol] : "[unkown protocol]";
+ p = r ? ProtocolStr[r->protocol] : "[unknown protocol]";
break;
case 'R':
/*
- * $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
#include "ExternalACL.h"
#include "ExternalACLEntry.h"
#include "AuthUserRequest.h"
+#include "SquidTime.h"
#include "Store.h"
#include "fde.h"
#include "ACLChecklist.h"
#include "HttpRequest.h"
#include "authenticate.h"
#include "MemBuf.h"
+#include "URLScheme.h"
#include "wordlist.h"
#ifndef DEFAULT_EXTERNAL_ACL_TTL
/*
- * $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
#include "squid.h"
#include "fde.h"
+#include "SquidTime.h"
int default_read_method(int, char *, int);
int default_write_method(int, const char *, int);
/*
- * $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
#include "squid.h"
#include "fde.h"
+#include "SquidTime.h"
#include "Store.h"
#include "comm.h"
/*
- * $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
#include "squid.h"
#include "forward.h"
+#include "SquidTime.h"
#include "Store.h"
#include "HttpRequest.h"
#include "fde.h"
/*
- * $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
*/
#include "squid.h"
+#include "SquidTime.h"
#include "Store.h"
#include "wordlist.h"
/*
- * $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
#include "DiskIO/DiskIOStrategy.h"
#include "DiskIO/DiskIOModule.h"
#include "Parsing.h"
+#include "SquidTime.h"
#include "SwapDir.h"
int UFSSwapDir::NumberOfUFSDirs = 0;
/*
- * $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
#include "Server.h"
#include "MemBuf.h"
#include "wordlist.h"
+#include "SquidTime.h"
+#include "URLScheme.h"
#if ICAP_CLIENT
#include "ICAP/ICAPClientRespmodPrecache.h"
/*
- * $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/
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; /* "-" */
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 */
/*
- * $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
#endif
#include "MemBuf.h"
#include "forward.h"
+#include "SquidTime.h"
/* gopher type code from rfc. Anawat. */
#define GOPHER_FILE '0'
/*
- * $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?
#include "squid.h"
#include "helper.h"
+#include "SquidTime.h"
#include "Store.h"
#include "comm.h"
#include "MemBuf.h"
/*
- * $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
#include "squid.h"
#include "htcp.h"
+#include "SquidTime.h"
#include "Store.h"
#include "StoreClient.h"
#include "HttpRequest.h"
void
htcpSpecifier::checkHit()
{
- method_t m = urlParseMethod(method);
+ method_t m = HttpRequestMethod(method);
char *blk_end;
checkHitRequest = HttpRequest::CreateFromUrlAndMethod(uri, m);
/*
- * $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
#include "ICAP/ICAPConfig.h"
extern ICAPConfig TheICAPConfig;
#endif
+#include "SquidTime.h"
CBDATA_CLASS_INIT(HttpStateData);
/*
- * $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
#include "ACL.h"
#include "AccessLogEntry.h"
#include "wordlist.h"
+#include "SquidTime.h"
static void icpLogIcp(struct IN_ADDR, log_type, int, const char *, int);
/*
- * $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
#include "HttpRequest.h"
#include "HttpReply.h"
#include "MemBuf.h"
+#include "SquidTime.h"
#include "wordlist.h"
/* called when we "miss" on an internal object;
/*
- * $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
*/
#include "squid.h"
+#include "SquidTime.h"
#include "Store.h"
#include "wordlist.h"
/*
- * $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
#include "StoreFileSystem.h"
#include "DiskIO/DiskIOModule.h"
#include "comm.h"
+#include "SquidTime.h"
#include "SwapDir.h"
#include "forward.h"
/*
- * $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
#include "Store.h"
#include "StoreEntryStream.h"
#include "MemBuf.h"
+#include "SquidTime.h"
/* module globals */
/*
- * $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
#include "ACLChecklist.h"
#include "htcp.h"
#include "PeerSelectState.h"
+#include "SquidTime.h"
/* count mcast group peers every 15 minutes */
#define MCAST_COUNT_RATE 900
/*
- * $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
#include "MemObject.h"
#include "fde.h"
#include "forward.h"
+#include "SquidTime.h"
#include "wordlist.h"
#if USE_ICMP
/*
- * $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
#include "HttpRequest.h"
#include "HttpReply.h"
#include "MemObject.h"
+#include "SquidTime.h"
#include "StoreClient.h"
#include "forward.h"
/*
- * $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
*/
#include "squid.h"
+#include "SquidTime.h"
#if USE_ICMP
}
}
-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[])
{
/*
- * $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);
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);
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 *);
/*
- * $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
#include "MemObject.h"
#include "HttpRequest.h"
#include "HttpReply.h"
+#include "SquidTime.h"
typedef enum {
rcHTTP,
/*
- * $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
#include "store_heap_replacement.h"
#include "Store.h"
#include "MemObject.h"
+#include "SquidTime.h"
/*
* Key generation function to implement the LFU-DA policy (Least
/*
- * $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
#include "squid.h"
#include "Store.h"
#include "MemObject.h"
+#include "SquidTime.h"
REMOVALPOLICYCREATE createRemovalPolicy_lru;
/*
- * $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
#include "squid.h"
#include "fde.h"
+#include "SquidTime.h"
static IPH send_announce;
/*
- * $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
#include "DelayPools.h"
#endif
#include "Stack.h"
+#include "SquidTime.h"
static STMCB storeWriteComplete;
/*
- * $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
#include "HttpRequest.h"
#include "HttpReply.h"
#include "MemObject.h"
+#include "SquidTime.h"
#include "StoreSearch.h"
/*
/*
- * $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
#include "squid.h"
#include "Store.h"
#include "MemObject.h"
+#include "SquidTime.h"
#include "SwapDir.h"
#if HAVE_STATVFS
/*
- * $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
#include "Store.h"
#include "SwapDir.h"
#include "StoreSearch.h"
+#include "SquidTime.h"
static struct _store_rebuild_data counts;
/*
- * $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/
/* http cache control header field */
-struct _HttpHdrCc
+class HttpHdrCc
{
+
+public:
int mask;
int max_age;
int s_maxage;
/*
- * $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(¤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)
{
#include "HttpHeader.h"
#include "HttpReply.h"
#include "StoreFileSystem.h"
+#include "SquidTime.h"
#define TESTDIR "testCoss__testCossSearch"
--- /dev/null
+/* This test tests that the header below can be processed on its own with
+ * no other #includes. Dont add any!
+ */
+#include "HttpRequestMethod.h"
--- /dev/null
+/* This test tests that the header below can be processed on its own with
+ * no other #includes. Dont add any!
+ */
+#include "URL.h"
--- /dev/null
+/* This test tests that the header below can be processed on its own with
+ * no other #includes. Dont add any!
+ */
+#include "URLScheme.h"
--- /dev/null
+#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()));
+}
--- /dev/null
+
+#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
+
#include "HttpHeader.h"
#include "HttpReply.h"
#include "StoreFileSystem.h"
+#include "SquidTime.h"
#define TESTDIR "testNull__testNullSearch"
#include "SwapDir.h"
#include "TestSwapDir.h"
#include "Mem.h"
+#include "SquidTime.h"
#include "StoreSearch.h"
CPPUNIT_TEST_SUITE_REGISTRATION( testStoreController );
#include "StoreHashIndex.h"
#include "Mem.h"
#include "StoreSearch.h"
+#include "SquidTime.h"
CPPUNIT_TEST_SUITE_REGISTRATION( testStoreHashIndex );
--- /dev/null
+#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;
+}
--- /dev/null
+
+#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
+
--- /dev/null
+#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()));
+}
--- /dev/null
+
+#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
+
#include "Mem.h"
#include "HttpHeader.h"
#include "HttpReply.h"
+#include "SquidTime.h"
#define TESTDIR "testUfs__testUfsSearch"
/*
- * $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
*
*/
-#include "squid.h"
+#include "SquidTime.h"
+time_t squid_curtime = 0;
time_t
getCurrentTime(void)
/*
- * $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
#include "fde.h"
#include "MemBuf.h"
#include "wordlist.h"
+#include "SquidTime.h"
#if HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
/*
- * $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/
class HttpHeader;
-typedef struct _HttpHdrCc HttpHdrCc;
+class HttpHdrCc;
typedef struct _TimeOrTag TimeOrTag;
/* 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 *);
/*
- * $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
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.
/* 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
return (xtolower(h[hl]) - xtolower(d[dl]));
}
+
+/*
+ * what does the return code of this mean ?
+ */
int
urlCheckRequest(const HttpRequest * r)
{
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)
+{}
/*
- * $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
#include "HttpRequest.h"
#include "MemBuf.h"
#include "forward.h"
+#include "SquidTime.h"
#define URN_REQBUF_SZ 4096
/*
- * $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
#include "comm.h"
#include "MemBuf.h"
#include "forward.h"
+#include "SquidTime.h"
class WaisStateData
{
#
# 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
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)