From: amosjeffries <> Date: Sun, 20 Jan 2008 15:54:28 +0000 (+0000) Subject: Author: Alexey Veselovsky X-Git-Tag: BASIC_TPROXY4~179 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60745f24f0e78cb7e0c9e853263fa693ff1ae716;p=thirdparty%2Fsquid.git Author: Alexey Veselovsky Bug #226 - Adding support for unknown methods. Response for these methods will not be cached. All cache entries for this url will be invalidated. see bugzilla entry #226 for further details. --- diff --git a/src/ACLMethod.cc b/src/ACLMethod.cc index 7639b6fcf0..d046cac055 100644 --- a/src/ACLMethod.cc +++ b/src/ACLMethod.cc @@ -1,6 +1,6 @@ /* - * $Id: ACLMethod.cc,v 1.3 2003/10/20 12:33:01 robertc Exp $ + * $Id: ACLMethod.cc,v 1.4 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -41,13 +41,13 @@ /* explicit template instantiation required for some systems */ -template class ACLStrategised +template class ACLStrategised ; ACL::Prototype ACLMethod::RegistryProtoype(&ACLMethod::RegistryEntry_, "method"); -ACLStrategised ACLMethod::RegistryEntry_(new ACLMethodData, ACLMethodStrategy::Instance(), "method"); +ACLStrategised ACLMethod::RegistryEntry_(new ACLMethodData, ACLMethodStrategy::Instance(), "method"); int ACLMethodStrategy::match (ACLData * &data, ACLChecklist *checklist) diff --git a/src/ACLMethod.h b/src/ACLMethod.h index 631c561285..9d9b026d45 100644 --- a/src/ACLMethod.h +++ b/src/ACLMethod.h @@ -1,6 +1,6 @@ /* - * $Id: ACLMethod.h,v 1.1 2003/02/25 12:22:33 robertc Exp $ + * $Id: ACLMethod.h,v 1.2 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -38,7 +38,7 @@ #include "ACLStrategy.h" #include "ACLStrategised.h" -class ACLMethodStrategy : public ACLStrategy +class ACLMethodStrategy : public ACLStrategy { public: @@ -63,7 +63,7 @@ class ACLMethod private: static ACL::Prototype RegistryProtoype; - static ACLStrategised RegistryEntry_; + static ACLStrategised RegistryEntry_; }; #endif /* SQUID_ACLMETHOD_H */ diff --git a/src/ACLMethodData.cc b/src/ACLMethodData.cc index 427b8ff193..5999538448 100644 --- a/src/ACLMethodData.cc +++ b/src/ACLMethodData.cc @@ -1,5 +1,5 @@ /* - * $Id: ACLMethodData.cc,v 1.9 2006/05/08 23:38:33 robertc Exp $ + * $Id: ACLMethodData.cc,v 1.10 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -55,24 +55,24 @@ ACLMethodData::~ACLMethodData() } bool -ACLMethodData::match(method_t toFind) +ACLMethodData::match(HttpRequestMethod toFind) { return values->findAndTune (toFind); } /* explicit instantiation required for some systems */ -template cbdata_type List +template cbdata_type List ::CBDATA_List; wordlist * ACLMethodData::dump() { wordlist *W = NULL; - List *data = values; + List *data = values; while (data != NULL) { - wordlistAdd(&W, RequestMethodStr[data->element]); + wordlistAdd(&W, RequestMethodStr(data->element)); data = data->next; } @@ -82,14 +82,14 @@ ACLMethodData::dump() void ACLMethodData::parse() { - List **Tail; + List **Tail; char *t = NULL; for (Tail = &values; *Tail; Tail = &((*Tail)->next)) ; while ((t = strtokFile())) { - List *q = new List (HttpRequestMethod(t)); + List *q = new List (HttpRequestMethod(t)); *(Tail) = q; Tail = &q->next; } @@ -101,7 +101,7 @@ ACLMethodData::empty() const return values == NULL; } -ACLData * +ACLData * ACLMethodData::clone() const { assert (!values); diff --git a/src/ACLMethodData.h b/src/ACLMethodData.h index d394d981bc..9082e77eba 100644 --- a/src/ACLMethodData.h +++ b/src/ACLMethodData.h @@ -1,6 +1,6 @@ /* - * $Id: ACLMethodData.h,v 1.4 2005/05/08 06:36:45 hno Exp $ + * $Id: ACLMethodData.h,v 1.5 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -39,7 +39,7 @@ #include "ACLData.h" #include "List.h" -class ACLMethodData : public ACLData +class ACLMethodData : public ACLData { public: @@ -49,13 +49,13 @@ public: ACLMethodData(ACLMethodData const &); ACLMethodData &operator= (ACLMethodData const &); virtual ~ACLMethodData(); - bool match(method_t); + bool match(HttpRequestMethod); wordlist *dump(); void parse(); bool empty() const; - virtual ACLData *clone() const; + virtual ACLData *clone() const; - List *values; + List *values; }; MEMPROXY_CLASS_INLINE(ACLMethodData) diff --git a/src/AccessLogEntry.h b/src/AccessLogEntry.h index 6e53672595..1fec6fce6a 100644 --- a/src/AccessLogEntry.h +++ b/src/AccessLogEntry.h @@ -1,6 +1,6 @@ /* - * $Id: AccessLogEntry.h,v 1.7 2007/12/14 23:11:45 amosjeffries Exp $ + * $Id: AccessLogEntry.h,v 1.8 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -57,7 +57,7 @@ public: public: HttpDetails() : method(METHOD_NONE), code(0), content_type(NULL) {} - method_t method; + HttpRequestMethod method; int code; const char *content_type; HttpVersion version; diff --git a/src/HttpMsg.h b/src/HttpMsg.h index 719c00a6b7..842333bc08 100644 --- a/src/HttpMsg.h +++ b/src/HttpMsg.h @@ -1,6 +1,6 @@ /* - * $Id: HttpMsg.h,v 1.16 2007/08/13 17:20:51 hno Exp $ + * $Id: HttpMsg.h,v 1.17 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -86,7 +86,7 @@ public: virtual int httpMsgParseError(); - virtual bool expectingBody(method_t, int64_t&) const = 0; + virtual bool expectingBody(const HttpRequestMethod&, int64_t&) const = 0; void firstLineBuf(MemBuf&); diff --git a/src/HttpReply.cc b/src/HttpReply.cc index 36e97b3ed0..40aee3e644 100644 --- a/src/HttpReply.cc +++ b/src/HttpReply.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.cc,v 1.97 2007/11/26 13:09:55 hno Exp $ + * $Id: HttpReply.cc,v 1.98 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 58 HTTP Reply (Response) * AUTHOR: Alex Rousskov @@ -416,7 +416,7 @@ HttpReply::hdrCacheClean() * Returns the body size of a HTTP response */ int64_t -HttpReply::bodySize(method_t method) const +HttpReply::bodySize(const HttpRequestMethod& method) const { if (sline.version.major < 1) return -1; @@ -470,7 +470,7 @@ HttpReply::httpMsgParseError() * along with this response */ bool -HttpReply::expectingBody(method_t req_method, int64_t& theSize) const +HttpReply::expectingBody(const HttpRequestMethod& req_method, int64_t& theSize) const { bool expectBody = true; diff --git a/src/HttpReply.h b/src/HttpReply.h index 6dfb3d0705..6230d05d01 100644 --- a/src/HttpReply.h +++ b/src/HttpReply.h @@ -1,6 +1,6 @@ /* - * $Id: HttpReply.h,v 1.21 2007/08/13 17:20:51 hno Exp $ + * $Id: HttpReply.h,v 1.22 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -97,7 +97,7 @@ public: public: virtual int httpMsgParseError(); - virtual bool expectingBody(method_t, int64_t&) const; + virtual bool expectingBody(const HttpRequestMethod&, int64_t&) const; void updateOnNotModified(HttpReply const *other); @@ -116,7 +116,7 @@ public: void redirect(http_status, const char *); - int64_t bodySize(method_t) const; + int64_t bodySize(const HttpRequestMethod&) const; int validatorsMatch (HttpReply const *other) const; diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index ddd416b0fc..36f878ecd9 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.cc,v 1.78 2007/12/14 23:11:45 amosjeffries Exp $ + * $Id: HttpRequest.cc,v 1.79 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -46,7 +46,7 @@ HttpRequest::HttpRequest() : HttpMsg(hoRequest) init(); } -HttpRequest::HttpRequest(method_t aMethod, protocol_t aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) +HttpRequest::HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) : HttpMsg(hoRequest) { init(); initHTTP(aMethod, aProtocol, aUrlpath); @@ -58,7 +58,7 @@ HttpRequest::~HttpRequest() } void -HttpRequest::initHTTP(method_t aMethod, protocol_t aProtocol, const char *aUrlpath) +HttpRequest::initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) { method = aMethod; protocol = aProtocol; @@ -238,7 +238,7 @@ HttpRequest::pack(Packer * p) assert(p); /* pack request-line */ packerPrintf(p, "%s %s HTTP/1.0\r\n", - RequestMethodStr[method], urlpath.buf()); + RequestMethodStr(method), urlpath.buf()); /* headers */ header.packInto(p); /* trailer */ @@ -259,7 +259,7 @@ httpRequestPack(void *obj, Packer *p) int HttpRequest::prefixLen() { - return strlen(RequestMethodStr[method]) + 1 + + return strlen(RequestMethodStr(method)) + 1 + urlpath.size() + 1 + 4 + 1 + 3 + 2 + header.len + 2; @@ -358,7 +358,7 @@ void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const { // form HTTP request-line packerPrintf(p, "%s %s HTTP/%d.%d\r\n", - RequestMethodStr[method], + RequestMethodStr(method), packableURI(full_uri), http_ver.major, http_ver.minor); } @@ -368,7 +368,7 @@ void HttpRequest::packFirstLineInto(Packer * p, bool full_uri) const * along with this request */ bool -HttpRequest::expectingBody(method_t unused, int64_t& theSize) const +HttpRequest::expectingBody(const HttpRequestMethod& unused, int64_t& theSize) const { bool expectBody = false; @@ -407,7 +407,7 @@ HttpRequest::expectingBody(method_t unused, int64_t& theSize) const * If the request cannot be created cleanly, NULL is returned */ HttpRequest * -HttpRequest::CreateFromUrlAndMethod(char * url, method_t method) +HttpRequest::CreateFromUrlAndMethod(char * url, const HttpRequestMethod& method) { return urlParse(method, url, NULL); } @@ -437,17 +437,9 @@ HttpRequest::cacheable() const * The below looks questionable: what non HTTP protocols use connect, * trace, put and post? RC */ - if (method == METHOD_CONNECT) - return 0; - - if (method == METHOD_TRACE) - return 0; - - if (method == METHOD_PUT) - return 0; - - if (method == METHOD_POST) - return 0; + + if (!method.isCacheble()) + return false; /* * XXX POST may be cached sometimes.. ignored @@ -457,7 +449,7 @@ HttpRequest::cacheable() const return gopherCachable(this); if (protocol == PROTO_CACHEOBJ) - return 0; + return false; - return 1; + return true; } diff --git a/src/HttpRequest.h b/src/HttpRequest.h index f19344fb52..74a9cea2ad 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -1,6 +1,6 @@ /* - * $Id: HttpRequest.h,v 1.31 2007/12/14 23:11:45 amosjeffries Exp $ + * $Id: HttpRequest.h,v 1.32 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -53,7 +53,7 @@ class HttpRequest: public HttpMsg public: MEMPROXY_CLASS(HttpRequest); HttpRequest(); - HttpRequest(method_t aMethod, protocol_t aProtocol, const char *aUrlpath); + HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath); ~HttpRequest(); virtual void reset(); @@ -63,7 +63,7 @@ public: return static_cast(HttpMsg::_lock()); }; - void initHTTP(method_t aMethod, protocol_t aProtocol, const char *aUrlpath); + void initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath); /* are responses to this request potentially cachable */ bool cacheable() const; @@ -92,7 +92,7 @@ protected: void init(); public: - method_t method; + HttpRequestMethod method; char login[MAX_LOGIN_SZ]; @@ -151,7 +151,7 @@ public: int parseHeader(const char *parse_start, int len); - virtual bool expectingBody(method_t unused, int64_t&) const; + virtual bool expectingBody(const HttpRequestMethod& unused, int64_t&) const; bool bodyNibbled() const; // the request has a [partially] consumed body @@ -163,7 +163,7 @@ public: static void httpRequestPack(void *obj, Packer *p); - static HttpRequest * CreateFromUrlAndMethod(char * url, method_t method); + static HttpRequest * CreateFromUrlAndMethod(char * url, const HttpRequestMethod& method); static HttpRequest * CreateFromUrl(char * url); diff --git a/src/HttpRequestMethod.cc b/src/HttpRequestMethod.cc index 2781c5610c..aa3f41c17e 100644 --- a/src/HttpRequestMethod.cc +++ b/src/HttpRequestMethod.cc @@ -1,6 +1,6 @@ /* - * $Id: HttpRequestMethod.cc,v 1.4 2007/04/30 16:56:09 wessels Exp $ + * $Id: HttpRequestMethod.cc,v 1.5 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 73 HTTP Request * AUTHOR: Duane Wessels @@ -38,7 +38,7 @@ #include "HttpRequestMethod.h" #include "wordlist.h" -const char *RequestMethodStr[] = +const char* HttpRequestMethod::RequestMethodStr[] = { "NONE", "GET", @@ -94,10 +94,10 @@ const char *RequestMethodStr[] = }; static -method_t &operator++ (method_t &aMethod) +_method_t &operator++ (_method_t &aMethod) { int tmp = (int)aMethod; - aMethod = (method_t)(++tmp); + aMethod = (_method_t)(++tmp); return aMethod; } @@ -127,20 +127,27 @@ HttpRequestMethod::HttpRequestMethod(char const *begin, char const *end) : theMe */ if (NULL == end) end = begin + strcspn(begin, w_space); - + + if (end == begin) { + theMethod = METHOD_NONE; + return; + } + for (++theMethod; theMethod < METHOD_ENUM_END; ++theMethod) { - if (0 == strncasecmp(begin, RequestMethodStr[theMethod], end-begin)) + if (0 == strncasecmp(begin, RequestMethodStr[theMethod], end-begin)) { return; + } } - /* reset to none */ - theMethod = METHOD_NONE; + // if method not found and method string is not null then it is other method + theMethod = METHOD_OTHER; + theImage.limitInit(begin,end-begin); } void HttpRequestMethod::AddExtension(const char *mstr) { - method_t method = METHOD_NONE; + _method_t method = METHOD_NONE; for (++method; method < METHOD_ENUM_END; ++method) { if (0 == strcmp(mstr, RequestMethodStr[method])) { @@ -178,3 +185,38 @@ HttpRequestMethod::Configure(SquidConfig &Config) w = w->next; } } + +char const* +HttpRequestMethod::image() const +{ + if (METHOD_OTHER != theMethod) { + return RequestMethodStr[theMethod]; + } + else { + if (theImage.size()>0) + return theImage.buf(); + else + return "METHOD_OTHER"; + } +} + +bool +HttpRequestMethod::isCacheble() const +{ + if (theMethod == METHOD_CONNECT) + return false; + + if (theMethod == METHOD_TRACE) + return false; + + if (theMethod == METHOD_PUT) + return false; + + if (theMethod == METHOD_POST) + return false; + + if (theMethod == METHOD_OTHER) + return false; + + return true; +} diff --git a/src/HttpRequestMethod.h b/src/HttpRequestMethod.h index 582a293a10..9616920cf3 100644 --- a/src/HttpRequestMethod.h +++ b/src/HttpRequestMethod.h @@ -1,6 +1,6 @@ /* - * $Id: HttpRequestMethod.h,v 1.5 2007/11/13 23:09:23 rousskov Exp $ + * $Id: HttpRequestMethod.h,v 1.6 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -87,13 +87,10 @@ enum _method_t { METHOD_EXT17, METHOD_EXT18, METHOD_EXT19, - METHOD_ENUM_END + METHOD_OTHER, + METHOD_ENUM_END // MUST be last, (yuck) this is used as an array-initialization index constant! }; -typedef enum _method_t method_t; - -extern const char *RequestMethodStr[]; - /* forward decls */ typedef struct _SquidConfig SquidConfig; @@ -113,33 +110,76 @@ public: HttpRequestMethod() : theMethod(METHOD_NONE) {} - HttpRequestMethod(method_t const aMethod) : theMethod(aMethod) {} + HttpRequestMethod(_method_t const aMethod) : theMethod(aMethod) {} HttpRequestMethod(char const * begin, char const * end=0); - operator method_t() const {return theMethod; } + operator _method_t() const {return theMethod; } + + HttpRequestMethod & operator = (const HttpRequestMethod& aMethod) + { + theMethod = aMethod.theMethod; + theImage = aMethod.theImage; + return *this; + } - HttpRequestMethod & operator = (method_t const aMethod) + HttpRequestMethod & operator = (_method_t const aMethod) { theMethod = aMethod; + theImage.clean(); return *this; } - bool operator != (method_t const & aMethod) { return theMethod != aMethod;} + bool operator != (_method_t const & aMethod) { return theMethod != aMethod;} + bool operator != (HttpRequestMethod const & aMethod) + { + return ( (theMethod != aMethod) || (theImage != aMethod.theImage) ); + } + + HttpRequestMethod& operator++() + { + if (METHOD_OTHER!=theMethod) + { + int tmp = (int)theMethod; + _method_t tmp_m = (_method_t)(++tmp); + + if (METHOD_ENUM_END >= tmp_m) + theMethod = tmp_m; + } + return *this; + } + /* Get a char string representation of the method. */ - char const *const_str() const { return RequestMethodStr[theMethod]; } + char const* image() const; + + bool isCacheble() const; private: - method_t theMethod; - + static const char *RequestMethodStr[]; + + _method_t theMethod; ///< Method type + String theImage; ///< Used for store METHOD_OTHER only }; + inline std::ostream & operator << (std::ostream &os, HttpRequestMethod const &method) { - os << method.const_str(); + os << method.image(); return os; } +inline const char* +RequestMethodStr(const _method_t m) +{ + return HttpRequestMethod(m).image(); +} + +inline const char* +RequestMethodStr(const HttpRequestMethod& m) +{ + return m.image(); +} + #endif /* SQUID_HTTPREQUESTMETHOD_H */ diff --git a/src/ICAP/ICAPModXact.cc b/src/ICAP/ICAPModXact.cc index 3cb5d61978..4aaf7f4955 100644 --- a/src/ICAP/ICAPModXact.cc +++ b/src/ICAP/ICAPModXact.cc @@ -1356,7 +1356,7 @@ void ICAPModXact::estimateVirginBody() HttpMsg *msg = virgin.header; Must(msg); - method_t method; + HttpRequestMethod method; if (virgin.cause) method = virgin.cause->method; diff --git a/src/MemObject.cc b/src/MemObject.cc index 9ac3633626..2966c1a10a 100644 --- a/src/MemObject.cc +++ b/src/MemObject.cc @@ -1,6 +1,6 @@ /* - * $Id: MemObject.cc,v 1.32 2007/11/15 16:47:35 wessels Exp $ + * $Id: MemObject.cc,v 1.33 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 19 Store Memory Primitives * AUTHOR: Robert Collins @@ -214,7 +214,7 @@ void MemObject::stat (MemBuf * mb) const { mb->Printf("\t%s %s\n", - RequestMethodStr[method], log_url); + RequestMethodStr(method), log_url); mb->Printf("\tinmem_lo: %"PRId64"\n", inmem_lo); mb->Printf("\tinmem_hi: %"PRId64"\n", data_hdr.endOffset()); mb->Printf("\tswapout: %"PRId64" bytes queued\n", diff --git a/src/MemObject.h b/src/MemObject.h index 1b204610c9..765d96b6bd 100644 --- a/src/MemObject.h +++ b/src/MemObject.h @@ -1,6 +1,6 @@ /* - * $Id: MemObject.h,v 1.15 2007/08/13 17:20:51 hno Exp $ + * $Id: MemObject.h,v 1.16 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -90,7 +90,7 @@ public: void checkUrlChecksum() const; #endif - method_t method; + HttpRequestMethod method; char *url; mem_hdr data_hdr; int64_t inmem_lo; diff --git a/src/SquidString.h b/src/SquidString.h index 9d31866fcb..082605e967 100644 --- a/src/SquidString.h +++ b/src/SquidString.h @@ -1,5 +1,5 @@ /* - * $Id: SquidString.h,v 1.13 2008/01/19 10:38:32 amosjeffries Exp $ + * $Id: SquidString.h,v 1.14 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 67 String * AUTHOR: Duane Wessels @@ -35,6 +35,7 @@ #ifndef SQUID_STRING_H #define SQUID_STRING_H + /* forward decls */ class CacheManager; diff --git a/src/Store.h b/src/Store.h index ffd08638b0..e159d940b5 100644 --- a/src/Store.h +++ b/src/Store.h @@ -1,6 +1,6 @@ /* - * $Id: Store.h,v 1.41 2008/01/07 17:12:28 hno Exp $ + * $Id: Store.h,v 1.42 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -153,9 +153,9 @@ swap_status_t swap_status: public: static size_t inUseCount(); - static void getPublicByRequestMethod(StoreClient * aClient, HttpRequest * request, const method_t method); + static void getPublicByRequestMethod(StoreClient * aClient, HttpRequest * request, const HttpRequestMethod& method); static void getPublicByRequest(StoreClient * aClient, HttpRequest * request); - static void getPublic(StoreClient * aClient, const char *uri, const method_t method); + static void getPublic(StoreClient * aClient, const char *uri, const HttpRequestMethod& method); virtual bool isNull() { @@ -304,10 +304,10 @@ SQUIDCEXTERN size_t storeEntryInUse(); SQUIDCEXTERN const char *storeEntryFlags(const StoreEntry *); extern void storeEntryReplaceObject(StoreEntry *, HttpReply *); -SQUIDCEXTERN StoreEntry *storeGetPublic(const char *uri, const method_t method); +SQUIDCEXTERN StoreEntry *storeGetPublic(const char *uri, const HttpRequestMethod& method); SQUIDCEXTERN StoreEntry *storeGetPublicByRequest(HttpRequest * request); -SQUIDCEXTERN StoreEntry *storeGetPublicByRequestMethod(HttpRequest * request, const method_t method); -SQUIDCEXTERN StoreEntry *storeCreateEntry(const char *, const char *, request_flags, method_t); +SQUIDCEXTERN StoreEntry *storeGetPublicByRequestMethod(HttpRequest * request, const HttpRequestMethod& method); +SQUIDCEXTERN StoreEntry *storeCreateEntry(const char *, const char *, request_flags, const HttpRequestMethod&); SQUIDCEXTERN void storeInit(void); extern void storeRegisterWithCacheManager(CacheManager & manager); SQUIDCEXTERN void storeConfigure(void); diff --git a/src/access_log.cc b/src/access_log.cc index bc010f1687..5382d4f5e3 100644 --- a/src/access_log.cc +++ b/src/access_log.cc @@ -1,6 +1,6 @@ /* - * $Id: access_log.cc,v 1.129 2007/12/14 23:11:45 amosjeffries Exp $ + * $Id: access_log.cc,v 1.130 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 46 Access Log * AUTHOR: Duane Wessels @@ -1408,7 +1408,7 @@ accessLogLog(AccessLogEntry * al, ACLChecklist * checklist) if (al->icp.opcode) al->_private.method_str = icp_opcode_str[al->icp.opcode]; else - al->_private.method_str = RequestMethodStr[al->http.method]; + al->_private.method_str = RequestMethodStr(al->http.method); if (al->hier.host[0] == '\0') xstrncpy(al->hier.host, dash_str, SQUIDHOSTNAMELEN); @@ -1783,7 +1783,7 @@ mcast_encode(unsigned int *ibuf, size_t isize, const unsigned int *key) #if HEADERS_LOG void -headersLog(int cs, int pq, method_t method, void *data) +headersLog(int cs, int pq, const HttpRequestMethod& method, void *data) { HttpReply *rep; HttpRequest *req; diff --git a/src/acl.cc b/src/acl.cc index 52200f1b78..a61859237c 100644 --- a/src/acl.cc +++ b/src/acl.cc @@ -1,5 +1,5 @@ /* - * $Id: acl.cc,v 1.324 2007/12/05 16:02:29 rousskov Exp $ + * $Id: acl.cc,v 1.325 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Duane Wessels @@ -330,7 +330,7 @@ acl_access::containsPURGE() const for (; a; a = a->next) { for (b = a->aclList; b; b = b->next) { - ACLStrategised *tempAcl = dynamic_cast *>(b->_acl); + ACLStrategised *tempAcl = dynamic_cast *>(b->_acl); if (!tempAcl) { debugs(28, 7, "acl_access::containsPURGE: can't create tempAcl"); diff --git a/src/auth/digest/auth_digest.cc b/src/auth/digest/auth_digest.cc index 63ade9a1ad..09742bfa94 100644 --- a/src/auth/digest/auth_digest.cc +++ b/src/auth/digest/auth_digest.cc @@ -1,5 +1,5 @@ /* - * $Id: auth_digest.cc,v 1.61 2007/12/30 04:06:30 hno Exp $ + * $Id: auth_digest.cc,v 1.62 2008/01/20 08:54:30 amosjeffries Exp $ * * DEBUG: section 29 Authenticator * AUTHOR: Robert Collins @@ -617,7 +617,7 @@ AuthDigestUserRequest::authenticate(HttpRequest * request, ConnStateData::Pointe digest_user->HA1, SESSIONKEY); DigestCalcResponse(SESSIONKEY, authenticateDigestNonceNonceb64(digest_request->nonce), digest_request->nc, digest_request->cnonce, digest_request->qop, - RequestMethodStr[request->method], digest_request->uri, HA2, Response); + RequestMethodStr(request->method), digest_request->uri, HA2, Response); debugs(29, 9, "\nResponse = '" << digest_request->response << "'\nsquid is = '" << Response << "'"); @@ -638,7 +638,7 @@ AuthDigestUserRequest::authenticate(HttpRequest * request, ConnStateData::Pointe */ DigestCalcResponse(SESSIONKEY, authenticateDigestNonceNonceb64(digest_request->nonce), digest_request->nc, digest_request->cnonce, digest_request->qop, - RequestMethodStr[METHOD_GET], digest_request->uri, HA2, Response); + RequestMethodStr(METHOD_GET), digest_request->uri, HA2, Response); if (strcasecmp(digest_request->response, Response)) { credentials(Failed); diff --git a/src/client_side.cc b/src/client_side.cc index 8ee8a62c79..a082450541 100644 --- a/src/client_side.cc +++ b/src/client_side.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side.cc,v 1.771 2007/12/14 23:11:46 amosjeffries Exp $ + * $Id: client_side.cc,v 1.772 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 33 Client-side Routines * AUTHOR: Duane Wessels @@ -130,7 +130,7 @@ static PF requestTimeout; static PF clientLifetimeTimeout; static ClientSocketContext *parseHttpRequestAbort(ConnStateData::Pointer & conn, const char *uri); -static ClientSocketContext *parseHttpRequest(ConnStateData::Pointer &, HttpParser *, method_t *, HttpVersion *); +static ClientSocketContext *parseHttpRequest(ConnStateData::Pointer &, HttpParser *, HttpRequestMethod *, HttpVersion *); #if USE_IDENT static IDCB clientIdentDone; #endif @@ -655,7 +655,7 @@ clientSetKeepaliveFlag(ClientHttpRequest * http) debugs(33, 3, "clientSetKeepaliveFlag: http_ver = " << request->http_ver.major << "." << request->http_ver.minor); debugs(33, 3, "clientSetKeepaliveFlag: method = " << - RequestMethodStr[request->method]); + RequestMethodStr(request->method)); HttpVersion http_ver(1,0); /* we are HTTP/1.0, no matter what the client requests... */ @@ -1832,7 +1832,7 @@ prepareTransparentURL(ConnStateData::Pointer & conn, ClientHttpRequest *http, ch * Sets result->flags.parsed_ok to 1 if we have a good request. */ static ClientSocketContext * -parseHttpRequest(ConnStateData::Pointer & conn, HttpParser *hp, method_t * method_p, HttpVersion *http_ver) +parseHttpRequest(ConnStateData::Pointer & conn, HttpParser *hp, HttpRequestMethod * method_p, HttpVersion *http_ver) { char *url = NULL; char *req_hdr = NULL; @@ -1891,7 +1891,7 @@ parseHttpRequest(ConnStateData::Pointer & conn, HttpParser *hp, method_t * metho } /* Set method_p */ - *method_p = HttpRequestMethod(&hp->buf[hp->m_start], &hp->buf[hp->m_end]); + *method_p = HttpRequestMethod(&hp->buf[hp->m_start], &hp->buf[hp->m_end]+1); if (*method_p == METHOD_NONE) { /* XXX need a way to say "this many character length string" */ @@ -2136,7 +2136,7 @@ clientAfterReadingRequests(int fd, ConnStateData::Pointer &conn, int do_next_rea } static void -clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketContext *context, method_t method, HttpVersion http_ver) +clientProcessRequest(ConnStateData::Pointer &conn, HttpParser *hp, ClientSocketContext *context, const HttpRequestMethod& method, HttpVersion http_ver) { ClientHttpRequest *http = context->http; HttpRequest *request = NULL; @@ -2356,7 +2356,7 @@ ConnStateData::bodySizeLeft() static bool clientParseRequest(ConnStateData::Pointer conn, bool &do_next_read) { - method_t method; + HttpRequestMethod method; ClientSocketContext *context; bool parsed_req = false; HttpVersion http_ver; diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 91f11bf5ea..280b369a8d 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.cc,v 1.147 2007/12/26 22:19:37 hno Exp $ + * $Id: client_side_reply.cc,v 1.148 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 88 Client-side Reply Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -88,7 +88,7 @@ clientReplyContext::clientReplyContext(ClientHttpRequest *clientContext) : http */ void clientReplyContext::setReplyToError( - err_type err, http_status status, method_t method, char const *uri, + err_type err, http_status status, const HttpRequestMethod& method, char const *uri, IPAddress &addr, HttpRequest * failedrequest, char *unparsedrequest, AuthUserRequest * auth_user_request) { @@ -657,7 +657,7 @@ clientReplyContext::processMiss() char *url = http->uri; HttpRequest *r = http->request; ErrorState *err = NULL; - debugs(88, 4, "clientProcessMiss: '" << RequestMethodStr[r->method] << " " << url << "'"); + debugs(88, 4, "clientProcessMiss: '" << RequestMethodStr(r->method) << " " << url << "'"); /* * We might have a left-over StoreEntry from a failed cache hit * or IMS request. @@ -677,6 +677,11 @@ clientReplyContext::processMiss() purgeRequest(); return; } + + if (METHOD_OTHER == r->method) { + // invalidate all cache entries + purgeAllCached(); + } if (http->onlyIfCached()) { processOnlyIfCachedMiss(); @@ -694,7 +699,7 @@ clientReplyContext::processMiss() triggerInitialStoreRead(); return; } else { - assert(http->out.offset == 0); + assert(http->out.offset == 0); createStoreEntry(r->method, r->flags); triggerInitialStoreRead(); @@ -732,7 +737,7 @@ clientReplyContext::processOnlyIfCachedMiss() { ErrorState *err = NULL; debugs(88, 4, "clientProcessOnlyIfCachedMiss: '" << - RequestMethodStr[http->request->method] << " " << http->uri << "'"); + RequestMethodStr(http->request->method) << " " << http->uri << "'"); http->al.http.code = HTTP_GATEWAY_TIMEOUT; err = clientBuildError(ERR_ONLY_IF_CACHED_MISS, HTTP_GATEWAY_TIMEOUT, NULL, http->getConn()->peer, http->request); removeClientStoreReference(&sc, http); @@ -741,13 +746,37 @@ clientReplyContext::processOnlyIfCachedMiss() void clientReplyContext::purgeRequestFindObjectToPurge() -{ +{ /* Try to find a base entry */ http->flags.purging = 1; lookingforstore = 1; + + // TODO: can we use purgeAllCached() here instead of doing the + // getPublicByRequestMethod() dance? StoreEntry::getPublicByRequestMethod(this, http->request, METHOD_GET); } +/* + * We probably cannot purge Vary-affected responses because their MD5 + * keys depend on vary headers. + */ +void +clientReplyContext::purgeAllCached() +{ + const char *url = urlCanonical(http->request); + + HttpRequestMethod m(METHOD_NONE); + for (; m!=METHOD_ENUM_END; ++m) { + if (m.isCacheble()) { + if (StoreEntry *entry = storeGetPublic(url, m)) { + debugs(88, 5, "purging " << RequestMethodStr(m) << ' ' << url); + entry->release(); + } + } // end if(isCacheble()) + } // end for + +} // purgeAllCached + void clientReplyContext::created(StoreEntry *newEntry) { @@ -1792,7 +1821,7 @@ clientReplyContext::ProcessReplyAccessResult (int rv, void *voidMe) void clientReplyContext::processReplyAccessResult(bool accessAllowed) { - debugs(88, 2, "The reply for " << RequestMethodStr[http->request->method] + debugs(88, 2, "The reply for " << RequestMethodStr(http->request->method) << " " << http->uri << " is " << ( accessAllowed ? "ALLOWED" : "DENIED") << ", because it matched '" @@ -1996,7 +2025,7 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) /* Using this breaks the client layering just a little! */ void -clientReplyContext::createStoreEntry(method_t m, request_flags flags) +clientReplyContext::createStoreEntry(const HttpRequestMethod& m, request_flags flags) { assert(http != NULL); /* diff --git a/src/client_side_reply.h b/src/client_side_reply.h index dbc465f3d2..cb70baf01d 100644 --- a/src/client_side_reply.h +++ b/src/client_side_reply.h @@ -1,6 +1,6 @@ /* - * $Id: client_side_reply.h,v 1.19 2008/01/07 17:12:28 hno Exp $ + * $Id: client_side_reply.h,v 1.20 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -76,8 +76,8 @@ public: int storeOKTransferDone() const; int storeNotOKTransferDone() const; - void setReplyToError(err_type, http_status, method_t, char const *, IPAddress &, HttpRequest *, char *, AuthUserRequest *); - void createStoreEntry(method_t m, request_flags flags); + void setReplyToError(err_type, http_status, const HttpRequestMethod&, char const *, IPAddress &, HttpRequest *, char *, AuthUserRequest *); + void createStoreEntry(const HttpRequestMethod& m, request_flags flags); void removeStoreReference(store_client ** scp, StoreEntry ** ep); void removeClientStoreReference(store_client **scp, ClientHttpRequest *http); void startError(ErrorState * err); @@ -143,6 +143,7 @@ private: void triggerInitialStoreRead(); void sendClientOldEntry(); void buildMaxBodySize(HttpReply * reply); + void purgeAllCached(); StoreEntry *old_entry; diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 81948809b2..16782ab2db 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.100 2007/12/17 02:21:53 amosjeffries Exp $ + * $Id: client_side_request.cc,v 1.101 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -271,7 +271,7 @@ ClientHttpRequest::~ClientHttpRequest() * determined by the user */ int /* returns nonzero on failure */ -clientBeginRequest(method_t method, char const *url, CSCB * streamcallback, +clientBeginRequest(const HttpRequestMethod& method, char const *url, CSCB * streamcallback, CSD * streamdetach, ClientStreamData streamdata, HttpHeader const *header, char *tailbuf, size_t taillen) { @@ -400,7 +400,7 @@ ClientRequestContext::clientAccessCheckDone(int answer) err_type page_id; http_status status; debugs(85, 2, "The request " << - RequestMethodStr[http->request->method] << " " << + RequestMethodStr(http->request->method) << " " << http->uri << " is " << (answer == ACCESS_ALLOWED ? "ALLOWED" : "DENIED") << ", because it matched '" << @@ -553,7 +553,7 @@ clientHierarchical(ClientHttpRequest * http) { const char *url = http->uri; HttpRequest *request = http->request; - method_t method = request->method; + HttpRequestMethod method = request->method; const wordlist *p = NULL; /* @@ -656,6 +656,10 @@ clientInterpretRequestHeaders(ClientHttpRequest * http) } } } + + if (METHOD_OTHER == request->method) { + no_cache++; + } #endif if (no_cache) { @@ -882,7 +886,7 @@ ClientRequestContext::checkNoCacheDone(int answer) void ClientHttpRequest::processRequest() { - debugs(85, 4, "clientProcessRequest: " << RequestMethodStr[request->method] << " '" << uri << "'"); + debugs(85, 4, "clientProcessRequest: " << RequestMethodStr(request->method) << " '" << uri << "'"); if (request->method == METHOD_CONNECT && !redirect.status) { logType = LOG_TCP_MISS; diff --git a/src/client_side_request.h b/src/client_side_request.h index d9a242e377..5234b0a7d0 100644 --- a/src/client_side_request.h +++ b/src/client_side_request.h @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.h,v 1.33 2008/01/07 17:12:28 hno Exp $ + * $Id: client_side_request.h,v 1.34 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -50,7 +50,7 @@ class HttpMsg; #endif /* client_side_request.c - client side request related routines (pure logic) */ -extern int clientBeginRequest(method_t, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t); +extern int clientBeginRequest(const HttpRequestMethod&, char const *, CSCB *, CSD *, ClientStreamData, HttpHeader const *, char *, size_t); class MemObject; diff --git a/src/errorpage.cc b/src/errorpage.cc index 1f2da04f4f..d3444b6963 100644 --- a/src/errorpage.cc +++ b/src/errorpage.cc @@ -1,6 +1,6 @@ /* - * $Id: errorpage.cc,v 1.228 2007/12/14 23:11:46 amosjeffries Exp $ + * $Id: errorpage.cc,v 1.229 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 4 Error Generation * AUTHOR: Duane Wessels @@ -535,7 +535,7 @@ errorDump(ErrorState * err, MemBuf * mb) if (NULL != r) { Packer p; str.Printf("%s %s HTTP/%d.%d\n", - RequestMethodStr[r->method], + RequestMethodStr(r->method), r->urlpath.size() ? r->urlpath.buf() : "/", r->http_ver.major, r->http_ver.minor); packerToMemInit(&p, &str); @@ -714,7 +714,7 @@ errorConvert(char token, ErrorState * err) break; case 'M': - p = r ? RequestMethodStr[r->method] : "[unknown method]"; + p = r ? RequestMethodStr(r->method) : "[unknown method]"; break; @@ -741,7 +741,7 @@ errorConvert(char token, ErrorState * err) if (NULL != r) { Packer p; mb.Printf("%s %s HTTP/%d.%d\n", - RequestMethodStr[r->method], + RequestMethodStr(r->method), r->urlpath.size() ? r->urlpath.buf() : "/", r->http_ver.major, r->http_ver.minor); packerToMemInit(&p, &mb); diff --git a/src/external_acl.cc b/src/external_acl.cc index c7fb9c6113..4e717d474a 100644 --- a/src/external_acl.cc +++ b/src/external_acl.cc @@ -1,6 +1,6 @@ /* - * $Id: external_acl.cc,v 1.81 2007/12/14 23:11:46 amosjeffries Exp $ + * $Id: external_acl.cc,v 1.82 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 82 External ACL * AUTHOR: Henrik Nordstrom, MARA Systems AB @@ -849,7 +849,7 @@ makeExternalAclKey(ACLChecklist * ch, external_acl_data * acl_data) break; case _external_acl_format::EXT_ACL_METHOD: - str = RequestMethodStr[request->method]; + str = RequestMethodStr(request->method); break; case _external_acl_format::EXT_ACL_HEADER: diff --git a/src/forward.cc b/src/forward.cc index 0da586558f..920e1d015f 100644 --- a/src/forward.cc +++ b/src/forward.cc @@ -1,6 +1,6 @@ /* - * $Id: forward.cc,v 1.169 2007/12/14 23:11:46 amosjeffries Exp $ + * $Id: forward.cc,v 1.170 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 17 Request Forwarding * AUTHOR: Duane Wessels @@ -939,7 +939,7 @@ void FwdState::dispatch() { peer *p = NULL; - debugs(17, 3, "fwdDispatch: FD " << client_fd << ": Fetching '" << RequestMethodStr[request->method] << " " << entry->url() << "'" ); + debugs(17, 3, "fwdDispatch: FD " << client_fd << ": Fetching '" << RequestMethodStr(request->method) << " " << entry->url() << "'" ); /* * Assert that server_fd is set. This is to guarantee that fwdState * is attached to something and will be deallocated when server_fd @@ -1296,7 +1296,7 @@ FwdState::log() (int) current_time.tv_sec, (int) current_time.tv_usec / 1000, last_status, - RequestMethodStr[request->method], + RequestMethodStr(request->method), request->canonical); } diff --git a/src/htcp.cc b/src/htcp.cc index 0455090d8c..df63c4a4a9 100644 --- a/src/htcp.cc +++ b/src/htcp.cc @@ -1,6 +1,6 @@ /* - * $Id: htcp.cc,v 1.78 2007/12/14 23:11:46 amosjeffries Exp $ + * $Id: htcp.cc,v 1.79 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 31 Hypertext Caching Protocol * AUTHOR: Duane Wesssels @@ -661,7 +661,7 @@ static htcpSpecifier * htcpUnpackSpecifier(char *buf, int sz) { htcpSpecifier *s = new htcpSpecifier; - method_t method; + HttpRequestMethod method; /* Find length of METHOD */ u_int16_t l = ntohs(*(u_int16_t *) buf); @@ -764,7 +764,7 @@ htcpUnpackSpecifier(char *buf, int sz) */ method = HttpRequestMethod(s->method); - s->request = HttpRequest::CreateFromUrlAndMethod(s->uri, method == METHOD_NONE ? METHOD_GET : method); + s->request = HttpRequest::CreateFromUrlAndMethod(s->uri, method == METHOD_NONE ? HttpRequestMethod(METHOD_GET) : method); if (s->request) HTTPMSGLOCK(s->request); @@ -1575,7 +1575,7 @@ htcpQuery(StoreEntry * e, HttpRequest * req, peer * p) stuff.msg_id = ++msg_id_counter; - stuff.S.method = (char *) RequestMethodStr[req->method]; + stuff.S.method = (char *) RequestMethodStr(req->method); stuff.S.uri = (char *) e->url(); diff --git a/src/http.cc b/src/http.cc index 28a4e011f4..e8c91f002e 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1,6 +1,6 @@ /* - * $Id: http.cc,v 1.544 2008/01/07 15:16:03 hno Exp $ + * $Id: http.cc,v 1.545 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 11 Hypertext Transfer Protocol (HTTP) * AUTHOR: Harvest Derived @@ -171,10 +171,11 @@ httpStateFree(int fd, void *data) } int -httpCachable(method_t method) +httpCachable(const HttpRequestMethod& method) { /* GET and HEAD are cachable. Others are not. */ + // TODO: replase to HttpRequestMethod::isCachable() ? if (method != METHOD_GET && method != METHOD_HEAD) return 0; @@ -879,7 +880,7 @@ HttpStateData::statusIfComplete() const * connection. */ if (!flags.request_sent) { - debugs(11, 1, "statusIfComplete: Request not yet fully sent \"" << RequestMethodStr[orig_request->method] << " " << entry->url() << "\"" ); + debugs(11, 1, "statusIfComplete: Request not yet fully sent \"" << RequestMethodStr(orig_request->method) << " " << entry->url() << "\"" ); return COMPLETE_NONPERSISTENT_MSG; } @@ -1734,7 +1735,7 @@ HttpStateData::buildRequestPrefix(HttpRequest * request, const int offset = mb->size; HttpVersion httpver(1, 0); mb->Printf("%s %s HTTP/%d.%d\r\n", - RequestMethodStr[request->method], + RequestMethodStr(request->method), request->urlpath.size() ? request->urlpath.buf() : "/", httpver.major,httpver.minor); /* build and pack headers */ @@ -1818,7 +1819,7 @@ HttpStateData::sendRequest() void httpStart(FwdState *fwd) { - debugs(11, 3, "httpStart: \"" << RequestMethodStr[fwd->request->method] << " " << fwd->entry->url() << "\"" ); + debugs(11, 3, "httpStart: \"" << RequestMethodStr(fwd->request->method) << " " << fwd->entry->url() << "\"" ); HttpStateData *httpState = new HttpStateData(fwd); if (!httpState->sendRequest()) { diff --git a/src/peer_select.cc b/src/peer_select.cc index 76a65aca57..cb1904f608 100644 --- a/src/peer_select.cc +++ b/src/peer_select.cc @@ -1,5 +1,5 @@ /* - * $Id: peer_select.cc,v 1.148 2007/12/14 23:11:47 amosjeffries Exp $ + * $Id: peer_select.cc,v 1.149 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 44 Peer Selection Algorithm * AUTHOR: Duane Wessels @@ -159,7 +159,7 @@ peerSelect(HttpRequest * request, if (entry) debugs(44, 3, "peerSelect: " << entry->url() ); else - debugs(44, 3, "peerSelect: " << RequestMethodStr[request->method]); + debugs(44, 3, "peerSelect: " << RequestMethodStr(request->method)); psstate = new ps_state; @@ -288,7 +288,7 @@ peerSelectFoo(ps_state * ps) { StoreEntry *entry = ps->entry; HttpRequest *request = ps->request; - debugs(44, 3, "peerSelectFoo: '" << RequestMethodStr[request->method] << " " << request->GetHost() << "'"); + debugs(44, 3, "peerSelectFoo: '" << RequestMethodStr(request->method) << " " << request->GetHost() << "'"); if (ps->direct == DIRECT_UNKNOWN) { if (ps->always_direct == 0 && Config.accessList.AlwaysDirect) { @@ -500,7 +500,7 @@ peerGetSomeParent(ps_state * ps) peer *p; HttpRequest *request = ps->request; hier_code code = HIER_NONE; - debugs(44, 3, "peerGetSomeParent: " << RequestMethodStr[request->method] << " " << request->GetHost()); + debugs(44, 3, "peerGetSomeParent: " << RequestMethodStr(request->method) << " " << request->GetHost()); if (ps->direct == DIRECT_YES) return; diff --git a/src/protos.h b/src/protos.h index 11023aaafe..0d4d07d3ef 100644 --- a/src/protos.h +++ b/src/protos.h @@ -1,6 +1,6 @@ /* - * $Id: protos.h,v 1.551 2007/12/14 23:11:47 amosjeffries Exp $ + * $Id: protos.h,v 1.552 2008/01/20 08:54:28 amosjeffries Exp $ * * * SQUID Web Proxy Cache http://www.squid-cache.org/ @@ -53,7 +53,7 @@ SQUIDCEXTERN void fvdbCountVia(const char *key); SQUIDCEXTERN void fvdbCountForw(const char *key); #endif #if HEADERS_LOG -SQUIDCEXTERN void headersLog(int cs, int pq, method_t m, void *data); +SQUIDCEXTERN void headersLog(int cs, int pq, const HttpRequestMethod& m, void *data); #endif SQUIDCEXTERN char *log_quote(const char *header); SQUIDCEXTERN int logTypeIsATcpHit(log_type); @@ -189,7 +189,7 @@ SQUIDCEXTERN int gopherCachable(const HttpRequest *); SQUIDCEXTERN void whoisStart(FwdState *); /* http.c */ -SQUIDCEXTERN int httpCachable(method_t); +SQUIDCEXTERN int httpCachable(const HttpRequestMethod&); SQUIDCEXTERN void httpStart(FwdState *); SQUIDCEXTERN mb_size_t httpBuildRequestPrefix(HttpRequest * request, HttpRequest * orig_request, @@ -526,10 +526,10 @@ SQUIDCEXTERN cache_key *storeKeyCopy(cache_key *, const cache_key *); SQUIDCEXTERN void storeKeyFree(const cache_key *); SQUIDCEXTERN const cache_key *storeKeyScan(const char *); SQUIDCEXTERN const char *storeKeyText(const cache_key *); -SQUIDCEXTERN const cache_key *storeKeyPublic(const char *, const method_t); +SQUIDCEXTERN const cache_key *storeKeyPublic(const char *, const HttpRequestMethod&); SQUIDCEXTERN const cache_key *storeKeyPublicByRequest(HttpRequest *); -SQUIDCEXTERN const cache_key *storeKeyPublicByRequestMethod(HttpRequest *, const method_t); -SQUIDCEXTERN const cache_key *storeKeyPrivate(const char *, method_t, int); +SQUIDCEXTERN const cache_key *storeKeyPublicByRequestMethod(HttpRequest *, const HttpRequestMethod&); +SQUIDCEXTERN const cache_key *storeKeyPrivate(const char *, const HttpRequestMethod&, int); SQUIDCEXTERN int storeKeyHashBuckets(int); SQUIDCEXTERN int storeKeyNull(const cache_key *); SQUIDCEXTERN void storeKeyInit(void); @@ -623,7 +623,7 @@ SQUIDCEXTERN void unlinkdUnlink(const char *); SQUIDCEXTERN protocol_t urlParseProtocol(const char *, const char *e = NULL); SQUIDCEXTERN void urlInitialize(void); -SQUIDCEXTERN HttpRequest *urlParse(method_t, char *, HttpRequest *request = NULL); +SQUIDCEXTERN HttpRequest *urlParse(const HttpRequestMethod&, char *, HttpRequest *request = NULL); SQUIDCEXTERN const char *urlCanonical(HttpRequest *); SQUIDCEXTERN char *urlRInternal(const char *host, u_short port, const char *dir, const char *name); SQUIDCEXTERN char *urlInternal(const char *dir, const char *name); diff --git a/src/redirect.cc b/src/redirect.cc index cba04a10ad..4f0105c061 100644 --- a/src/redirect.cc +++ b/src/redirect.cc @@ -1,6 +1,6 @@ /* - * $Id: redirect.cc,v 1.123 2007/12/14 23:11:48 amosjeffries Exp $ + * $Id: redirect.cc,v 1.124 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 61 Redirector * AUTHOR: Duane Wessels @@ -157,7 +157,7 @@ redirectStart(ClientHttpRequest * http, RH * handler, void *data) if (!r->client_ident) r->client_ident = dash_str; - r->method_s = RequestMethodStr[http->request->method]; + r->method_s = RequestMethodStr(http->request->method); r->handler = handler; diff --git a/src/store.cc b/src/store.cc index a6b6b8a018..d7fa8c0cce 100644 --- a/src/store.cc +++ b/src/store.cc @@ -1,6 +1,6 @@ /* - * $Id: store.cc,v 1.618 2007/08/30 19:26:10 hno Exp $ + * $Id: store.cc,v 1.619 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 20 Storage Manager * AUTHOR: Harvest Derived @@ -520,7 +520,7 @@ StoreEntry::unlock() } void -StoreEntry::getPublicByRequestMethod (StoreClient *aClient, HttpRequest * request, const method_t method) +StoreEntry::getPublicByRequestMethod (StoreClient *aClient, HttpRequest * request, const HttpRequestMethod& method) { assert (aClient); StoreEntry *result = storeGetPublicByRequestMethod( request, method); @@ -544,7 +544,7 @@ StoreEntry::getPublicByRequest (StoreClient *aClient, HttpRequest * request) } void -StoreEntry::getPublic (StoreClient *aClient, const char *uri, const method_t method) +StoreEntry::getPublic (StoreClient *aClient, const char *uri, const HttpRequestMethod& method) { assert (aClient); StoreEntry *result = storeGetPublic (uri, method); @@ -556,13 +556,13 @@ StoreEntry::getPublic (StoreClient *aClient, const char *uri, const method_t met } StoreEntry * -storeGetPublic(const char *uri, const method_t method) +storeGetPublic(const char *uri, const HttpRequestMethod& method) { return Store::Root().get(storeKeyPublic(uri, method)); } StoreEntry * -storeGetPublicByRequestMethod(HttpRequest * req, const method_t method) +storeGetPublicByRequestMethod(HttpRequest * req, const HttpRequestMethod& method) { return Store::Root().get(storeKeyPublicByRequestMethod(req, method)); } @@ -747,7 +747,7 @@ StoreEntry::setPublicKey() } StoreEntry * -storeCreateEntry(const char *url, const char *log_url, request_flags flags, method_t method) +storeCreateEntry(const char *url, const char *log_url, request_flags flags, const HttpRequestMethod& method) { StoreEntry *e = NULL; MemObject *mem = NULL; diff --git a/src/store_key_md5.cc b/src/store_key_md5.cc index 1fdfed2ea5..d60c8f8704 100644 --- a/src/store_key_md5.cc +++ b/src/store_key_md5.cc @@ -1,6 +1,6 @@ /* - * $Id: store_key_md5.cc,v 1.36 2007/11/15 16:47:35 wessels Exp $ + * $Id: store_key_md5.cc,v 1.37 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 20 Storage Manager MD5 Cache Keys * AUTHOR: Duane Wessels @@ -99,12 +99,12 @@ storeKeyHashHash(const void *key, unsigned int n) } const cache_key * -storeKeyPrivate(const char *url, method_t method, int id) +storeKeyPrivate(const char *url, const HttpRequestMethod& method, int id) { static cache_key digest[SQUID_MD5_DIGEST_LENGTH]; SquidMD5_CTX M; assert(id > 0); - debugs(20, 3, "storeKeyPrivate: " << RequestMethodStr[method] << " " << url); + debugs(20, 3, "storeKeyPrivate: " << RequestMethodStr(method) << " " << url); SquidMD5Init(&M); SquidMD5Update(&M, (unsigned char *) &id, sizeof(id)); SquidMD5Update(&M, (unsigned char *) &method, sizeof(method)); @@ -114,7 +114,7 @@ storeKeyPrivate(const char *url, method_t method, int id) } const cache_key * -storeKeyPublic(const char *url, const method_t method) +storeKeyPublic(const char *url, const HttpRequestMethod& method) { static cache_key digest[SQUID_MD5_DIGEST_LENGTH]; unsigned char m = (unsigned char) method; @@ -133,7 +133,7 @@ storeKeyPublicByRequest(HttpRequest * request) } const cache_key * -storeKeyPublicByRequestMethod(HttpRequest * request, const method_t method) +storeKeyPublicByRequestMethod(HttpRequest * request, const HttpRequestMethod& method) { static cache_key digest[SQUID_MD5_DIGEST_LENGTH]; unsigned char m = (unsigned char) method; diff --git a/src/store_log.cc b/src/store_log.cc index 7a0a992e1b..dfa95feeb0 100644 --- a/src/store_log.cc +++ b/src/store_log.cc @@ -1,5 +1,5 @@ /* - * $Id: store_log.cc,v 1.36 2007/12/14 23:11:48 amosjeffries Exp $ + * $Id: store_log.cc,v 1.37 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 20 Storage Manager Logging Functions * AUTHOR: Duane Wessels @@ -90,7 +90,7 @@ storeLog(int tag, const StoreEntry * e) reply->content_type.size() ? reply->content_type.buf() : "unknown", reply->content_length, e->contentLen(), - RequestMethodStr[mem->method], + RequestMethodStr(mem->method), mem->log_url); } else { /* no mem object. Most RELEASE cases */ diff --git a/src/test_cache_digest.cc b/src/test_cache_digest.cc index afb3057380..3b15ab7ca1 100644 --- a/src/test_cache_digest.cc +++ b/src/test_cache_digest.cc @@ -1,6 +1,6 @@ /* - * $Id: test_cache_digest.cc,v 1.34 2007/11/15 16:47:35 wessels Exp $ + * $Id: test_cache_digest.cc,v 1.35 2008/01/20 08:54:28 amosjeffries Exp $ * * AUTHOR: Alex Rousskov * @@ -124,7 +124,7 @@ const char *RequestMethodStr[] = }; /* copied from url.c */ -static method_t +static HttpRequestMethod methodStrToId(const char *s) { if (strcasecmp(s, "GET") == 0) { @@ -431,7 +431,7 @@ accessLogReader(FileIterator * fi) RawAccessLogEntry *entry; char *url; char *method; - method_t method_id = METHOD_NONE; + HttpRequestMethod method_id = METHOD_NONE; char *hier = NULL; assert(fi); diff --git a/src/tests/stub_HttpReply.cc b/src/tests/stub_HttpReply.cc index 6afc0d2d9f..94ba11599a 100644 --- a/src/tests/stub_HttpReply.cc +++ b/src/tests/stub_HttpReply.cc @@ -1,5 +1,5 @@ /* - * $Id: stub_HttpReply.cc,v 1.4 2007/08/13 17:20:58 hno Exp $ + * $Id: stub_HttpReply.cc,v 1.5 2008/01/20 08:54:33 amosjeffries Exp $ * * DEBUG: section 84 Helper process maintenance * AUTHOR: Robert Collins @@ -90,7 +90,7 @@ HttpReply::httpMsgParseError() } bool -HttpReply::expectingBody(method_t, int64_t&) const +HttpReply::expectingBody(const HttpRequestMethod&, int64_t&) const { fatal ("Not implemented"); return false; diff --git a/src/tests/stub_HttpRequest.cc b/src/tests/stub_HttpRequest.cc index 5e290d4c4f..15e2eac815 100644 --- a/src/tests/stub_HttpRequest.cc +++ b/src/tests/stub_HttpRequest.cc @@ -1,5 +1,5 @@ /* - * $Id: stub_HttpRequest.cc,v 1.4 2007/08/13 17:20:58 hno Exp $ + * $Id: stub_HttpRequest.cc,v 1.5 2008/01/20 08:54:33 amosjeffries Exp $ * * DEBUG: section 28 Access Control * AUTHOR: Robert Collins @@ -41,7 +41,7 @@ HttpRequest::HttpRequest() : HttpMsg(hoRequest) fatal("Not implemented"); } -HttpRequest::HttpRequest(method_t method, protocol_t protocol, const char *aUrlpath) : HttpMsg(hoRequest) +HttpRequest::HttpRequest(const HttpRequestMethod& method, protocol_t protocol, const char *aUrlpath) : HttpMsg(hoRequest) { fatal("Not implemented"); } @@ -75,14 +75,14 @@ HttpRequest::reset() } bool -HttpRequest::expectingBody(method_t unused, int64_t&) const +HttpRequest::expectingBody(const HttpRequestMethod& unused, int64_t&) const { fatal("Not implemented"); return false; } void -HttpRequest::initHTTP(method_t aMethod, protocol_t aProtocol, const char *aUrlpath) +HttpRequest::initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath) { fatal("Not implemented"); } diff --git a/src/tests/testHttpRequestMethod.cc b/src/tests/testHttpRequestMethod.cc index 7b479ebbe1..d5c73b1856 100644 --- a/src/tests/testHttpRequestMethod.cc +++ b/src/tests/testHttpRequestMethod.cc @@ -20,6 +20,7 @@ testHttpRequestMethod::testConstructCharStart() CPPUNIT_ASSERT(METHOD_NONE == HttpRequestMethod(NULL)); /* parsing a literal should work */ CPPUNIT_ASSERT(METHOD_GET == HttpRequestMethod("GET", NULL)); + CPPUNIT_ASSERT(METHOD_OTHER == HttpRequestMethod("QWERTY", NULL)); } /* diff --git a/src/tunnel.cc b/src/tunnel.cc index ed3a1a7582..925791ff2c 100644 --- a/src/tunnel.cc +++ b/src/tunnel.cc @@ -1,6 +1,6 @@ /* - * $Id: tunnel.cc,v 1.176 2007/12/14 23:11:48 amosjeffries Exp $ + * $Id: tunnel.cc,v 1.177 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 26 Secure Sockets Layer Proxy * AUTHOR: Duane Wessels @@ -629,7 +629,7 @@ tunnelStart(ClientHttpRequest * http, int64_t * size_ptr, int *status_ptr) } } - debugs(26, 3, "tunnelStart: '" << RequestMethodStr[request->method] << " " << url << "'"); + debugs(26, 3, "tunnelStart: '" << RequestMethodStr(request->method) << " " << url << "'"); statCounter.server.all.requests++; statCounter.server.other.requests++; /* Create socket. */ diff --git a/src/url.cc b/src/url.cc index c747eeed8b..8cfdf4dbaa 100644 --- a/src/url.cc +++ b/src/url.cc @@ -1,6 +1,6 @@ /* - * $Id: url.cc,v 1.163 2007/12/14 23:11:48 amosjeffries Exp $ + * $Id: url.cc,v 1.164 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 23 URL Parsing * AUTHOR: Duane Wessels @@ -37,7 +37,7 @@ #include "HttpRequest.h" #include "URLScheme.h" -static HttpRequest *urnParse(method_t method, char *urn); +static HttpRequest *urnParse(const HttpRequestMethod& method, char *urn); static const char valid_hostname_chars_u[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" "abcdefghijklmnopqrstuvwxyz" @@ -196,7 +196,7 @@ urlDefaultPort(protocol_t p) * being "end of host with implied path of /". */ HttpRequest * -urlParse(method_t method, char *url, HttpRequest *request) +urlParse(const HttpRequestMethod& method, char *url, HttpRequest *request) { LOCAL_ARRAY(char, proto, MAX_URL); LOCAL_ARRAY(char, login, MAX_URL); @@ -420,7 +420,7 @@ urlParse(method_t method, char *url, HttpRequest *request) } static HttpRequest * -urnParse(method_t method, char *urn) +urnParse(const HttpRequestMethod& method, char *urn) { debugs(50, 5, "urnParse: " << urn); return new HttpRequest(method, PROTO_URN, urn + 4); diff --git a/src/urn.cc b/src/urn.cc index d8db3baf49..5378178bd7 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -1,6 +1,6 @@ /* - * $Id: urn.cc,v 1.108 2007/12/14 23:11:48 amosjeffries Exp $ + * $Id: urn.cc,v 1.109 2008/01/20 08:54:28 amosjeffries Exp $ * * DEBUG: section 52 URN Parsing * AUTHOR: Kostas Anagnostakis @@ -100,7 +100,7 @@ typedef struct url_entry; static STCB urnHandleReply; -static url_entry *urnParseReply(const char *inbuf, method_t); +static url_entry *urnParseReply(const char *inbuf, const HttpRequestMethod&); static const char *const crlf = "\r\n"; static QS url_entry_sort; @@ -128,7 +128,7 @@ UrnState::~UrnState () } static url_entry * -urnFindMinRtt(url_entry * urls, method_t m, int *rtt_ret) +urnFindMinRtt(url_entry * urls, const HttpRequestMethod& m, int *rtt_ret) { int min_rtt = 0; url_entry *u = NULL; @@ -476,7 +476,7 @@ error: } static url_entry * -urnParseReply(const char *inbuf, method_t m) +urnParseReply(const char *inbuf, const HttpRequestMethod& m) { char *buf = xstrdup(inbuf); char *token;