=== modified file 'configure.ac' --- configure.ac 2011-02-22 23:39:33 +0000 +++ configure.ac 2011-02-25 09:16:25 +0000 @@ -3349,40 +3349,41 @@ AC_MSG_NOTICE([BUILD OBJECTS: $OBJS]) AC_MSG_NOTICE([BUILD EXTRA OBJECTS: $XTRA_OBJS]) AC_MSG_NOTICE([BUILD C FLAGS: $CFLAGS]) AC_MSG_NOTICE([BUILD EXTRA C FLAGS: $SQUID_CFLAGS]) AC_MSG_NOTICE([BUILD C++ FLAGS: $CXXFLAGS]) AC_MSG_NOTICE([BUILD EXTRA C++ FLAGS: $SQUID_CXXFLAGS]) dnl Clean up after OSF/1 core dump bug rm -f core AC_CONFIG_FILES([\ Makefile \ compat/Makefile \ lib/Makefile \ lib/ntlmauth/Makefile \ lib/profiler/Makefile \ lib/rfcnb/Makefile \ lib/smblib/Makefile \ scripts/Makefile \ src/Makefile \ + src/anyp/Makefile \ src/base/Makefile \ src/acl/Makefile \ src/fs/Makefile \ src/repl/Makefile \ src/auth/Makefile \ src/adaptation/Makefile \ src/adaptation/icap/Makefile \ src/adaptation/ecap/Makefile \ src/comm/Makefile \ src/esi/Makefile \ src/eui/Makefile \ src/icmp/Makefile \ src/ident/Makefile \ src/ip/Makefile \ src/log/Makefile \ src/ipc/Makefile \ src/ssl/Makefile \ src/mgr/Makefile \ src/snmp/Makefile \ contrib/Makefile \ === modified file 'include/util.h' --- include/util.h 2010-12-03 04:57:33 +0000 +++ include/util.h 2011-02-14 09:56:16 +0000 @@ -121,21 +121,23 @@ #if !HAVE_GETTIMEOFDAY SQUIDCEXTERN int gettimeofday(struct timeval * ,void *); #endif SQUIDCEXTERN int kill(pid_t, int); SQUIDCEXTERN int statfs(const char *, struct statfs *); SQUIDCEXTERN int truncate(const char *, off_t); SQUIDCEXTERN const char * wsastrerror(int); SQUIDCEXTERN struct passwd *getpwnam(char *); SQUIDCEXTERN struct group *getgrnam(char *); SQUIDCEXTERN uid_t geteuid(void); SQUIDCEXTERN uid_t getuid(void); SQUIDCEXTERN int setuid(uid_t); SQUIDCEXTERN int seteuid(uid_t); SQUIDCEXTERN gid_t getgid(void); SQUIDCEXTERN gid_t getegid(void); SQUIDCEXTERN int setgid(gid_t); SQUIDCEXTERN int setegid(gid_t); SQUIDCEXTERN const char *WIN32_strerror(int); SQUIDCEXTERN void WIN32_maperror(unsigned long); #endif + +SQUIDCEXTERN char * strtolower(const char *); #endif /* SQUID_UTIL_H */ === modified file 'lib/util.c' --- lib/util.c 2010-11-21 11:03:56 +0000 +++ lib/util.c 2011-02-25 10:11:29 +0000 @@ -185,20 +185,39 @@ call_id = 0; /* select format */ if (value < 1e9) snprintf(buf, sizeof(GbBuf), "%.2f MB", value / 1e6); else if (value < 1e12) snprintf(buf, sizeof(GbBuf), "%.2f GB", value / 1e9); else snprintf(buf, sizeof(GbBuf), "%.2f TB", value / 1e12); return buf; } /** * rounds num to the next upper integer multiple of what */ unsigned int RoundTo(const unsigned int num, const unsigned int what) { return what * ((num + what -1)/what); } + +/** converts a whole char string (nul terminated) to lower case. + * An upper bound length of BUFSIZ bytes converted. Remainder will be truncated. + * NULL or empty string are accepted and will result in empty string return. + * The result of this call will remain usable only until any subsequest call. + */ +char * +strtolower(const char *in) +{ + static char out[BUFSIZ]; + *out = '\0'; + if (in != NULL) { + int p = 0; + for (; p < BUFSIZ && in[p] != '\0'; ++p) + out[p] = xtolower(in[p]); + out[p] = '\0'; + } + return out; +} === modified file 'src/AclRegs.cc' --- src/AclRegs.cc 2011-02-07 10:27:53 +0000 +++ src/AclRegs.cc 2011-02-14 09:56:16 +0000 @@ -93,41 +93,41 @@ ACLStrategised ACLHierCode::RegistryEntry_(new ACLHierCodeData, ACLHierCodeStrategy::Instance(), "hier_code"); ACL::Prototype ACLHTTPRepHeader::RegistryProtoype(&ACLHTTPRepHeader::RegistryEntry_, "rep_header"); ACLStrategised ACLHTTPRepHeader::RegistryEntry_(new ACLHTTPHeaderData, ACLHTTPRepHeaderStrategy::Instance(), "rep_header"); ACL::Prototype ACLHTTPReqHeader::RegistryProtoype(&ACLHTTPReqHeader::RegistryEntry_, "req_header"); ACLStrategised ACLHTTPReqHeader::RegistryEntry_(new ACLHTTPHeaderData, ACLHTTPReqHeaderStrategy::Instance(), "req_header"); ACL::Prototype ACLHTTPStatus::RegistryProtoype(&ACLHTTPStatus::RegistryEntry_, "http_status"); ACLHTTPStatus ACLHTTPStatus::RegistryEntry_("http_status"); ACL::Prototype ACLMaxConnection::RegistryProtoype(&ACLMaxConnection::RegistryEntry_, "maxconn"); ACLMaxConnection ACLMaxConnection::RegistryEntry_("maxconn"); ACL::Prototype ACLMethod::RegistryProtoype(&ACLMethod::RegistryEntry_, "method"); ACLStrategised ACLMethod::RegistryEntry_(new ACLMethodData, ACLMethodStrategy::Instance(), "method"); ACL::Prototype ACLMyIP::RegistryProtoype(&ACLMyIP::RegistryEntry_, "myip"); ACLMyIP ACLMyIP::RegistryEntry_; ACL::Prototype ACLMyPort::RegistryProtoype(&ACLMyPort::RegistryEntry_, "myport"); ACLStrategised ACLMyPort::RegistryEntry_(new ACLIntRange, ACLMyPortStrategy::Instance(), "myport"); ACL::Prototype ACLMyPortName::RegistryProtoype(&ACLMyPortName::RegistryEntry_, "myportname"); ACLStrategised ACLMyPortName::RegistryEntry_(new ACLStringData, ACLMyPortNameStrategy::Instance(), "myportname"); ACL::Prototype ACLPeerName::RegistryProtoype(&ACLPeerName::RegistryEntry_, "peername"); ACLStrategised ACLPeerName::RegistryEntry_(new ACLStringData, ACLPeerNameStrategy::Instance(), "peername"); ACL::Prototype ACLProtocol::RegistryProtoype(&ACLProtocol::RegistryEntry_, "proto"); -ACLStrategised ACLProtocol::RegistryEntry_(new ACLProtocolData, ACLProtocolStrategy::Instance(), "proto"); +ACLStrategised ACLProtocol::RegistryEntry_(new ACLProtocolData, ACLProtocolStrategy::Instance(), "proto"); ACL::Prototype ACLRandom::RegistryProtoype(&ACLRandom::RegistryEntry_, "random"); ACLRandom ACLRandom::RegistryEntry_("random"); ACL::Prototype ACLReferer::RegistryProtoype(&ACLReferer::RegistryEntry_, "referer_regex"); ACLStrategised ACLReferer::RegistryEntry_(new ACLRegexData, ACLRequestHeaderStrategy::Instance(), "referer_regex"); ACL::Prototype ACLReplyMIMEType::RegistryProtoype(&ACLReplyMIMEType::RegistryEntry_, "rep_mime_type"); ACLStrategised ACLReplyMIMEType::RegistryEntry_(new ACLRegexData, ACLReplyHeaderStrategy::Instance(), "rep_mime_type"); ACL::Prototype ACLRequestMIMEType::RegistryProtoype(&ACLRequestMIMEType::RegistryEntry_, "req_mime_type"); ACLStrategised ACLRequestMIMEType::RegistryEntry_(new ACLRegexData, ACLRequestHeaderStrategy::Instance(), "req_mime_type"); ACL::Prototype ACLSourceDomain::LiteralRegistryProtoype(&ACLSourceDomain::LiteralRegistryEntry_, "srcdomain"); ACLStrategised ACLSourceDomain::LiteralRegistryEntry_(new ACLDomainData, ACLSourceDomainStrategy::Instance(), "srcdomain"); ACL::Prototype ACLSourceDomain::RegexRegistryProtoype(&ACLSourceDomain::RegexRegistryEntry_, "srcdom_regex"); ACLStrategised ACLSourceDomain::RegexRegistryEntry_(new ACLRegexData,ACLSourceDomainStrategy::Instance() ,"srcdom_regex"); ACL::Prototype ACLSourceIP::RegistryProtoype(&ACLSourceIP::RegistryEntry_, "src"); ACLSourceIP ACLSourceIP::RegistryEntry_; ACL::Prototype ACLTime::RegistryProtoype(&ACLTime::RegistryEntry_, "time"); ACLStrategised ACLTime::RegistryEntry_(new ACLTimeData, ACLTimeStrategy::Instance(), "time"); ACL::Prototype ACLUrl::RegistryProtoype(&ACLUrl::RegistryEntry_, "url_regex"); ACLStrategised ACLUrl::RegistryEntry_(new ACLRegexData, ACLUrlStrategy::Instance(), "url_regex"); ACL::Prototype ACLUrlPath::LegacyRegistryProtoype(&ACLUrlPath::RegistryEntry_, "pattern"); ACL::Prototype ACLUrlPath::RegistryProtoype(&ACLUrlPath::RegistryEntry_, "urlpath_regex"); === modified file 'src/HttpMsg.cc' --- src/HttpMsg.cc 2011-01-25 08:55:40 +0000 +++ src/HttpMsg.cc 2011-02-14 09:56:16 +0000 @@ -21,41 +21,41 @@ * 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 "HttpMsg.h" #include "MemBuf.h" HttpMsg::HttpMsg(http_hdr_owner_type owner): header(owner), - cache_control(NULL), hdr_sz(0), content_length(0), protocol(PROTO_NONE), + cache_control(NULL), hdr_sz(0), content_length(0), protocol(AnyP::PROTO_NONE), pstate(psReadyToParseStartLine), lock_count(0) {} HttpMsg::~HttpMsg() { assert(lock_count == 0); assert(!body_pipe); } HttpMsgParseState &operator++ (HttpMsgParseState &aState) { int tmp = (int)aState; aState = (HttpMsgParseState)(++tmp); return aState; } /* find end of headers */ int httpMsgIsolateHeaders(const char **parse_start, int l, const char **blk_start, const char **blk_end) { === modified file 'src/HttpMsg.h' --- src/HttpMsg.h 2011-02-21 05:06:20 +0000 +++ src/HttpMsg.h 2011-02-25 09:16:25 +0000 @@ -72,41 +72,41 @@ * \retval false the message sender will close the connection. * * Factors other than the headers may result in connection closure. */ bool persistent() const; public: HttpVersion http_ver; HttpHeader header; HttpHdrCc *cache_control; /* Unsupported, writable, may disappear/change in the future * For replies, sums _stored_ status-line, headers, and . * Also used to report parsed header size if parse() is successful */ int hdr_sz; int64_t content_length; - protocol_t protocol; + AnyP::ProtocolType protocol; HttpMsgParseState pstate; /* the current parsing state */ BodyPipe::Pointer body_pipe; // optional pipeline to receive message body // returns true and sets hdr_sz on success // returns false and sets *error to zero when needs more data // returns false and sets *error to a positive http_status code on error bool parse(MemBuf *buf, bool eol, http_status *error); bool parseCharBuf(const char *buf, ssize_t end); int httpMsgParseStep(const char *buf, int len, int atEnd); virtual int httpMsgParseError(); virtual bool expectingBody(const HttpRequestMethod&, int64_t&) const = 0; void firstLineBuf(MemBuf&); === modified file 'src/HttpRequest.cc' --- src/HttpRequest.cc 2011-02-07 10:27:53 +0000 +++ src/HttpRequest.cc 2011-02-14 10:51:08 +0000 @@ -36,67 +36,67 @@ #include "squid.h" #include "HttpRequest.h" #if USE_AUTH #include "auth/UserRequest.h" #endif #include "HttpHeaderRange.h" #include "MemBuf.h" #include "Store.h" #if ICAP_CLIENT #include "adaptation/icap/icap_log.h" #endif #include "acl/FilledChecklist.h" #include "err_detail_type.h" HttpRequest::HttpRequest() : HttpMsg(hoRequest) { init(); } -HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) +HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) { static unsigned int id = 1; debugs(93,7, HERE << "constructed, this=" << this << " id=" << ++id); init(); initHTTP(aMethod, aProtocol, aUrlpath); } HttpRequest::~HttpRequest() { clean(); debugs(93,7, HERE << "destructed, this=" << this); } void -HttpRequest::initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) +HttpRequest::initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) { method = aMethod; protocol = aProtocol; urlpath = aUrlpath; } void HttpRequest::init() { method = METHOD_NONE; - protocol = PROTO_NONE; + protocol = AnyP::PROTO_NONE; urlpath = NULL; login[0] = '\0'; host[0] = '\0'; host_is_numeric = -1; #if USE_AUTH auth_user_request = NULL; #endif pinned_connection = NULL; port = 0; canonical = NULL; memset(&flags, '\0', sizeof(flags)); range = NULL; ims = -1; imslen = 0; lastmod = -1; client_addr.SetEmpty(); #if USE_SQUID_EUI client_eui48.clear(); client_eui64.clear(); #endif @@ -548,59 +548,59 @@ } /* * Create a Request from a URL. * * If the request cannot be created cleanly, NULL is returned */ HttpRequest * HttpRequest::CreateFromUrl(char * url) { return urlParse(METHOD_GET, url, NULL); } /* * Are responses to this request possible cacheable ? * If false then no matter what the response must not be cached. */ bool HttpRequest::cacheable() const { - if (protocol == PROTO_HTTP) + if (protocol == AnyP::PROTO_HTTP) return httpCachable(method); /* * The below looks questionable: what non HTTP protocols use connect, * trace, put and post? RC */ if (!method.isCacheble()) return false; /* * XXX POST may be cached sometimes.. ignored * for now */ - if (protocol == PROTO_GOPHER) + if (protocol == AnyP::PROTO_GOPHER) return gopherCachable(this); - if (protocol == PROTO_CACHEOBJ) + if (protocol == AnyP::PROTO_CACHEOBJ) return false; return true; } bool HttpRequest::conditional() const { return flags.ims || header.has(HDR_IF_MATCH) || header.has(HDR_IF_NONE_MATCH); } bool HttpRequest::inheritProperties(const HttpMsg *aMsg) { const HttpRequest* aReq = dynamic_cast(aMsg); if (!aReq) return false; client_addr = aReq->client_addr; === modified file 'src/HttpRequest.h' --- src/HttpRequest.h 2011-02-24 10:18:58 +0000 +++ src/HttpRequest.h 2011-02-25 09:16:25 +0000 @@ -56,50 +56,50 @@ // TODO: Move these three to access_log.h or AccessLogEntry.h #if USE_ADAPTATION extern bool alLogformatHasAdaptToken; #endif #if ICAP_CLIENT extern bool alLogformatHasIcapToken; #endif extern int LogfileStatus; class HttpHdrRange; class DnsLookupDetails; class HttpRequest: public HttpMsg { public: typedef HttpMsgPointerT Pointer; MEMPROXY_CLASS(HttpRequest); HttpRequest(); - HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath); + HttpRequest(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath); ~HttpRequest(); virtual void reset(); // use HTTPMSGLOCK() instead of calling this directly virtual HttpRequest *_lock() { return static_cast(HttpMsg::_lock()); }; - void initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath); + void initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath); virtual HttpRequest *clone() const; /* are responses to this request potentially cachable */ bool cacheable() const; bool conditional() const; ///< has at least one recognized If-* header /// whether the client is likely to be able to handle a 1xx reply bool canHandle1xx() const; /* Now that we care what host contains it is better off being protected. */ /* HACK: These two methods are only inline to get around Makefile dependancies */ /* caused by HttpRequest being used in places it really shouldn't. */ /* ideally they would be methods of URL instead. */ inline void SetHost(const char *src) { host_addr.SetEmpty(); host_addr = src; if ( host_addr.IsAnyAddr() ) { xstrncpy(host, src, SQUIDHOSTNAMELEN); === modified file 'src/HttpStatusLine.cc' --- src/HttpStatusLine.cc 2009-11-03 01:12:56 +0000 +++ src/HttpStatusLine.cc 2011-02-14 09:56:17 +0000 @@ -43,89 +43,89 @@ void httpStatusLineInit(HttpStatusLine * sline) { HttpVersion version; httpStatusLineSet(sline, version, HTTP_STATUS_NONE, NULL); } void httpStatusLineClean(HttpStatusLine * sline) { HttpVersion version; httpStatusLineSet(sline, version, HTTP_INTERNAL_SERVER_ERROR, NULL); } /* set values */ void httpStatusLineSet(HttpStatusLine * sline, HttpVersion version, http_status status, const char *reason) { assert(sline); - sline->protocol = PROTO_HTTP; + sline->protocol = AnyP::PROTO_HTTP; sline->version = version; sline->status = status; /* Note: no xstrdup for 'reason', assumes constant 'reasons' */ sline->reason = reason; } /** * Write HTTP version and status structures into a Packer buffer for output as HTTP status line. * Special exemption made for ICY response status lines. */ void httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p) { assert(sline && p); /* handle ICY protocol status line specially. Pass on the bad format. */ - if (sline->protocol == PROTO_ICY) { + if (sline->protocol == AnyP::PROTO_ICY) { debugs(57, 9, "packing sline " << sline << " using " << p << ":"); debugs(57, 9, "FORMAT=" << IcyStatusLineFormat ); debugs(57, 9, "ICY " << sline->status << " " << (sline->reason ? sline->reason : httpStatusString(sline->status)) ); packerPrintf(p, IcyStatusLineFormat, sline->status, httpStatusLineReason(sline)); return; } debugs(57, 9, "packing sline " << sline << " using " << p << ":"); debugs(57, 9, "FORMAT=" << HttpStatusLineFormat ); debugs(57, 9, "HTTP/" << sline->version.major << "." << sline->version.minor << " " << sline->status << " " << (sline->reason ? sline->reason : httpStatusString(sline->status)) ); packerPrintf(p, HttpStatusLineFormat, sline->version.major, sline->version.minor, sline->status, httpStatusLineReason(sline)); } /* * Parse character string into 'sline'. Note 'end' currently unused, * so NULL-termination assumed. */ int httpStatusLineParse(HttpStatusLine * sline, const String &protoPrefix, const char *start, const char *end) { assert(sline); sline->status = HTTP_INVALID_HEADER; /* Squid header parsing error */ // XXX: HttpMsg::parse() has a similar check but is using // casesensitive comparison (which is required by HTTP errata?) if (protoPrefix.cmp("ICY", 3) == 0) { debugs(57, 3, "httpStatusLineParse: Invalid HTTP identifier. Detected ICY protocol istead."); - sline->protocol = PROTO_ICY; + sline->protocol = AnyP::PROTO_ICY; start += protoPrefix.size(); } else if (protoPrefix.caseCmp(start, protoPrefix.size()) == 0) { start += protoPrefix.size(); if (!xisdigit(*start)) return 0; if (sscanf(start, "%d.%d", &sline->version.major, &sline->version.minor) != 2) { debugs(57, 7, "httpStatusLineParse: Invalid HTTP identifier."); } } else return 0; if (!(start = strchr(start, ' '))) return 0; sline->status = (http_status) atoi(++start); /* we ignore 'reason-phrase' */ === modified file 'src/HttpStatusLine.h' --- src/HttpStatusLine.h 2010-11-21 04:40:05 +0000 +++ src/HttpStatusLine.h 2011-02-14 09:56:17 +0000 @@ -19,62 +19,61 @@ * 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 */ #ifndef SQUID_HTTPSTATUSLINE_H #define SQUID_HTTPSTATUSLINE_H class Packer; class String; -/* for http_status and protocol_t */ -#include "enums.h" - +#include "HttpStatusCode.h" #include "HttpVersion.h" +#include "anyp/ProtocolType.h" #include "SquidString.h" /** * Holds the values parsed from an HTTP reply status line. * * For example: HTTP/1.1 200 Okay */ class HttpStatusLine { public: /* public, read only */ /** * By rights protocol name should be a constant "HTTP", with no need for this field to exist. - * However there are protocols which violate HTTP by sending their wn custom formats - * back with other protocol names (ICY streaming format being the current major problem) + * However there are protocols which violate HTTP by sending their own custom formats + * back with other protocol names (ICY streaming format being the current major problem). */ - protocol_t protocol; + AnyP::ProtocolType protocol; HttpVersion version; ///< breakdown of protocol version labels: 0.9 1.0 1.1 http_status status; ///< status code. ie 200 404 const char *reason; ///< points to a _constant_ string (default or supplied), never free()d */ }; /* init/clean */ SQUIDCEXTERN void httpStatusLineInit(HttpStatusLine * sline); SQUIDCEXTERN void httpStatusLineClean(HttpStatusLine * sline); /* set/get values */ SQUIDCEXTERN void httpStatusLineSet(HttpStatusLine * sline, HttpVersion version, http_status status, const char *reason); SQUIDCEXTERN const char *httpStatusLineReason(const HttpStatusLine * sline); /* parse/pack */ /* parse a 0-terminating buffer and fill internal structires; returns true on success */ SQUIDCEXTERN int httpStatusLineParse(HttpStatusLine * sline, const String &protoPrefix, const char *start, const char *end); /* pack fields using Packer */ SQUIDCEXTERN void httpStatusLinePackInto(const HttpStatusLine * sline, Packer * p); === modified file 'src/Makefile.am' --- src/Makefile.am 2011-02-18 23:11:19 +0000 +++ src/Makefile.am 2011-02-25 09:16:25 +0000 @@ -13,42 +13,42 @@ else DNSSOURCE = dns_internal.cc DNSSERVER = endif DNSSOURCE += \ DnsLookupDetails.h \ DnsLookupDetails.cc SBUF_SOURCE= \ base/InstanceId.h \ MemBlob.h \ MemBlob.cc LOADABLE_MODULES_SOURCES = \ LoadableModule.h \ LoadableModule.cc \ LoadableModules.h \ LoadableModules.cc -SUBDIRS = base comm eui acl fs repl -DIST_SUBDIRS = base comm eui acl fs repl +SUBDIRS = base anyp comm eui acl fs repl +DIST_SUBDIRS = base anyp comm eui acl fs repl if ENABLE_AUTH SUBDIRS += auth AUTH_LIBS= auth/libauth.la AUTH_ACL_LIBS= auth/libacls.la check_PROGRAMS+= tests/testAuth tests/testACLMaxUserIP endif DIST_SUBDIRS += auth SUBDIRS += ip icmp ident log ipc mgr DIST_SUBDIRS += ip icmp ident log ipc mgr if ENABLE_SSL SUBDIRS += ssl SSL_LIBS = \ ssl/libsslutil.la \ ssl/libsslsquid.la else SSL_LOCAL_LIBS = endif @@ -537,40 +537,41 @@ BUILT_SOURCES = \ cf_gen_defines.cci \ cf_parser.cci \ err_type.cc \ err_detail_type.cc \ globals.cc \ hier_code.cc \ icp_opcode.cc \ lookup_t.cc \ repl_modules.cc \ swap_log_op.cc CLEANFILES += $(BUILT_SOURCES) nodist_squid_SOURCES = \ $(DISKIO_GEN_SOURCE) \ $(BUILT_SOURCES) squid_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ comm/libcomm.la \ eui/libeui.la \ icmp/libicmp.la icmp/libicmp-core.la \ log/liblog.la \ $(XTRA_OBJS) \ $(DISK_LINKOBJS) \ $(REPL_OBJS) \ $(DISK_LIBS) \ $(DISK_OS_LIBS) \ $(CRYPTLIB) \ $(REGEXLIB) \ $(ADAPTATION_LIBS) \ $(ESI_LIBS) \ $(SSL_LIBS) \ $(SNMP_LIBS) \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ $(SSLLIB) \ $(EPOLL_LIBS) \ @@ -1293,40 +1294,41 @@ ident/libident.la \ acl/libacls.la \ eui/libeui.la \ acl/libstate.la \ $(AUTH_LIBS) \ acl/libapi.la \ base/libbase.la \ libsquid.la \ ip/libip.la \ fs/libfs.la \ ipc/libipc.la \ mgr/libmgr.la \ $(SNMP_LIBS) \ comm/libcomm.la \ icmp/libicmp.la icmp/libicmp-core.la \ log/liblog.la \ $(REPL_OBJS) \ $(ADAPTATION_LIBS) \ $(ESI_LIBS) \ $(SSL_LIBS) \ + anyp/libanyp.la \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ $(REGEXLIB) \ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(SSLLIB) \ $(KRB5LIBS) \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_testCacheManager_LDFLAGS = $(LIBADD_DL) tests_testCacheManager_DEPENDENCIES = \ $(REPL_OBJS) \ $(SQUID_CPPUNIT_LA) tests_testDiskIO_SOURCES = \ $(SWAP_TEST_SOURCES) \ tests/testDiskIO.cc \ tests/testDiskIO.h \ tests/testMain.cc \ @@ -1496,40 +1498,41 @@ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ $(TEST_CALL_SOURCES) \ tools.cc \ tunnel.cc \ SwapDir.cc \ url.cc \ URLScheme.cc \ urn.cc \ wccp2.cc \ whois.cc \ FadingCounter.cc \ $(WIN32_SOURCE) \ wordlist.cc nodist_tests_testEvent_SOURCES = \ $(BUILT_SOURCES) tests_testEvent_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ comm/libcomm.la \ log/liblog.la \ $(REPL_OBJS) \ $(ADAPTATION_LIBS) \ $(ESI_LIBS) \ $(SSL_LIBS) \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ $(REGEXLIB) \ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(SSLLIB) \ $(KRB5LIBS) \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_testEvent_LDFLAGS = $(LIBADD_DL) tests_testEvent_DEPENDENCIES = \ @@ -1657,40 +1660,41 @@ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ $(TEST_CALL_SOURCES) \ tools.cc \ tunnel.cc \ SwapDir.cc \ url.cc \ URLScheme.cc \ urn.cc \ wccp2.cc \ whois.cc \ FadingCounter.cc \ $(WIN32_SOURCE) \ wordlist.cc nodist_tests_testEventLoop_SOURCES = \ $(BUILT_SOURCES) tests_testEventLoop_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ comm/libcomm.la \ log/liblog.la \ $(REPL_OBJS) \ $(ADAPTATION_LIBS) \ $(ESI_LIBS) \ $(SSL_LIBS) \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ $(REGEXLIB) \ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(SSLLIB) \ $(KRB5LIBS) \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_testEventLoop_LDFLAGS = $(LIBADD_DL) tests_testEventLoop_DEPENDENCIES = \ @@ -1813,40 +1817,41 @@ String.cc \ SwapDir.cc \ $(TEST_CALL_SOURCES) \ time.cc \ tools.cc \ tunnel.cc \ url.cc \ URLScheme.cc \ urn.cc \ wccp2.cc \ whois.cc \ FadingCounter.cc \ $(WIN32_SOURCE) \ wordlist.cc \ Packer.cc \ MemBuf.cc nodist_tests_test_http_range_SOURCES = \ $(BUILT_SOURCES) tests_test_http_range_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ comm/libcomm.la \ log/liblog.la \ $(REPL_OBJS) \ $(ADAPTATION_LIBS) \ $(ESI_LIBS) \ $(SSL_LIBS) \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ $(REGEXLIB) \ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(SSLLIB) \ $(KRB5LIBS) \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_test_http_range_LDFLAGS = $(LIBADD_DL) tests_test_http_range_DEPENDENCIES = \ @@ -1974,40 +1979,41 @@ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ $(TEST_CALL_SOURCES) \ tools.cc \ tunnel.cc \ SwapDir.cc \ url.cc \ URLScheme.cc \ urn.cc \ wccp2.cc \ whois.cc \ FadingCounter.cc \ $(WIN32_SOURCE) \ wordlist.cc nodist_tests_testHttpRequest_SOURCES = \ $(BUILT_SOURCES) tests_testHttpRequest_LDADD = \ $(COMMON_LIBS) \ + anyp/libanyp.la \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ comm/libcomm.la \ log/liblog.la \ $(REPL_OBJS) \ $(ADAPTATION_LIBS) \ $(ESI_LIBS) \ $(SSL_LIBS) \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ $(REGEXLIB) \ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(SSLLIB) \ $(KRB5LIBS) \ $(COMPAT_LIB) \ $(XTRA_LIBS) tests_testHttpRequest_LDFLAGS = $(LIBADD_DL) tests_testHttpRequest_DEPENDENCIES = \ @@ -2388,40 +2394,41 @@ StoreMetaMD5.cc \ StoreMetaSTD.cc \ StoreMetaSTDLFS.cc \ StoreMetaUnpacker.cc \ StoreMetaURL.cc \ StoreMetaVary.cc \ StoreSwapLogData.cc \ $(TEST_CALL_SOURCES) \ tools.cc \ tunnel.cc \ SwapDir.cc \ urn.cc \ wccp2.cc \ whois.cc \ FadingCounter.cc \ $(WIN32_SOURCE) \ wordlist.cc nodist_tests_testURL_SOURCES = \ $(BUILT_SOURCES) tests_testURL_LDADD = \ + anyp/libanyp.la \ $(COMMON_LIBS) \ $(SNMP_LIBS) \ icmp/libicmp.la icmp/libicmp-core.la \ comm/libcomm.la \ log/liblog.la \ $(REGEXLIB) \ $(REPL_OBJS) \ $(ADAPTATION_LIBS) \ $(ESI_LIBS) \ $(SSL_LIBS) \ $(top_builddir)/lib/libmisccontainers.la \ $(top_builddir)/lib/libmiscencoding.la \ $(top_builddir)/lib/libmiscutil.la \ $(COMPAT_LIB) \ $(SQUID_CPPUNIT_LIBS) \ $(SQUID_CPPUNIT_LA) \ $(SSLLIB) \ $(KRB5LIBS) \ $(COMPAT_LIB) \ $(XTRA_LIBS) === modified file 'src/URLScheme.h' --- src/URLScheme.h 2009-01-21 03:47:47 +0000 +++ src/URLScheme.h 2011-02-14 11:30:05 +0000 @@ -32,49 +32,49 @@ */ #ifndef SQUID_URLSCHEME_H #define SQUID_URLSCHEME_H /* For the definition of NULL and protocol_t */ #include "squid.h" #include 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() : theScheme(AnyP::PROTO_NONE) {} - URLScheme(protocol_t const aScheme) : theScheme(aScheme) {} + URLScheme(AnyP::ProtocolType const aScheme) : theScheme(aScheme) {} - operator protocol_t() const { return theScheme; } + operator AnyP::ProtocolType() const { return theScheme; } - bool operator != (protocol_t const & aProtocol) const { return theScheme != aProtocol;} + bool operator != (AnyP::ProtocolType const & aProtocol) const { return theScheme != aProtocol;} /* Get a char string representation of the scheme. */ - char const *const_str() const { return ProtocolStr[theScheme]; } + char const *const_str() const { return AnyP::ProtocolType_str[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; + AnyP::ProtocolType theScheme; }; inline std::ostream & operator << (std::ostream &os, URLScheme const &scheme) { os << scheme.const_str(); return os; } #endif /* SQUID_URLSCHEME_H */ === modified file 'src/acl/Protocol.cc' --- src/acl/Protocol.cc 2009-03-17 02:04:14 +0000 +++ src/acl/Protocol.cc 2011-02-14 09:56:17 +0000 @@ -24,37 +24,37 @@ * 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 "acl/Protocol.h" #include "acl/ProtocolData.h" #include "acl/Checklist.h" #include "HttpRequest.h" /* explicit template instantiation required for some systems */ -template class ACLStrategised; +template class ACLStrategised; int ACLProtocolStrategy::match (ACLData * &data, ACLFilledChecklist *checklist) { - return data->match (checklist->request->protocol); + return data->match(checklist->request->protocol); } ACLProtocolStrategy * ACLProtocolStrategy::Instance() { return &Instance_; } ACLProtocolStrategy ACLProtocolStrategy::Instance_; === modified file 'src/acl/Protocol.h' --- src/acl/Protocol.h 2009-03-08 21:53:27 +0000 +++ src/acl/Protocol.h 2011-02-14 09:56:17 +0000 @@ -18,52 +18,54 @@ * 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 */ #ifndef SQUID_ACLPROTOCOL_H #define SQUID_ACLPROTOCOL_H + #include "acl/Strategy.h" #include "acl/Strategised.h" +#include "anyp/ProtocolType.h" -class ACLProtocolStrategy : public ACLStrategy +class ACLProtocolStrategy : public ACLStrategy { public: virtual int match (ACLData * &, ACLFilledChecklist *); virtual bool requiresRequest() const {return true;} static ACLProtocolStrategy *Instance(); /* Not implemented to prevent copies of the instance. */ /* Not private to prevent brain dead g+++ warnings about * private constructors with no friends */ ACLProtocolStrategy(ACLProtocolStrategy const &); private: static ACLProtocolStrategy Instance_; ACLProtocolStrategy() {} ACLProtocolStrategy&operator=(ACLProtocolStrategy const &); }; class ACLProtocol { private: static ACL::Prototype RegistryProtoype; - static ACLStrategised RegistryEntry_; + static ACLStrategised RegistryEntry_; }; #endif /* SQUID_ACLPROTOCOL_H */ === modified file 'src/acl/ProtocolData.cc' --- src/acl/ProtocolData.cc 2009-03-08 19:34:36 +0000 +++ src/acl/ProtocolData.cc 2011-02-14 11:29:16 +0000 @@ -38,72 +38,77 @@ #include "acl/ProtocolData.h" #include "acl/Checklist.h" #include "URLScheme.h" #include "wordlist.h" ACLProtocolData::ACLProtocolData() : values (NULL) {} ACLProtocolData::ACLProtocolData(ACLProtocolData const &old) : values (NULL) { assert (!old.values); } ACLProtocolData::~ACLProtocolData() { if (values) delete values; } bool -ACLProtocolData::match(protocol_t toFind) +ACLProtocolData::match(AnyP::ProtocolType toFind) { return values->findAndTune (toFind); } /* explicit instantiation required for some systems */ /// \cond AUTODOCS-IGNORE -template cbdata_type CbDataList::CBDATA_CbDataList; +template cbdata_type CbDataList::CBDATA_CbDataList; /// \endcond wordlist * ACLProtocolData::dump() { wordlist *W = NULL; - CbDataList *data = values; + CbDataList *data = values; while (data != NULL) { - wordlistAdd(&W, ProtocolStr[data->element]); + wordlistAdd(&W, AnyP::ProtocolType_str[data->element]); data = data->next; } return W; } void ACLProtocolData::parse() { - CbDataList **Tail; + CbDataList **Tail; char *t = NULL; for (Tail = &values; *Tail; Tail = &((*Tail)->next)); while ((t = strtokFile())) { - CbDataList *q = new CbDataList (urlParseProtocol(t)); - *(Tail) = q; - Tail = &q->next; + for (int p = AnyP::PROTO_NONE; p < AnyP::PROTO_UNKNOWN; ++p) { + if (strcasecmp(t, AnyP::ProtocolType_str[p]) != 0) { + CbDataList *q = new CbDataList(static_cast(p)); + *(Tail) = q; + Tail = &q->next; + break; + } + } } } bool ACLProtocolData::empty() const { return values == NULL; } -ACLData * +ACLData * ACLProtocolData::clone() const { /* Splay trees don't clone yet. */ assert (!values); return new ACLProtocolData(*this); } === modified file 'src/acl/ProtocolData.h' --- src/acl/ProtocolData.h 2009-03-08 19:34:36 +0000 +++ src/acl/ProtocolData.h 2011-02-14 09:56:17 +0000 @@ -18,46 +18,48 @@ * 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 */ #ifndef SQUID_ACLPROTOCOLDATA_H #define SQUID_ACLPROTOCOLDATA_H + #include "acl/Acl.h" #include "acl/Data.h" +#include "anyp/ProtocolType.h" #include "CbDataList.h" -class ACLProtocolData : public ACLData +class ACLProtocolData : public ACLData { public: MEMPROXY_CLASS(ACLProtocolData); ACLProtocolData(); ACLProtocolData(ACLProtocolData const &); ACLProtocolData &operator= (ACLProtocolData const &); virtual ~ACLProtocolData(); - bool match(protocol_t); + bool match(AnyP::ProtocolType); wordlist *dump(); void parse(); bool empty() const; - virtual ACLData *clone() const; + virtual ACLData *clone() const; - CbDataList *values; + CbDataList *values; }; MEMPROXY_CLASS_INLINE(ACLProtocolData); #endif /* SQUID_ACLPROTOCOLDATA_H */ === added directory 'src/anyp' === added file 'src/anyp/Makefile.am' --- src/anyp/Makefile.am 1970-01-01 00:00:00 +0000 +++ src/anyp/Makefile.am 2011-02-14 09:57:21 +0000 @@ -0,0 +1,13 @@ +include $(top_srcdir)/src/Common.am +include $(top_srcdir)/src/TestHeaders.am + +noinst_LTLIBRARIES = libanyp.la + +libanyp_la_SOURCES = \ + ProtocolType.cc \ + ProtocolType.h + +ProtocolType.cc: ProtocolType.h $(top_srcdir)/src/mk-string-arrays.awk + ($(AWK) -f $(top_srcdir)/src/mk-string-arrays.awk <$(srcdir)/ProtocolType.h | sed -e 's%PROTO_%%' >$@) || ($(RM) -f $@ && exit 1) + +CLEANFILES += ProtocolType.cc === added file 'src/anyp/ProtocolType.h' --- src/anyp/ProtocolType.h 1970-01-01 00:00:00 +0000 +++ src/anyp/ProtocolType.h 2011-02-14 11:25:45 +0000 @@ -0,0 +1,48 @@ +#ifndef _SQUID_SRC_ANYP_PROTOCOLTYPE_H +#define _SQUID_SRC_ANYP_PROTOCOLTYPE_H + +#if HAVE_OSTREAM +#include +#endif + +namespace AnyP { + +/** + * List of all protocols known and supported. + * This is a combined list. It is used as type-codes where needed and + * the AnyP::ProtocolType_Str array of strings may be used for display + */ +typedef enum { + PROTO_NONE = 0, + PROTO_HTTP, + PROTO_FTP, + PROTO_HTTPS, + PROTO_GOPHER, + PROTO_WAIS, + PROTO_CACHEOBJ, + PROTO_ICP, +#if USE_HTCP + PROTO_HTCP, +#endif + PROTO_URN, + PROTO_WHOIS, + PROTO_INTERNAL, + PROTO_ICY, + PROTO_UNKNOWN, + PROTO_MAX +} ProtocolType; + +extern const char *ProtocolType_str[]; + +/// Display the Protocol Type (in upper case). +inline std::ostream & +operator <<(std::ostream &os, ProtocolType const &p) +{ + if (p < PROTO_UNKNOWN) + os << ProtocolType_str[p]; + return os; +} + +} // namespace AnyP + +#endif /* _SQUID_SRC_ANYP_PROTOCOLTYPE_H */ === modified file 'src/client_db.cc' --- src/client_db.cc 2010-12-12 12:51:33 +0000 +++ src/client_db.cc 2011-02-14 09:56:17 +0000 @@ -126,66 +126,66 @@ */ ClientInfo * clientdbGetInfo(const Ip::Address &addr) { char key[MAX_IPSTRLEN]; ClientInfo *c; if (!Config.onoff.client_db) return NULL; addr.NtoA(key,MAX_IPSTRLEN); c = (ClientInfo *) hash_lookup(client_table, key); if (c==NULL) { debugs(77,1,"Client db does not contain information for given IP address "<<(const char*)key); return NULL; } return c; } #endif void -clientdbUpdate(const Ip::Address &addr, log_type ltype, protocol_t p, size_t size) +clientdbUpdate(const Ip::Address &addr, log_type ltype, AnyP::ProtocolType p, size_t size) { char key[MAX_IPSTRLEN]; ClientInfo *c; if (!Config.onoff.client_db) return; addr.NtoA(key,MAX_IPSTRLEN); c = (ClientInfo *) hash_lookup(client_table, key); if (c == NULL) c = clientdbAdd(addr); if (c == NULL) debug_trap("clientdbUpdate: Failed to add entry"); - if (p == PROTO_HTTP) { + if (p == AnyP::PROTO_HTTP) { c->Http.n_requests++; c->Http.result_hist[ltype]++; kb_incr(&c->Http.kbytes_out, size); if (logTypeIsATcpHit(ltype)) kb_incr(&c->Http.hit_kbytes_out, size); - } else if (p == PROTO_ICP) { + } else if (p == AnyP::PROTO_ICP) { c->Icp.n_requests++; c->Icp.result_hist[ltype]++; kb_incr(&c->Icp.kbytes_out, size); if (LOG_UDP_HIT == ltype) kb_incr(&c->Icp.hit_kbytes_out, size); } c->last_seen = squid_curtime; } /** * This function tracks the number of currently established connections * for a client IP address. When a connection is accepted, call this * with delta = 1. When the connection is closed, call with delta = * -1. To get the current value, simply call with delta = 0. */ int clientdbEstablished(const Ip::Address &addr, int delta) { === modified file 'src/client_side.cc' --- src/client_side.cc 2011-02-24 10:18:58 +0000 +++ src/client_side.cc 2011-02-25 09:16:25 +0000 @@ -662,41 +662,41 @@ /* This is broken. Fails if the connection has been closed. Needs * to snarf the ssl details some place earlier.. */ if (getConn() != NULL) al.cache.ssluser = sslGetUserEmail(fd_table[getConn()->fd].ssl); #endif ACLFilledChecklist *checklist = clientAclChecklistCreate(Config.accessList.log, this); if (al.reply) checklist->reply = HTTPMSGLOCK(al.reply); if (!Config.accessList.log || checklist->fastCheck()) { if (request) al.adapted_request = HTTPMSGLOCK(request); accessLogLog(&al, checklist); updateCounters(); if (getConn() != NULL) - clientdbUpdate(getConn()->peer, logType, PROTO_HTTP, out.size); + clientdbUpdate(getConn()->peer, logType, AnyP::PROTO_HTTP, out.size); } delete checklist; } accessLogFreeMemory(&al); } void ClientHttpRequest::freeResources() { safe_free(uri); safe_free(log_uri); safe_free(redirect.location); range_iter.boundary.clean(); HTTPMSGUNLOCK(request); if (client_stream.tail) clientStreamAbort((clientStreamNode *)client_stream.tail->data, this); } @@ -2468,41 +2468,41 @@ */ if (Ip::Interceptor.InterceptActive()) { request->flags.intercepted = http->flags.intercepted; } if (Ip::Interceptor.TransparentActive()) { request->flags.spoof_client_ip = conn->port->spoof_client_ip; } if (internalCheck(request->urlpath.termedBuf())) { if (internalHostnameIs(request->GetHost()) && request->port == getMyPort()) { http->flags.internal = 1; } else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.termedBuf())) { request->SetHost(internalHostname()); request->port = getMyPort(); http->flags.internal = 1; } } if (http->flags.internal) { - request->protocol = PROTO_HTTP; + request->protocol = AnyP::PROTO_HTTP; request->login[0] = '\0'; } request->flags.internal = http->flags.internal; setLogUri (http, urlCanonicalClean(request)); request->client_addr = conn->peer; #if USE_SQUID_EUI request->client_eui48 = conn->peer_eui48; request->client_eui64 = conn->peer_eui64; #endif #if FOLLOW_X_FORWARDED_FOR request->indirect_client_addr = conn->peer; #endif /* FOLLOW_X_FORWARDED_FOR */ request->my_addr = conn->me; request->myportname = conn->port->name; request->http_ver = http_ver; if (request->header.chunked()) { chunked = true; } else if (request->header.has(HDR_TRANSFER_ENCODING)) { === modified file 'src/client_side_reply.cc' --- src/client_side_reply.cc 2011-02-18 09:57:53 +0000 +++ src/client_side_reply.cc 2011-02-18 13:51:45 +0000 @@ -534,41 +534,41 @@ * then we should probably only use parents for the validation * request. Otherwise two siblings could generate a loop if * both have a stale version of the object. */ r->flags.need_validation = 1; if (e->lastmod < 0) { /* * Previous reply didn't have a Last-Modified header, * we cannot revalidate it. */ http->logType = LOG_TCP_MISS; processMiss(); } else if (r->flags.nocache) { /* * This did not match a refresh pattern that overrides no-cache * we should honour the client no-cache header. */ http->logType = LOG_TCP_CLIENT_REFRESH_MISS; processMiss(); - } else if (r->protocol == PROTO_HTTP) { + } else if (r->protocol == AnyP::PROTO_HTTP) { /* * Object needs to be revalidated * XXX This could apply to FTP as well, if Last-Modified is known. */ processExpired(); } else { /* * We don't know how to re-validate other protocols. Handle * them as if the object has expired. */ http->logType = LOG_TCP_MISS; processMiss(); } } else if (r->conditional()) processConditional(result); else { /* * plain ol' cache hit */ @@ -641,41 +641,41 @@ assert(http->out.offset == 0); createStoreEntry(r->method, r->flags); triggerInitialStoreRead(); if (http->redirect.status) { HttpReply *rep = new HttpReply; #if LOG_TCP_REDIRECTS http->logType = LOG_TCP_REDIRECT; #endif http->storeEntry()->releaseRequest(); rep->redirect(http->redirect.status, http->redirect.location); http->storeEntry()->replaceHttpReply(rep); http->storeEntry()->complete(); return; } /** Check for internal requests. Update Protocol info if so. */ if (http->flags.internal) - r->protocol = PROTO_INTERNAL; + r->protocol = AnyP::PROTO_INTERNAL; r->clientConnection = http->getConn(); /** Start forwarding to get the new object from network */ FwdState::fwdStart(http->getConn() != NULL ? http->getConn()->fd : -1, http->storeEntry(), r); } } /** * client issued a request with an only-if-cached cache-control directive; * we did not find a cached object that can be returned without * contacting other servers; * respond with a 504 (Gateway Timeout) as suggested in [RFC 2068] */ void clientReplyContext::processOnlyIfCachedMiss() { ErrorState *err = NULL; @@ -1487,41 +1487,41 @@ if ( hdr->has(HDR_SURROGATE_CONTROL) ) { if (!request->header.has(HDR_SURROGATE_CAPABILITY)) { hdr->delById(HDR_SURROGATE_CONTROL); } /* TODO: else case: drop any controls intended specifically for our surrogate ID */ } httpHdrMangleList(hdr, request, ROR_REPLY); } void clientReplyContext::cloneReply() { assert(reply == NULL); HttpReply *rep = http->storeEntry()->getReply()->clone(); reply = HTTPMSGLOCK(rep); - if (reply->sline.protocol == PROTO_HTTP) { + if (reply->sline.protocol == AnyP::PROTO_HTTP) { /* RFC 2616 requires us to advertise our 1.1 version (but only on real HTTP traffic) */ reply->sline.version = HttpVersion(1,1); } /* do header conversions */ buildReplyHeader(); } void clientReplyContext::identifyStoreObject() { HttpRequest *r = http->request; if (r->flags.cachable || r->flags.internal) { lookingforstore = 5; StoreEntry::getPublicByRequest (this, r); } else { identifyFoundObject (NullStoreEntry::getInstance()); } } @@ -2131,41 +2131,41 @@ holdingBuffer = result; processReplyAccess(); return; } /* Using this breaks the client layering just a little! */ void clientReplyContext::createStoreEntry(const HttpRequestMethod& m, request_flags reqFlags) { assert(http != NULL); /* * For erroneous requests, we might not have a h->request, * so make a fake one. */ if (http->request == NULL) - http->request = HTTPMSGLOCK(new HttpRequest(m, PROTO_NONE, null_string)); + http->request = HTTPMSGLOCK(new HttpRequest(m, AnyP::PROTO_NONE, null_string)); StoreEntry *e = storeCreateEntry(http->uri, http->log_uri, reqFlags, m); sc = storeClientListAdd(e, this); #if USE_DELAY_POOLS sc->setDelayId(DelayId::DelayClient(http)); #endif reqofs = 0; reqsize = 0; /* I don't think this is actually needed! -- adrian */ /* http->reqbuf = http->norm_reqbuf; */ // assert(http->reqbuf == http->norm_reqbuf); /* The next line is illegal because we don't know if the client stream * buffers have been set up */ // storeClientCopy(http->sc, e, 0, HTTP_REQBUF_SZ, http->reqbuf, === modified file 'src/client_side_request.cc' --- src/client_side_request.cc 2011-02-07 10:27:53 +0000 +++ src/client_side_request.cc 2011-02-14 09:56:17 +0000 @@ -746,53 +746,52 @@ * This is incorrect: authenticating requests can be sent via a hierarchy * (they can even be cached if the correct headers are set on the reply) */ if (request->flags.auth) return 0; if (method == METHOD_TRACE) return 1; if (method != METHOD_GET) return 0; /* scan hierarchy_stoplist */ for (p = Config.hierarchy_stoplist; p; p = p->next) if (strstr(url, p->key)) return 0; if (request->flags.loopdetect) return 0; - if (request->protocol == PROTO_HTTP) + else if (request->protocol == AnyP::PROTO_HTTP) return httpCachable(method); - if (request->protocol == PROTO_GOPHER) + else if (request->protocol == AnyP::PROTO_GOPHER) return gopherCachable(request); - if (request->protocol == PROTO_CACHEOBJ) + else if (request->protocol == AnyP::PROTO_CACHEOBJ) return 0; return 1; } - static void clientCheckPinning(ClientHttpRequest * http) { HttpRequest *request = http->request; HttpHeader *req_hdr = &request->header; ConnStateData *http_conn = http->getConn(); /* Internal requests such as those from ESI includes may be without * a client connection */ if (!http_conn) return; request->flags.connection_auth_disabled = http_conn->port->connection_auth_disabled; if (!request->flags.connection_auth_disabled) { if (http_conn->pinning.fd != -1) { if (http_conn->pinning.auth) { request->flags.connection_auth = 1; request->flags.auth = 1; } else { === modified file 'src/enums.h' --- src/enums.h 2011-01-28 07:58:53 +0000 +++ src/enums.h 2011-02-14 09:56:17 +0000 @@ -126,59 +126,40 @@ PING_DONE } ping_status_t; typedef enum { STORE_OK, STORE_PENDING } store_status_t; typedef enum { SWAPOUT_NONE, SWAPOUT_WRITING, SWAPOUT_DONE } swap_status_t; typedef enum { STORE_NON_CLIENT, STORE_MEM_CLIENT, STORE_DISK_CLIENT } store_client_t; -typedef enum { - PROTO_NONE, - PROTO_HTTP, - PROTO_FTP, - PROTO_GOPHER, - PROTO_WAIS, - PROTO_CACHEOBJ, - PROTO_ICP, -#if USE_HTCP - PROTO_HTCP, -#endif - PROTO_URN, - PROTO_WHOIS, - PROTO_INTERNAL, - PROTO_HTTPS, - PROTO_ICY, - PROTO_MAX -} protocol_t; - /* * These are for StoreEntry->flag, which is defined as a SHORT * * NOTE: These flags are written to swap.state, so think very carefully * about deleting or re-assigning! */ enum { ENTRY_SPECIAL, ENTRY_REVALIDATE, DELAY_SENDING, RELEASE_REQUEST, REFRESH_REQUEST, ENTRY_CACHABLE, ENTRY_DISPATCHED, KEY_PRIVATE, ENTRY_FWD_HDR_WAIT, ENTRY_NEGCACHED, ENTRY_VALIDATED, ENTRY_BAD_LENGTH, ENTRY_ABORTED === modified file 'src/errorpage.cc' --- src/errorpage.cc 2011-02-07 10:27:53 +0000 +++ src/errorpage.cc 2011-02-14 11:37:40 +0000 @@ -791,41 +791,41 @@ else if (!building_deny_info_url) p= "[unknown method]"; break; case 'o': p = request ? request->extacl_message.termedBuf() : external_acl_message; if (!p && !building_deny_info_url) p = "[not available]"; break; case 'p': if (request) { mb.Printf("%d", (int) request->port); } else if (!building_deny_info_url) { p = "[unknown port]"; } break; case 'P': if (request) { - p = ProtocolStr[request->protocol]; + p = AnyP::ProtocolType_str[request->protocol]; } else if (!building_deny_info_url) { p = "[unknown protocol]"; } break; case 'R': if (building_deny_info_url) { p = (request->urlpath.size() != 0 ? request->urlpath.termedBuf() : "/"); break; } if (NULL != request) { Packer pck; String urlpath_or_slash; if (request->urlpath.size() != 0) urlpath_or_slash = request->urlpath; else urlpath_or_slash = "/"; mb.Printf("%s " SQUIDSTRINGPH " HTTP/%d.%d\n", === modified file 'src/external_acl.cc' --- src/external_acl.cc 2011-02-16 01:12:34 +0000 +++ src/external_acl.cc 2011-02-16 10:49:56 +0000 @@ -937,41 +937,41 @@ #endif case _external_acl_format::EXT_ACL_MYADDR: str = request->my_addr.NtoA(buf, sizeof(buf)); break; case _external_acl_format::EXT_ACL_MYPORT: snprintf(buf, sizeof(buf), "%d", request->my_addr.GetPort()); str = buf; break; case _external_acl_format::EXT_ACL_URI: str = urlCanonical(request); break; case _external_acl_format::EXT_ACL_DST: str = request->GetHost(); break; case _external_acl_format::EXT_ACL_PROTO: - str = ProtocolStr[request->protocol]; + str = AnyP::ProtocolType_str[request->protocol]; break; case _external_acl_format::EXT_ACL_PORT: snprintf(buf, sizeof(buf), "%d", request->port); str = buf; break; case _external_acl_format::EXT_ACL_PATH: str = request->urlpath.termedBuf(); break; case _external_acl_format::EXT_ACL_METHOD: str = RequestMethodStr(request->method); break; case _external_acl_format::EXT_ACL_HEADER_REQUEST: sb = request->header.getByName(format->header); str = sb.termedBuf(); break; === modified file 'src/forward.cc' --- src/forward.cc 2011-01-10 09:43:43 +0000 +++ src/forward.cc 2011-02-14 09:56:17 +0000 @@ -186,41 +186,41 @@ } debugs(17, 3, HERE << "FwdState destructor done"); } /** * This is the entry point for client-side to start forwarding * a transaction. It is a static method that may or may not * allocate a FwdState. */ void FwdState::fwdStart(int client_fd, StoreEntry *entry, HttpRequest *request) { /** \note * client_addr == no_addr indicates this is an "internal" request * from peer_digest.c, asn.c, netdb.c, etc and should always * be allowed. yuck, I know. */ if ( Config.accessList.miss && !request->client_addr.IsNoAddr() && - request->protocol != PROTO_INTERNAL && request->protocol != PROTO_CACHEOBJ) { + request->protocol != AnyP::PROTO_INTERNAL && request->protocol != AnyP::PROTO_CACHEOBJ) { /** * Check if this host is allowed to fetch MISSES from us (miss_access) */ ACLFilledChecklist ch(Config.accessList.miss, request, NULL); ch.src_addr = request->client_addr; ch.my_addr = request->my_addr; int answer = ch.fastCheck(); if (answer == 0) { err_type page_id; page_id = aclGetDenyInfoPage(&Config.denyInfoList, AclMatchedName, 1); if (page_id == ERR_NONE) page_id = ERR_FORWARDING_DENIED; ErrorState *anErr = errorCon(page_id, HTTP_FORBIDDEN, request); errorAppendEntry(entry, anErr); // frees anErr return; @@ -230,49 +230,49 @@ debugs(17, 3, "FwdState::start() '" << entry->url() << "'"); /* * This seems like an odd place to bind mem_obj and request. * Might want to assert that request is NULL at this point */ entry->mem_obj->request = HTTPMSGLOCK(request); #if URL_CHECKSUM_DEBUG entry->mem_obj->checkUrlChecksum(); #endif if (shutting_down) { /* more yuck */ ErrorState *anErr = errorCon(ERR_SHUTTING_DOWN, HTTP_SERVICE_UNAVAILABLE, request); errorAppendEntry(entry, anErr); // frees anErr return; } switch (request->protocol) { - case PROTO_INTERNAL: + case AnyP::PROTO_INTERNAL: internalStart(request, entry); return; - case PROTO_CACHEOBJ: + case AnyP::PROTO_CACHEOBJ: CacheManager::GetInstance()->Start(client_fd, request, entry); return; - case PROTO_URN: + case AnyP::PROTO_URN: urnStart(request, entry); return; default: FwdState::Pointer fwd = new FwdState(client_fd, entry, request); /* If we need to transparently proxy the request * then we need the client source protocol, address and port */ if (request->flags.spoof_client_ip) { fwd->src = request->client_addr; } fwd->start(fwd); return; } /* NOTREACHED */ } void @@ -735,41 +735,41 @@ } else if (status != COMM_OK) { assert(fs); ErrorState *const anErr = makeConnectingError(ERR_CONNECT_FAIL); anErr->xerrno = xerrno; fail(anErr); if (fs->_peer) peerConnectFailed(fs->_peer); comm_close(server_fd); } else { debugs(17, 3, "fwdConnectDone: FD " << server_fd << ": '" << entry->url() << "'" ); if (fs->_peer) peerConnectSucceded(fs->_peer); #if USE_SSL if ((fs->_peer && fs->_peer->use_ssl) || - (!fs->_peer && request->protocol == PROTO_HTTPS)) { + (!fs->_peer && request->protocol == AnyP::PROTO_HTTPS)) { initiateSSL(); return; } #endif dispatch(); } } void FwdState::connectTimeout(int fd) { FwdServer *fs = servers; debugs(17, 2, "fwdConnectTimeout: FD " << fd << ": '" << entry->url() << "'" ); assert(fd == server_fd); if (Config.onoff.log_ip_on_direct && fs->code == HIER_DIRECT && fd_table[fd].ipaddr[0]) updateHierarchyInfo(); @@ -1052,70 +1052,70 @@ fde * clientFde = &fd_table[client_fd]; if (clientFde) { /* Get the TOS value for the packet */ Ip::Qos::getTosFromServer(server_fd, clientFde); } } #endif if (servers && (p = servers->_peer)) { p->stats.fetches++; request->peer_login = p->login; request->peer_domain = p->domain; httpStart(this); } else { request->peer_login = NULL; request->peer_domain = NULL; switch (request->protocol) { #if USE_SSL - case PROTO_HTTPS: + case AnyP::PROTO_HTTPS: httpStart(this); break; #endif - case PROTO_HTTP: + case AnyP::PROTO_HTTP: httpStart(this); break; - case PROTO_GOPHER: + case AnyP::PROTO_GOPHER: gopherStart(this); break; - case PROTO_FTP: + case AnyP::PROTO_FTP: ftpStart(this); break; - case PROTO_CACHEOBJ: + case AnyP::PROTO_CACHEOBJ: - case PROTO_INTERNAL: + case AnyP::PROTO_INTERNAL: - case PROTO_URN: + case AnyP::PROTO_URN: fatal_dump("Should never get here"); break; - case PROTO_WHOIS: + case AnyP::PROTO_WHOIS: whoisStart(this); break; - case PROTO_WAIS: /* Not implemented */ + case AnyP::PROTO_WAIS: /* Not implemented */ default: debugs(17, 1, "fwdDispatch: Cannot retrieve '" << entry->url() << "'" ); ErrorState *anErr = errorCon(ERR_UNSUP_REQ, HTTP_BAD_REQUEST, request); fail(anErr); /* * Force a persistent connection to be closed because * some Netscape browsers have a bug that sends CONNECT * requests as GET's over persistent connections. */ request->flags.proxy_keepalive = 0; /* * Set the dont_retry flag becuase this is not a * transient (network) error; its a bug. */ flags.dont_retry = 1; comm_close(server_fd); break; } } === modified file 'src/ftp.cc' --- src/ftp.cc 2011-01-26 03:47:13 +0000 +++ src/ftp.cc 2011-02-14 10:49:39 +0000 @@ -1454,63 +1454,63 @@ if (l == 1) flags.root_dir = 1; } else { flags.dir_slash = 1; } } void FtpStateData::buildTitleUrl() { title_url = "ftp://"; if (strcmp(user, "anonymous")) { title_url.append(user); title_url.append("@"); } title_url.append(request->GetHost()); - if (request->port != urlDefaultPort(PROTO_FTP)) { + if (request->port != urlDefaultPort(AnyP::PROTO_FTP)) { title_url.append(":"); title_url.append(xitoa(request->port)); } title_url.append (request->urlpath); base_href = "ftp://"; if (strcmp(user, "anonymous") != 0) { base_href.append(rfc1738_escape_part(user)); if (password_url) { base_href.append (":"); base_href.append(rfc1738_escape_part(password)); } base_href.append("@"); } base_href.append(request->GetHost()); - if (request->port != urlDefaultPort(PROTO_FTP)) { + if (request->port != urlDefaultPort(AnyP::PROTO_FTP)) { base_href.append(":"); base_href.append(xitoa(request->port)); } base_href.append(request->urlpath); base_href.append("/"); } /// \ingroup ServerProtocolFTPAPI void ftpStart(FwdState * fwd) { FtpStateData *ftpState = new FtpStateData(fwd); ftpState->start(); } void FtpStateData::start() { if (!checkAuth(&request->header)) { @@ -3756,41 +3756,41 @@ return newrep; } /** \ingroup ServerProtocolFTPAPI \todo Should be a URL class API call. * * Construct an URI with leading / in PATH portion for use by CWD command * possibly others. FTP encodes absolute paths as beginning with '/' * after the initial URI path delimiter, which happens to be / itself. * This makes FTP absolute URI appear as: ftp:host:port//root/path * To encompass older software which compacts multiple // to / in transit * We use standard URI-encoding on the second / making it * ftp:host:port/%2froot/path AKA 'the FTP %2f hack'. */ const char * ftpUrlWith2f(HttpRequest * request) { String newbuf = "%2f"; - if (request->protocol != PROTO_FTP) + if (request->protocol != AnyP::PROTO_FTP) return NULL; if ( request->urlpath[0]=='/' ) { newbuf.append(request->urlpath); request->urlpath.absorb(newbuf); safe_free(request->canonical); } else if ( !strncmp(request->urlpath.termedBuf(), "%2f", 3) ) { newbuf.append(request->urlpath.substr(1,request->urlpath.size())); request->urlpath.absorb(newbuf); safe_free(request->canonical); } return urlCanonical(request); } void FtpStateData::printfReplyBody(const char *fmt, ...) { va_list args; va_start (args, fmt); === modified file 'src/http.cc' --- src/http.cc 2011-02-07 10:27:53 +0000 +++ src/http.cc 2011-02-14 09:56:17 +0000 @@ -700,48 +700,48 @@ ctx_exit(ctx); return; } if (!parsed) { // need more data assert(!error); assert(!eof); delete newrep; ctx_exit(ctx); return; } debugs(11, 9, "GOT HTTP REPLY HDR:\n---------\n" << readBuf->content() << "\n----------"); header_bytes_read = headersEnd(readBuf->content(), readBuf->contentSize()); readBuf->consume(header_bytes_read); } newrep->removeStaleWarnings(); - if (newrep->sline.protocol == PROTO_HTTP && newrep->sline.status >= 100 && newrep->sline.status < 200) { + if (newrep->sline.protocol == AnyP::PROTO_HTTP && newrep->sline.status >= 100 && newrep->sline.status < 200) { handle1xx(newrep); ctx_exit(ctx); return; } flags.chunked = 0; - if (newrep->sline.protocol == PROTO_HTTP && newrep->header.chunked()) { + if (newrep->sline.protocol == AnyP::PROTO_HTTP && newrep->header.chunked()) { flags.chunked = 1; httpChunkDecoder = new ChunkedCodingParser; } if (!peerSupportsConnectionPinning()) orig_request->flags.connection_auth_disabled = 1; HttpReply *vrep = setVirginReply(newrep); flags.headers_parsed = 1; keepaliveAccounting(vrep); checkDateSkew(vrep); processSurrogateControl (vrep); /** \todo IF the reply is a 1.0 reply, AND it has a Connection: Header * Parse the header and remove all referenced headers */ @@ -1799,41 +1799,41 @@ if (request->urlpath.size()) assert(strstr(url, request->urlpath.termedBuf())); } /* Enforce sibling relations */ if (flags.only_if_cached) EBIT_SET(cc->mask, CC_ONLY_IF_CACHED); hdr_out->putCc(cc); httpHdrCcDestroy(cc); } /* maybe append Connection: keep-alive */ if (flags.keepalive) { hdr_out->putStr(HDR_CONNECTION, "keep-alive"); } /* append Front-End-Https */ if (flags.front_end_https) { - if (flags.front_end_https == 1 || request->protocol == PROTO_HTTPS) + if (flags.front_end_https == 1 || request->protocol == AnyP::PROTO_HTTPS) hdr_out->putStr(HDR_FRONT_END_HTTPS, "On"); } if (flags.chunked_request) { // Do not just copy the original value so that if the client-side // starts decode other encodings, this code may remain valid. hdr_out->putStr(HDR_TRANSFER_ENCODING, "chunked"); } /* Now mangle the headers. */ if (Config2.onoff.mangle_request_headers) httpHdrMangleList(hdr_out, request, ROR_REQUEST); strConnection.clean(); } /** * Decides whether a particular header may be cloned from the received Clients request * to our outgoing fetch request. */ === modified file 'src/icp_v2.cc' --- src/icp_v2.cc 2011-01-10 09:43:43 +0000 +++ src/icp_v2.cc 2011-02-14 09:56:17 +0000 @@ -197,41 +197,41 @@ } icpCreateAndSend(codeToSend, flags, url, header.reqnum, src_rtt, fd, from); delete this; } /* End ICP2State */ /// \ingroup ServerProtocolICPInternal2 static void icpLogIcp(const Ip::Address &caddr, log_type logcode, int len, const char *url, int delay) { AccessLogEntry al; if (LOG_TAG_NONE == logcode) return; if (LOG_ICP_QUERY == logcode) return; - clientdbUpdate(caddr, logcode, PROTO_ICP, len); + clientdbUpdate(caddr, logcode, AnyP::PROTO_ICP, len); if (!Config.onoff.log_udp) return; al.icp.opcode = ICP_QUERY; al.url = url; al.cache.caddr = caddr; al.cache.replySize = len; al.cache.code = logcode; al.cache.msec = delay; accessLogLog(&al, NULL); } /// \ingroup ServerProtocolICPInternal2 @@ -408,41 +408,41 @@ return LOG_UDP_INVALID; } void icpCreateAndSend(icp_opcode opcode, int flags, char const *url, int reqnum, int pad, int fd, const Ip::Address &from) { icp_common_t *reply = _icp_common_t::createMessage(opcode, flags, url, reqnum, pad); icpUdpSend(fd, from, reply, icpLogFromICPCode(opcode), 0); } void icpDenyAccess(Ip::Address &from, char *url, int reqnum, int fd) { debugs(12, 2, "icpDenyAccess: Access Denied for " << from << " by " << AclMatchedName << "."); if (clientdbCutoffDenied(from)) { /* * count this DENIED query in the clientdb, even though * we're not sending an ICP reply... */ - clientdbUpdate(from, LOG_UDP_DENIED, PROTO_ICP, 0); + clientdbUpdate(from, LOG_UDP_DENIED, AnyP::PROTO_ICP, 0); } else { icpCreateAndSend(ICP_DENIED, 0, url, reqnum, 0, fd, from); } } int icpAccessAllowed(Ip::Address &from, HttpRequest * icp_request) { /* absent an explicit allow, we deny all */ if (!Config.accessList.icp) return 0; ACLFilledChecklist checklist(Config.accessList.icp, icp_request, NULL); checklist.src_addr = from; checklist.my_addr.SetNoAddr(); int result = checklist.fastCheck(); return result; } char const * === modified file 'src/internal.cc' --- src/internal.cc 2010-07-25 08:10:12 +0000 +++ src/internal.cc 2011-02-14 10:51:47 +0000 @@ -108,41 +108,41 @@ } /* * append the domain in order to mirror the requests with appended * domains */ /* For IPv6 addresses also check for a colon */ if (Config.appendDomain && !strchr(lc_host, '.') && !strchr(lc_host, ':')) strncat(lc_host, Config.appendDomain, SQUIDHOSTNAMELEN - strlen(lc_host) - 1); /* build uri in mb */ static MemBuf mb; mb.reset(); mb.Printf("http://%s", lc_host); /* append port if not default */ - if (port && port != urlDefaultPort(PROTO_HTTP)) + if (port && port != urlDefaultPort(AnyP::PROTO_HTTP)) mb.Printf(":%d", port); if (dir) mb.Printf("%s", dir); mb.Printf("%s", name); /* return a pointer to a local static buffer */ return mb.buf; } /* * makes internal url with local host and port */ char * internalLocalUri(const char *dir, const char *name) { return internalRemoteUri(getMyHostname(), getMyPort(), dir, name); } === modified file 'src/neighbors.cc' --- src/neighbors.cc 2011-02-11 11:48:28 +0000 +++ src/neighbors.cc 2011-02-14 09:56:17 +0000 @@ -1076,80 +1076,80 @@ } if (entry->lock_count == 0) { debugs(12, 1, "neighborsUdpAck: '" << storeKeyText(key) << "' has no locks"); neighborCountIgnored(p); return; } debugs(15, 3, "neighborsUdpAck: " << opcode_d << " for '" << storeKeyText(key) << "' from " << (p ? p->host : "source") << " "); if (p) { ntype = neighborType(p, mem->request); } if (ignoreMulticastReply(p, mem)) { neighborCountIgnored(p); } else if (opcode == ICP_MISS) { if (p == NULL) { neighborIgnoreNonPeer(from, opcode); } else { - mem->ping_reply_callback(p, ntype, PROTO_ICP, header, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data); } } else if (opcode == ICP_HIT) { if (p == NULL) { neighborIgnoreNonPeer(from, opcode); } else { header->opcode = ICP_HIT; - mem->ping_reply_callback(p, ntype, PROTO_ICP, header, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data); } } else if (opcode == ICP_DECHO) { if (p == NULL) { neighborIgnoreNonPeer(from, opcode); } else if (ntype == PEER_SIBLING) { debug_trap("neighborsUdpAck: Found non-ICP cache as SIBLING\n"); debug_trap("neighborsUdpAck: non-ICP neighbors must be a PARENT\n"); } else { - mem->ping_reply_callback(p, ntype, PROTO_ICP, header, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data); } } else if (opcode == ICP_SECHO) { if (p) { debugs(15, 1, "Ignoring SECHO from neighbor " << p->host); neighborCountIgnored(p); } else { debugs(15, 1, "Unsolicited SECHO from " << from); } } else if (opcode == ICP_DENIED) { if (p == NULL) { neighborIgnoreNonPeer(from, opcode); } else if (p->stats.pings_acked > 100) { if (100 * p->icp.counts[ICP_DENIED] / p->stats.pings_acked > 95) { debugs(15, 0, "95%% of replies from '" << p->host << "' are UDP_DENIED"); debugs(15, 0, "Disabling '" << p->host << "', please check your configuration."); neighborRemove(p); p = NULL; } else { neighborCountIgnored(p); } } } else if (opcode == ICP_MISS_NOFETCH) { - mem->ping_reply_callback(p, ntype, PROTO_ICP, header, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_ICP, header, mem->ircb_data); } else { debugs(15, 0, "neighborsUdpAck: Unexpected ICP reply: " << opcode_d); } } peer * peerFindByName(const char *name) { peer *p = NULL; for (p = Config.peers; p; p = p->next) { if (!strcasecmp(name, p->name)) break; } return p; } peer * peerFindByNameAndPort(const char *name, unsigned short port) @@ -1506,49 +1506,49 @@ peer *p = (peer *)psstate->callback_data; p->mcast.flags.counting = 0; p->mcast.avg_n_members = Math::doubleAverage(p->mcast.avg_n_members, (double) psstate->ping.n_recv, ++p->mcast.n_times_counted, 10); debugs(15, 1, "Group " << p->host << ": " << psstate->ping.n_recv << " replies, "<< std::setw(4)<< std::setprecision(2) << p->mcast.avg_n_members <<" average, RTT " << p->stats.rtt); p->mcast.n_replies_expected = (int) p->mcast.avg_n_members; } cbdataReferenceDone(psstate->callback_data); EBIT_SET(fake->flags, ENTRY_ABORTED); HTTPMSGUNLOCK(fake->mem_obj->request); fake->releaseRequest(); fake->unlock(); HTTPMSGUNLOCK(psstate->request); cbdataFree(psstate); } static void -peerCountHandleIcpReply(peer * p, peer_t type, protocol_t proto, void *hdrnotused, void *data) +peerCountHandleIcpReply(peer * p, peer_t type, AnyP::ProtocolType proto, void *hdrnotused, void *data) { int rtt_av_factor; ps_state *psstate = (ps_state *)data; StoreEntry *fake = psstate->entry; MemObject *mem = fake->mem_obj; int rtt = tvSubMsec(mem->start_ping, current_time); - assert(proto == PROTO_ICP); + assert(proto == AnyP::PROTO_ICP); assert(fake); assert(mem); psstate->ping.n_recv++; rtt_av_factor = RTT_AV_FACTOR; if (p->options.weighted_roundrobin) rtt_av_factor = RTT_BACKGROUND_AV_FACTOR; p->stats.rtt = Math::intAverage(p->stats.rtt, rtt, psstate->ping.n_recv, rtt_av_factor); } static void neighborDumpPeers(StoreEntry * sentry) { dump_peers(sentry, Config.peers); } static void neighborDumpNonPeers(StoreEntry * sentry) { @@ -1821,41 +1821,41 @@ return; } if (e->lock_count == 0) { debugs(12, 1, "neighborsUdpAck: '" << storeKeyText(key) << "' has no locks"); neighborCountIgnored(p); return; } if (p) { ntype = neighborType(p, mem->request); neighborUpdateRtt(p, mem); } if (ignoreMulticastReply(p, mem)) { neighborCountIgnored(p); return; } debugs(15, 3, "neighborsHtcpReply: e = " << e); - mem->ping_reply_callback(p, ntype, PROTO_HTCP, htcp, mem->ircb_data); + mem->ping_reply_callback(p, ntype, AnyP::PROTO_HTCP, htcp, mem->ircb_data); } /* * Send HTCP CLR messages to all peers configured to receive them. */ void neighborsHtcpClear(StoreEntry * e, const char *uri, HttpRequest * req, const HttpRequestMethod &method, htcp_clr_reason reason) { peer *p; char buf[128]; for (p = Config.peers; p; p = p->next) { if (!p->options.htcp) { continue; } if (p->options.htcp_no_clr) { continue; } if (p->options.htcp_no_purge_clr && reason == HTCP_CLR_PURGE) { continue; === modified file 'src/peer_select.cc' --- src/peer_select.cc 2011-02-07 10:27:53 +0000 +++ src/peer_select.cc 2011-02-14 09:56:17 +0000 @@ -480,41 +480,41 @@ if (p && code != HIER_NONE) { debugs(44, 3, "peerSelect: " << hier_code_str[code] << "/" << p->host); peerAddFwdServer(&ps->servers, p, code); } } /* * peerGetSomeDirect * * Simply adds a 'direct' entry to the FwdServers list if this * request can be forwarded directly to the origin server */ static void peerGetSomeDirect(ps_state * ps) { if (ps->direct == DIRECT_NO) return; /* WAIS is not implemented natively */ - if (ps->request->protocol == PROTO_WAIS) + if (ps->request->protocol == AnyP::PROTO_WAIS) return; peerAddFwdServer(&ps->servers, NULL, HIER_DIRECT); } static void peerGetSomeParent(ps_state * ps) { peer *p; HttpRequest *request = ps->request; hier_code code = HIER_NONE; debugs(44, 3, "peerGetSomeParent: " << RequestMethodStr(request->method) << " " << request->GetHost()); if (ps->direct == DIRECT_YES) return; if ((p = getDefaultParent(request))) { code = DEFAULT_PARENT; #if USE_AUTH } else if ((p = peerUserHashSelectParent(request))) { @@ -728,54 +728,54 @@ return; /* set FIRST_MISS if there is no CLOSEST parent */ if (!ps->closest_parent_miss.IsAnyAddr()) return; rtt = (tvSubMsec(ps->ping.start, current_time) - p->basetime) / p->weight; if (rtt < 1) rtt = 1; if (ps->first_parent_miss.IsAnyAddr() || rtt < ps->ping.w_rtt) { ps->first_parent_miss = p->in_addr; ps->ping.w_rtt = rtt; } } #endif static void -peerHandlePingReply(peer * p, peer_t type, protocol_t proto, void *pingdata, void *data) +peerHandlePingReply(peer * p, peer_t type, AnyP::ProtocolType proto, void *pingdata, void *data) { - if (proto == PROTO_ICP) + if (proto == AnyP::PROTO_ICP) peerHandleIcpReply(p, type, (icp_common_t *)pingdata, data); #if USE_HTCP - else if (proto == PROTO_HTCP) + else if (proto == AnyP::PROTO_HTCP) peerHandleHtcpReply(p, type, (htcpReplyData *)pingdata, data); #endif else - debugs(44, 1, "peerHandlePingReply: unknown protocol_t " << proto); + debugs(44, 1, "peerHandlePingReply: unknown protocol " << proto); } static void peerAddFwdServer(FwdServer ** FSVR, peer * p, hier_code code) { FwdServer *fs = (FwdServer *)memAllocate(MEM_FWD_SERVER); debugs(44, 5, "peerAddFwdServer: adding " << (p ? p->host : "DIRECT") << " " << hier_code_str[code] ); fs->_peer = cbdataReference(p); fs->code = code; while (*FSVR) FSVR = &(*FSVR)->next; *FSVR = fs; } void * ps_state::operator new(size_t) === modified file 'src/protos.h' --- src/protos.h 2011-02-07 10:27:53 +0000 +++ src/protos.h 2011-02-14 10:27:57 +0000 @@ -67,41 +67,42 @@ SQUIDCEXTERN void wordlistCat(const wordlist *, MemBuf * mb); SQUIDCEXTERN void self_destruct(void); SQUIDCEXTERN void add_http_port(char *portspec); extern int xatoi(const char *token); extern long xatol(const char *token); /* extra functions from cache_cf.c useful for lib modules */ SQUIDCEXTERN void parse_int(int *var); SQUIDCEXTERN void parse_onoff(int *var); SQUIDCEXTERN void parse_eol(char *volatile *var); SQUIDCEXTERN void parse_wordlist(wordlist ** list); SQUIDCEXTERN void requirePathnameExists(const char *name, const char *path); SQUIDCEXTERN void parse_time_t(time_t * var); /* client_side.c - FD related client side routines */ SQUIDCEXTERN void clientdbInit(void); -SQUIDCEXTERN void clientdbUpdate(const Ip::Address &, log_type, protocol_t, size_t); +#include "anyp/ProtocolType.h" +SQUIDCEXTERN void clientdbUpdate(const Ip::Address &, log_type, AnyP::ProtocolType, size_t); SQUIDCEXTERN int clientdbCutoffDenied(const Ip::Address &); void clientdbDump(StoreEntry *); SQUIDCEXTERN void clientdbFreeMemory(void); SQUIDCEXTERN int clientdbEstablished(const Ip::Address &, int); #if USE_DELAY_POOLS SQUIDCEXTERN void clientdbSetWriteLimiter(ClientInfo * info, const int writeSpeedLimit,const double initialBurst,const double highWatermark); SQUIDCEXTERN ClientInfo * clientdbGetInfo(const Ip::Address &addr); #endif SQUIDCEXTERN void clientOpenListenSockets(void); SQUIDCEXTERN void clientHttpConnectionsClose(void); SQUIDCEXTERN void httpRequestFree(void *); extern void clientAccessCheck(void *); #include "Debug.h" /* packs, then prints an object using debugs() */ SQUIDCEXTERN void debugObj(int section, int level, const char *label, void *obj, ObjPackMethod pm); @@ -597,53 +598,53 @@ SQUIDCEXTERN void logsFlush(void); SQUIDCEXTERN const char *checkNullString(const char *p); SQUIDCEXTERN void squid_getrusage(struct rusage *r); SQUIDCEXTERN double rusage_cputime(struct rusage *r); SQUIDCEXTERN int rusage_maxrss(struct rusage *r); SQUIDCEXTERN int rusage_pagefaults(struct rusage *r); SQUIDCEXTERN void releaseServerSockets(void); SQUIDCEXTERN void PrintRusage(void); SQUIDCEXTERN void dumpMallocStats(void); #if USE_UNLINKD SQUIDCEXTERN void unlinkdInit(void); SQUIDCEXTERN void unlinkdClose(void); SQUIDCEXTERN void unlinkdUnlink(const char *); #endif -SQUIDCEXTERN protocol_t urlParseProtocol(const char *, const char *e = NULL); +SQUIDCEXTERN AnyP::ProtocolType urlParseProtocol(const char *, const char *e = NULL); SQUIDCEXTERN void urlInitialize(void); SQUIDCEXTERN HttpRequest *urlParse(const HttpRequestMethod&, char *, HttpRequest *request = NULL); SQUIDCEXTERN const char *urlCanonical(HttpRequest *); SQUIDCEXTERN char *urlCanonicalClean(const HttpRequest *); SQUIDCEXTERN const char *urlCanonicalFakeHttps(const HttpRequest * request); SQUIDCEXTERN bool urlIsRelative(const char *); SQUIDCEXTERN char *urlMakeAbsolute(const HttpRequest *, const char *); SQUIDCEXTERN char *urlRInternal(const char *host, u_short port, const char *dir, const char *name); SQUIDCEXTERN char *urlInternal(const char *dir, const char *name); SQUIDCEXTERN int matchDomainName(const char *host, const char *domain); SQUIDCEXTERN int urlCheckRequest(const HttpRequest *); -SQUIDCEXTERN int urlDefaultPort(protocol_t p); +SQUIDCEXTERN int urlDefaultPort(AnyP::ProtocolType p); SQUIDCEXTERN char *urlHostname(const char *url); SQUIDCEXTERN void urlExtMethodConfigure(void); SQUIDCEXTERN peer_t parseNeighborType(const char *s); /* tools.c */ //UNUSED #include "dlink.h" //UNUSED SQUIDCEXTERN void dlinkAdd(void *data, dlink_node *, dlink_list *); //UNUSED SQUIDCEXTERN void dlinkAddAfter(void *, dlink_node *, dlink_node *, dlink_list *); //UNUSED SQUIDCEXTERN void dlinkAddTail(void *data, dlink_node *, dlink_list *); //UNUSED SQUIDCEXTERN void dlinkDelete(dlink_node * m, dlink_list * list); //UNUSED SQUIDCEXTERN void dlinkNodeDelete(dlink_node * m); //UNUSED SQUIDCEXTERN dlink_node *dlinkNodeNew(void); SQUIDCEXTERN void kb_incr(kb_t *, size_t); SQUIDCEXTERN int stringHasWhitespace(const char *); SQUIDCEXTERN int stringHasCntl(const char *); SQUIDCEXTERN void linklistPush(link_list **, void *); SQUIDCEXTERN void *linklistShift(link_list **); SQUIDCEXTERN int xrename(const char *from, const char *to); === modified file 'src/tests/stub_HttpRequest.cc' --- src/tests/stub_HttpRequest.cc 2009-07-26 09:08:24 +0000 +++ src/tests/stub_HttpRequest.cc 2011-02-14 11:48:18 +0000 @@ -24,82 +24,82 @@ * 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 "HttpRequest.h" HttpRequest::HttpRequest() : HttpMsg(hoRequest) { fatal("Not implemented"); } -HttpRequest::HttpRequest(const HttpRequestMethod& method, protocol_t protocol, const char *aUrlpath) : HttpMsg(hoRequest) +HttpRequest::HttpRequest(const HttpRequestMethod& method, AnyP::ProtocolType protocol, const char *aUrlpath) : HttpMsg(hoRequest) { fatal("Not implemented"); } HttpRequest::~HttpRequest() {} void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const { fatal("Not implemented"); } bool HttpRequest::sanityCheckStartLine(MemBuf *buf, const size_t hdr_len, http_status *error) { fatal("Not implemented"); return false; } void HttpRequest::hdrCacheInit() { fatal("Not implemented"); } void HttpRequest::reset() { fatal("Not implemented"); } bool HttpRequest::expectingBody(const HttpRequestMethod& unused, int64_t&) const { fatal("Not implemented"); return false; } void -HttpRequest::initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) +HttpRequest::initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath) { fatal("Not implemented"); } bool HttpRequest::parseFirstLine(const char *start, const char *end) { fatal("Not implemented"); return false; } HttpRequest * HttpRequest::clone() const { fatal("Not implemented"); return NULL; } bool HttpRequest::inheritProperties(const HttpMsg *aMsg) === modified file 'src/tests/testHttpRequest.cc' --- src/tests/testHttpRequest.cc 2010-09-29 07:25:36 +0000 +++ src/tests/testHttpRequest.cc 2011-02-15 01:55:54 +0000 @@ -25,137 +25,137 @@ Mem::Init(); httpHeaderInitModule(); } /* * Test creating an HttpRequest object from a Url and method */ void testHttpRequest::testCreateFromUrlAndMethod() { /* vanilla url */ ushort expected_port; char * url = xstrdup("http://foo:90/bar"); HttpRequest *aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_GET); expected_port = 90; HttpRequest *nullRequest = NULL; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url)); xfree(url); /* vanilla url, different method */ url = xstrdup("http://foo/bar"); aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_PUT); expected_port = 80; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT(aRequest->method == METHOD_PUT); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://foo/bar"), String(url)); /* a connect url with non-CONNECT data */ url = xstrdup(":foo/bar"); aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_CONNECT); xfree(url); CPPUNIT_ASSERT_EQUAL(nullRequest, aRequest); /* a CONNECT url with CONNECT data */ url = xstrdup("foo:45"); aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_CONNECT); expected_port = 45; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT(aRequest->method == METHOD_CONNECT); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String(""), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_NONE, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_NONE, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("foo:45"), String(url)); xfree(url); } /* * Test creating an HttpRequest object from a Url alone. */ void testHttpRequest::testCreateFromUrl() { /* vanilla url */ ushort expected_port; char * url = xstrdup("http://foo:90/bar"); HttpRequest *aRequest = HttpRequest::CreateFromUrl(url); expected_port = 90; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url)); xfree(url); } /* * Test BUG: URL '2000:800:45' opens host 2000 port 800 !! */ void testHttpRequest::testIPv6HostColonBug() { ushort expected_port; char * url = NULL; HttpRequest *aRequest = NULL; /* valid IPv6 address without port */ url = xstrdup("http://[2000:800::45]/foo"); aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_GET); expected_port = 80; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://[2000:800::45]/foo"), String(url)); xfree(url); /* valid IPv6 address with port */ url = xstrdup("http://[2000:800::45]:90/foo"); aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_GET); expected_port = 90; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://[2000:800::45]:90/foo"), String(url)); xfree(url); /* IPv6 address as invalid (bug trigger) */ url = xstrdup("http://2000:800::45/foo"); aRequest = HttpRequest::CreateFromUrlAndMethod(url, METHOD_GET); expected_port = 80; CPPUNIT_ASSERT_EQUAL(expected_port, aRequest->port); CPPUNIT_ASSERT(aRequest->method == METHOD_GET); CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost())); CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, aRequest->protocol); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol); CPPUNIT_ASSERT_EQUAL(String("http://2000:800::45/foo"), String(url)); xfree(url); } void testHttpRequest::testSanityCheckStartLine() { MemBuf input; PrivateHttpRequest engine; http_status error = HTTP_STATUS_NONE; size_t hdr_len; input.init(); // a valid request line input.append("GET / HTTP/1.1\n\n", 16); hdr_len = headersEnd(input.content(), input.contentSize()); CPPUNIT_ASSERT(engine.doSanityCheckStartLine(&input, hdr_len, &error) ); CPPUNIT_ASSERT_EQUAL(error, HTTP_STATUS_NONE); input.reset(); error = HTTP_STATUS_NONE; === modified file 'src/tests/testURL.cc' --- src/tests/testURL.cc 2010-08-16 14:47:39 +0000 +++ src/tests/testURL.cc 2011-02-15 03:06:46 +0000 @@ -12,44 +12,44 @@ #endif CPPUNIT_TEST_SUITE_REGISTRATION( testURL ); /* init memory pools */ void testURL::setUp() { Mem::Init(); } /* * we can construct a URL with a URLScheme. * This creates a URL for that scheme. */ void testURL::testConstructScheme() { URLScheme empty_scheme; - URL protoless_url(PROTO_NONE); + URL protoless_url(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(empty_scheme, protoless_url.getScheme()); - URLScheme ftp_scheme(PROTO_FTP); - URL ftp_url(PROTO_FTP); + URLScheme ftp_scheme(AnyP::PROTO_FTP); + URL ftp_url(AnyP::PROTO_FTP); CPPUNIT_ASSERT_EQUAL(ftp_scheme, ftp_url.getScheme()); } /* * a default constructed URL has scheme "NONE". * Also, we should be able to use new and delete on * scheme instances. */ void testURL::testDefaultConstructor() { URLScheme aScheme; URL aUrl; CPPUNIT_ASSERT_EQUAL(aScheme, aUrl.getScheme()); URL *urlPointer = new URL; CPPUNIT_ASSERT(urlPointer != NULL); delete urlPointer; } === modified file 'src/tests/testURLScheme.cc' --- src/tests/testURLScheme.cc 2009-05-03 13:02:50 +0000 +++ src/tests/testURLScheme.cc 2011-02-19 01:36:18 +0000 @@ -38,117 +38,117 @@ /* 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 empty_scheme; URLScheme scheme; - scheme = PROTO_NONE; + scheme = AnyP::PROTO_NONE; CPPUNIT_ASSERT_EQUAL(empty_scheme, scheme); - URLScheme https_scheme(PROTO_HTTPS); - scheme = PROTO_HTTPS; + URLScheme https_scheme(AnyP::PROTO_HTTPS); + scheme = AnyP::PROTO_HTTPS; CPPUNIT_ASSERT_EQUAL(https_scheme, 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); + AnyP::ProtocolType protocol = static_cast(URLScheme()); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_NONE, protocol); /* and implicit */ - protocol = URLScheme(PROTO_HTTP); - CPPUNIT_ASSERT_EQUAL(PROTO_HTTP, protocol); + protocol = URLScheme(AnyP::PROTO_HTTP); + CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, protocol); } /* - * a default constructed URLScheme is == PROTO_NONE + * a default constructed URLScheme is == AnyP::PROTO_NONE */ void testURLScheme::testDefaultConstructor() { URLScheme lhs; - URLScheme rhs(PROTO_NONE); + URLScheme rhs(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(lhs, rhs); } /* * we should be able to construct a URLScheme from the old 'protocol_t' enum. */ void testURLScheme::testConstructprotocol_t() { - URLScheme lhs_none(PROTO_NONE), rhs_none(PROTO_NONE); + URLScheme lhs_none(AnyP::PROTO_NONE), rhs_none(AnyP::PROTO_NONE); CPPUNIT_ASSERT_EQUAL(lhs_none, rhs_none); - URLScheme lhs_cacheobj(PROTO_CACHEOBJ), rhs_cacheobj(PROTO_CACHEOBJ); + URLScheme lhs_cacheobj(AnyP::PROTO_CACHEOBJ), rhs_cacheobj(AnyP::PROTO_CACHEOBJ); CPPUNIT_ASSERT_EQUAL(lhs_cacheobj, rhs_cacheobj); CPPUNIT_ASSERT(lhs_none != rhs_cacheobj); } /* * we should be able to get a char const * version of the method. */ void testURLScheme::testConst_str() { - String lhs("wais"); - URLScheme wais(PROTO_WAIS); + String lhs("WAIS"); + URLScheme wais(AnyP::PROTO_WAIS); String rhs(wais.const_str()); CPPUNIT_ASSERT_EQUAL(lhs, rhs); } /* * 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))); + CPPUNIT_ASSERT(URLScheme() == AnyP::PROTO_NONE); + CPPUNIT_ASSERT(not (URLScheme(AnyP::PROTO_WAIS) == AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(AnyP::PROTO_HTTP == URLScheme(AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(not (AnyP::PROTO_CACHEOBJ == URLScheme(AnyP::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))); + CPPUNIT_ASSERT(URLScheme(AnyP::PROTO_NONE) != AnyP::PROTO_HTTP); + CPPUNIT_ASSERT(not (URLScheme(AnyP::PROTO_HTTP) != AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(AnyP::PROTO_NONE != URLScheme(AnyP::PROTO_HTTP)); + CPPUNIT_ASSERT(not (AnyP::PROTO_WAIS != URLScheme(AnyP::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); - String http_str("http"); + buffer << URLScheme(AnyP::PROTO_HTTP); + String http_str("HTTP"); String from_buf(buffer.str().c_str()); CPPUNIT_ASSERT_EQUAL(http_str, from_buf); } === modified file 'src/typedefs.h' --- src/typedefs.h 2011-01-20 10:13:05 +0000 +++ src/typedefs.h 2011-02-14 09:56:17 +0000 @@ -137,41 +137,43 @@ #endif typedef void FREE(void *); typedef void CBDUNL(void *); typedef void FOCB(void *, int fd, int errcode); typedef void PF(int, void *); /* disk.c / diskd.c callback typedefs */ typedef void DRCB(int, const char *buf, int size, int errflag, void *data); /* Disk read CB */ typedef void DWCB(int, int, size_t, void *); /* disk write CB */ typedef void DOCB(int, int errflag, void *data); /* disk open CB */ typedef void DCCB(int, int errflag, void *data); /* disk close CB */ typedef void DUCB(int errflag, void *data); /* disk unlink CB */ typedef void DTCB(int errflag, void *data); /* disk trunc CB */ class DnsLookupDetails; typedef void FQDNH(const char *, const DnsLookupDetails &details, void *); typedef void IDCB(const char *ident, void *data); typedef void IPH(const ipcache_addrs *, const DnsLookupDetails &details, void *); -typedef void IRCB(struct peer *, peer_t, protocol_t, void *, void *data); + +#include "anyp/ProtocolType.h" +typedef void IRCB(struct peer *, peer_t, AnyP::ProtocolType, void *, void *data); class FwdServer; typedef void PSC(FwdServer *, void *); typedef void RH(void *data, char *); /* in wordlist.h */ class wordlist; typedef void UH(void *data, wordlist *); typedef int READ_HANDLER(int, char *, int); typedef int WRITE_HANDLER(int, const char *, int); typedef int QS(const void *, const void *); /* qsort */ typedef void STABH(void *); typedef void ERCB(int fd, void *, size_t); class StoreEntry; typedef void OBJH(StoreEntry *); typedef void SIGHDLR(int sig); typedef void STVLDCB(void *, int, int); typedef void HLPCB(void *, char *buf); typedef int HLPSAVAIL(void *); === modified file 'src/url.cc' --- src/url.cc 2010-12-13 11:31:14 +0000 +++ src/url.cc 2011-02-14 10:56:50 +0000 @@ -23,233 +23,233 @@ * (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 "config.h" #include "URL.h" #include "HttpRequest.h" #include "URLScheme.h" #include "rfc1738.h" static HttpRequest *urlParseFinish(const HttpRequestMethod& method, - const protocol_t protocol, + const AnyP::ProtocolType protocol, const char *const urlpath, const char *const host, const char *const login, const int port, HttpRequest *request); static HttpRequest *urnParse(const HttpRequestMethod& method, char *urn); static const char valid_hostname_chars_u[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789-._" "[:]" ; static const char valid_hostname_chars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" "0123456789-." "[:]" ; void urlInitialize(void) { debugs(23, 5, "urlInitialize: Initializing..."); /* 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); + assert(strcmp(ProtocolStr[AnyP::PROTO_MAX], "TOTAL") == 0); /* * These test that our matchDomainName() function works the * way we expect it to. */ assert(0 == matchDomainName("foo.com", "foo.com")); assert(0 == matchDomainName(".foo.com", "foo.com")); assert(0 == matchDomainName("foo.com", ".foo.com")); assert(0 == matchDomainName(".foo.com", ".foo.com")); assert(0 == matchDomainName("x.foo.com", ".foo.com")); assert(0 != matchDomainName("x.foo.com", "foo.com")); assert(0 != matchDomainName("foo.com", "x.foo.com")); assert(0 != matchDomainName("bar.com", "foo.com")); assert(0 != matchDomainName(".bar.com", "foo.com")); assert(0 != matchDomainName(".bar.com", ".foo.com")); assert(0 != matchDomainName("bar.com", ".foo.com")); assert(0 < matchDomainName("zzz.com", "foo.com")); assert(0 > matchDomainName("aaa.com", "foo.com")); assert(0 == matchDomainName("FOO.com", "foo.COM")); assert(0 < matchDomainName("bfoo.com", "afoo.com")); assert(0 > matchDomainName("afoo.com", "bfoo.com")); assert(0 < matchDomainName("x-foo.com", ".foo.com")); /* more cases? */ } /** * urlParseProtocol() takes begin (b) and end (e) pointers, but for * backwards compatibility, e defaults to NULL, in which case we * assume b is NULL-terminated. */ -protocol_t +AnyP::ProtocolType urlParseProtocol(const char *b, const char *e) { /* * 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, ":"); int len = e - b; /* test common stuff first */ if (strncasecmp(b, "http", len) == 0) - return PROTO_HTTP; + return AnyP::PROTO_HTTP; if (strncasecmp(b, "ftp", len) == 0) - return PROTO_FTP; + return AnyP::PROTO_FTP; if (strncasecmp(b, "https", len) == 0) - return PROTO_HTTPS; + return AnyP::PROTO_HTTPS; if (strncasecmp(b, "file", len) == 0) - return PROTO_FTP; + return AnyP::PROTO_FTP; if (strncasecmp(b, "gopher", len) == 0) - return PROTO_GOPHER; + return AnyP::PROTO_GOPHER; if (strncasecmp(b, "wais", len) == 0) - return PROTO_WAIS; + return AnyP::PROTO_WAIS; if (strncasecmp(b, "cache_object", len) == 0) - return PROTO_CACHEOBJ; + return AnyP::PROTO_CACHEOBJ; if (strncasecmp(b, "urn", len) == 0) - return PROTO_URN; + return AnyP::PROTO_URN; if (strncasecmp(b, "whois", len) == 0) - return PROTO_WHOIS; + return AnyP::PROTO_WHOIS; if (strncasecmp(b, "internal", len) == 0) - return PROTO_INTERNAL; + return AnyP::PROTO_INTERNAL; - return PROTO_NONE; + return AnyP::PROTO_NONE; } int -urlDefaultPort(protocol_t p) +urlDefaultPort(AnyP::ProtocolType p) { switch (p) { - case PROTO_HTTP: + case AnyP::PROTO_HTTP: return 80; - case PROTO_HTTPS: + case AnyP::PROTO_HTTPS: return 443; - case PROTO_FTP: + case AnyP::PROTO_FTP: return 21; - case PROTO_GOPHER: + case AnyP::PROTO_GOPHER: return 70; - case PROTO_WAIS: + case AnyP::PROTO_WAIS: return 210; - case PROTO_CACHEOBJ: + case AnyP::PROTO_CACHEOBJ: - case PROTO_INTERNAL: + case AnyP::PROTO_INTERNAL: return CACHE_HTTP_PORT; - case PROTO_WHOIS: + case AnyP::PROTO_WHOIS: return 43; default: return 0; } } /* * Parse a URI/URL. * * If the 'request' arg is non-NULL, put parsed values there instead * of allocating a new HttpRequest. * * This abuses HttpRequest as a way of representing the parsed url * and its components. * method is used to switch parsers and to init the HttpRequest. * If method is METHOD_CONNECT, then rather than a URL a hostname:port is * looked for. * The url is non const so that if its too long we can NULL-terminate it in place. */ /* * This routine parses a URL. Its assumed that the URL is complete - * ie, the end of the string is the end of the URL. Don't pass a partial * URL here as this routine doesn't have any way of knowing whether * its partial or not (ie, it handles the case of no trailing slash as * being "end of host with implied path of /". */ HttpRequest * urlParse(const HttpRequestMethod& method, char *url, HttpRequest *request) { LOCAL_ARRAY(char, proto, MAX_URL); LOCAL_ARRAY(char, login, MAX_URL); LOCAL_ARRAY(char, host, MAX_URL); LOCAL_ARRAY(char, urlpath, MAX_URL); char *t = NULL; char *q = NULL; int port; - protocol_t protocol = PROTO_NONE; + AnyP::ProtocolType protocol = AnyP::PROTO_NONE; int l; int i; const char *src; char *dst; proto[0] = host[0] = urlpath[0] = login[0] = '\0'; if ((l = strlen(url)) + Config.appendDomainLen > (MAX_URL - 1)) { /* terminate so it doesn't overflow other buffers */ *(url + (MAX_URL >> 1)) = '\0'; debugs(23, 1, "urlParse: URL too large (" << l << " bytes)"); return NULL; } if (method == METHOD_CONNECT) { port = CONNECT_PORT; if (sscanf(url, "[%[^]]]:%d", host, &port) < 1) if (sscanf(url, "%[^:]:%d", host, &port) < 1) return NULL; } else if ((method == METHOD_OPTIONS || method == METHOD_TRACE) && strcmp(url, "*") == 0) { - protocol = PROTO_HTTP; + protocol = AnyP::PROTO_HTTP; port = urlDefaultPort(protocol); return urlParseFinish(method, protocol, url, host, login, port, request); } else if (!strncmp(url, "urn:", 4)) { return urnParse(method, url); } else { /* Parse the URL: */ src = url; i = 0; /* Find first : - everything before is protocol */ for (i = 0, dst = proto; i < l && *src != ':'; i++, src++, dst++) { *dst = *src; } if (i >= l) return NULL; *dst = '\0'; /* Then its :// */ /* (XXX yah, I'm not checking we've got enough data left before checking the array..) */ if (*src != ':' || *(src + 1) != '/' || *(src + 2) != '/') return NULL; @@ -408,77 +408,77 @@ t = q = urlpath; while (*t) { if (!xisspace(*t)) *q++ = *t; t++; } *q = '\0'; } } return urlParseFinish(method, protocol, urlpath, host, login, port, request); } /** * Update request with parsed URI data. If the request arg is * non-NULL, put parsed values there instead of allocating a new * HttpRequest. */ static HttpRequest * urlParseFinish(const HttpRequestMethod& method, - const protocol_t protocol, + const AnyP::ProtocolType protocol, const char *const urlpath, const char *const host, const char *const login, const int port, HttpRequest *request) { if (NULL == request) request = new HttpRequest(method, protocol, urlpath); else { request->initHTTP(method, protocol, urlpath); } request->SetHost(host); xstrncpy(request->login, login, MAX_LOGIN_SZ); request->port = (u_short) port; return request; } static HttpRequest * urnParse(const HttpRequestMethod& method, char *urn) { debugs(50, 5, "urnParse: " << urn); - return new HttpRequest(method, PROTO_URN, urn + 4); + return new HttpRequest(method, AnyP::PROTO_URN, urn + 4); } const char * urlCanonical(HttpRequest * request) { LOCAL_ARRAY(char, portbuf, 32); /// \todo AYJ: Performance: making this a ptr and allocating when needed will be better than a write and future xstrdup(). LOCAL_ARRAY(char, urlbuf, MAX_URL); if (request->canonical) return request->canonical; - if (request->protocol == PROTO_URN) { + if (request->protocol == AnyP::PROTO_URN) { snprintf(urlbuf, MAX_URL, "urn:" SQUIDSTRINGPH, SQUIDSTRINGPRINT(request->urlpath)); } else { /// \todo AYJ: this could use "if..else and method == METHOD_CONNECT" easier. switch (request->method.id()) { case METHOD_CONNECT: snprintf(urlbuf, MAX_URL, "%s:%d", request->GetHost(), request->port); break; default: portbuf[0] = '\0'; if (request->port != urlDefaultPort(request->protocol)) snprintf(portbuf, 32, ":%d", request->port); snprintf(urlbuf, MAX_URL, "%s://%s%s%s%s" SQUIDSTRINGPH, ProtocolStr[request->protocol], request->login, *request->login ? "@" : null_string, @@ -488,41 +488,41 @@ break; } } return (request->canonical = xstrdup(urlbuf)); } /** \todo AYJ: Performance: This is an *almost* duplicate of urlCanonical. But elides the query-string. * After copying it on in the first place! Would be less code to merge the two with a flag parameter. * and never copy the query-string part in the first place */ char * urlCanonicalClean(const HttpRequest * request) { LOCAL_ARRAY(char, buf, MAX_URL); LOCAL_ARRAY(char, portbuf, 32); LOCAL_ARRAY(char, loginbuf, MAX_LOGIN_SZ + 1); char *t; - if (request->protocol == PROTO_URN) { + if (request->protocol == AnyP::PROTO_URN) { snprintf(buf, MAX_URL, "urn:" SQUIDSTRINGPH, SQUIDSTRINGPRINT(request->urlpath)); } else { /// \todo AYJ: this could use "if..else and method == METHOD_CONNECT" easier. switch (request->method.id()) { case METHOD_CONNECT: snprintf(buf, MAX_URL, "%s:%d", request->GetHost(), request->port); break; default: portbuf[0] = '\0'; if (request->port != urlDefaultPort(request->protocol)) snprintf(portbuf, 32, ":%d", request->port); loginbuf[0] = '\0'; @@ -613,41 +613,41 @@ * * It is assumed that you have already ensured that the URL is relative. * * If NULL is returned it is an indication that the method in use in the * request does not distinguish between relative and absolute and you should * use the url unchanged. * * If non-NULL is returned, it is up to the caller to free the resulting * memory using safe_free(). */ char * urlMakeAbsolute(const HttpRequest * req, const char *relUrl) { if (req->method.id() == METHOD_CONNECT) { return (NULL); } char *urlbuf = (char *)xmalloc(MAX_URL * sizeof(char)); - if (req->protocol == PROTO_URN) { + if (req->protocol == AnyP::PROTO_URN) { snprintf(urlbuf, MAX_URL, "urn:" SQUIDSTRINGPH, SQUIDSTRINGPRINT(req->urlpath)); return (urlbuf); } size_t urllen; if (req->port != urlDefaultPort(req->protocol)) { urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s:%d", ProtocolStr[req->protocol], req->login, *req->login ? "@" : null_string, req->GetHost(), req->port ); } else { urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s", ProtocolStr[req->protocol], req->login, *req->login ? "@" : null_string, @@ -791,66 +791,66 @@ * there. * * So, we should delegate them to HTTP. The problem is that we * do not have a default protocol from the client side of HTTP. */ if (r->method == METHOD_CONNECT) return 1; // we support OPTIONS and TRACE directed at us (with a 501 reply, for now) // we also support forwarding OPTIONS and TRACE, except for the *-URI ones if (r->method == METHOD_OPTIONS || r->method == METHOD_TRACE) return (r->header.getInt64(HDR_MAX_FORWARDS) == 0 || r->urlpath != "*"); if (r->method == METHOD_PURGE) return 1; /* does method match the protocol? */ switch (r->protocol) { - case PROTO_URN: + case AnyP::PROTO_URN: - case PROTO_HTTP: + case AnyP::PROTO_HTTP: - case PROTO_CACHEOBJ: + case AnyP::PROTO_CACHEOBJ: rc = 1; break; - case PROTO_FTP: + case AnyP::PROTO_FTP: if (r->method == METHOD_PUT) rc = 1; - case PROTO_GOPHER: + case AnyP::PROTO_GOPHER: - case PROTO_WAIS: + case AnyP::PROTO_WAIS: - case PROTO_WHOIS: + case AnyP::PROTO_WHOIS: if (r->method == METHOD_GET) rc = 1; else if (r->method == METHOD_HEAD) rc = 1; break; - case PROTO_HTTPS: + case AnyP::PROTO_HTTPS: #if USE_SSL rc = 1; break; #else /* * Squid can't originate an SSL connection, so it should * never receive an "https:" URL. It should always be * CONNECT instead. */ rc = 0; #endif default: break; }