From: Francesco Chemolli Date: Mon, 10 Sep 2012 12:49:35 +0000 (+0200) Subject: renamed request_flags to RequestFlags, moved to own header, started implementing... X-Git-Tag: sourceformat-review-1~6^2~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f206b6525faf5699d23cec177d62aeced871fa07;p=thirdparty%2Fsquid.git renamed request_flags to RequestFlags, moved to own header, started implementing getters and setters for it. --- diff --git a/src/HttpRequest.cc b/src/HttpRequest.cc index 20a13379c7..e91c2240b3 100644 --- a/src/HttpRequest.cc +++ b/src/HttpRequest.cc @@ -420,27 +420,6 @@ HttpRequest::hdrCacheInit() range = header.getRange(); } -/* request_flags */ -bool -request_flags::resetTCP() const -{ - return reset_tcp != 0; -} - -void -request_flags::setResetTCP() -{ - debugs(73, 9, "request_flags::setResetTCP"); - reset_tcp = 1; -} - -void -request_flags::clearResetTCP() -{ - debugs(73, 9, "request_flags::clearResetTCP"); - reset_tcp = 0; -} - #if ICAP_CLIENT Adaptation::Icap::History::Pointer HttpRequest::icapHistory() const @@ -493,27 +472,6 @@ HttpRequest::multipartRangeRequest() const return (range && range->specs.count > 1); } -void -request_flags::destinationIPLookupCompleted() -{ - destinationIPLookedUp_ = true; -} - -bool -request_flags::destinationIPLookedUp() const -{ - return destinationIPLookedUp_; -} - -request_flags -request_flags::cloneAdaptationImmune() const -{ - // At the time of writing, all flags where either safe to copy after - // adaptation or were not set at the time of the adaptation. If there - // are flags that are different, they should be cleared in the clone. - return *this; -} - bool HttpRequest::bodyNibbled() const { diff --git a/src/HttpRequest.h b/src/HttpRequest.h index f7a06a6c78..40005752a5 100644 --- a/src/HttpRequest.h +++ b/src/HttpRequest.h @@ -37,6 +37,7 @@ #include "HierarchyLogEntry.h" #include "HttpMsg.h" #include "HttpRequestMethod.h" +#include "RequestFlags.h" #if USE_AUTH #include "auth/UserRequest.h" @@ -162,7 +163,7 @@ public: char *canonical; - request_flags flags; + RequestFlags flags; HttpHdrRange *range; diff --git a/src/Makefile.am b/src/Makefile.am index 1510f7e379..21fe2588b6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -397,6 +397,8 @@ squid_SOURCES = \ HttpParser.h \ HttpReply.cc \ HttpReply.h \ + RequestFlags.h \ + RequestFlags.cc \ HttpRequest.cc \ HttpRequest.h \ HttpRequestMethod.cc \ @@ -1142,8 +1144,8 @@ tests_testHttpReply_SOURCES=\ HttpStatusLine.h \ Mem.h \ mem.cc \ - RegexList.h \ - RegexList.cc \ + RegexList.h \ + RegexList.cc \ MemBuf.cc \ MemBuf.h \ mime_header.h \ @@ -1366,6 +1368,8 @@ tests_testCacheManager_SOURCES = \ debug.cc \ HttpParser.cc \ HttpParser.h \ + RequestFlags.h \ + RequestFlags.cc \ HttpRequest.cc \ HttpRequestMethod.cc \ Mem.h \ @@ -1386,7 +1390,7 @@ tests_testCacheManager_SOURCES = \ YesNoNone.cc \ RefreshPattern.h \ CacheMgrPasswd.h \ - CacheMgrPasswd.cc \ + CacheMgrPasswd.cc \ cache_cf.cc \ CacheDigest.h \ CacheDigest.cc \ @@ -1648,6 +1652,8 @@ tests_testDiskIO_SOURCES = \ refresh.h \ refresh.cc \ RemovalPolicy.cc \ + RequestFlags.h \ + RequestFlags.cc \ StatCounters.h \ StatCounters.cc \ StatHist.h \ @@ -1779,7 +1785,7 @@ tests_testEvent_SOURCES = \ YesNoNone.cc \ RefreshPattern.h \ CacheMgrPasswd.h \ - CacheMgrPasswd.cc \ + CacheMgrPasswd.cc \ cache_cf.cc \ cache_manager.cc \ carp.h \ @@ -1853,6 +1859,8 @@ tests_testEvent_SOURCES = \ HttpParser.cc \ HttpParser.h \ HttpReply.cc \ + RequestFlags.h \ + RequestFlags.cc \ HttpRequest.cc \ HttpRequestMethod.cc \ HttpStatusLine.cc \ @@ -2019,7 +2027,7 @@ tests_testEventLoop_SOURCES = \ YesNoNone.cc \ RefreshPattern.h \ CacheMgrPasswd.h \ - CacheMgrPasswd.cc \ + CacheMgrPasswd.cc \ cache_cf.cc \ carp.h \ carp.cc \ @@ -2092,6 +2100,8 @@ tests_testEventLoop_SOURCES = \ HttpParser.cc \ HttpParser.h \ HttpReply.cc \ + RequestFlags.h \ + RequestFlags.cc \ HttpRequest.cc \ HttpRequestMethod.cc \ HttpStatusLine.cc \ @@ -2254,7 +2264,7 @@ tests_test_http_range_SOURCES = \ YesNoNone.cc \ RefreshPattern.h \ CacheMgrPasswd.h \ - CacheMgrPasswd.cc \ + CacheMgrPasswd.cc \ cache_cf.cc \ cache_manager.cc \ CacheDigest.h \ @@ -2328,6 +2338,8 @@ tests_test_http_range_SOURCES = \ HttpParser.cc \ HttpParser.h \ HttpReply.cc \ + RequestFlags.h \ + RequestFlags.cc \ HttpRequest.cc \ HttpRequestMethod.cc \ HttpStatusLine.cc \ @@ -2522,6 +2534,8 @@ tests_testHttpRequest_SOURCES = \ $(ACL_REGISTRATION_SOURCES) \ HttpParser.cc \ HttpParser.h \ + RequestFlags.h \ + RequestFlags.cc \ HttpRequest.cc \ HttpRequestMethod.cc \ Mem.h \ @@ -2545,7 +2559,7 @@ tests_testHttpRequest_SOURCES = \ YesNoNone.cc \ RefreshPattern.h \ CacheMgrPasswd.h \ - CacheMgrPasswd.cc \ + CacheMgrPasswd.cc \ cache_cf.cc \ debug.cc \ CacheDigest.h \ @@ -2783,6 +2797,8 @@ tests_testStore_SOURCES= \ HttpHeader.cc \ HttpMsg.cc \ HttpRequestMethod.cc \ + RequestFlags.cc \ + RequestFlags.h \ int.h \ int.cc \ SquidList.h \ @@ -3003,6 +3019,8 @@ tests_testUfs_SOURCES = \ HttpStatusLine.cc \ int.h \ int.cc \ + RequestFlags.h \ + RequestFlags.cc \ SquidList.h \ SquidList.cc \ MemObject.cc \ @@ -3182,6 +3200,8 @@ tests_testRock_SOURCES = \ Packer.cc \ Parsing.cc \ RemovalPolicy.cc \ + RequestFlags.cc \ + RequestFlags.h \ StatCounters.h \ StatCounters.cc \ StatHist.h \ @@ -3606,7 +3626,7 @@ tests_testURL_SOURCES = \ YesNoNone.cc \ RefreshPattern.h \ CacheMgrPasswd.h \ - CacheMgrPasswd.cc \ + CacheMgrPasswd.cc \ cache_cf.cc \ cache_manager.cc \ CacheDigest.h \ @@ -3679,6 +3699,8 @@ tests_testURL_SOURCES = \ HttpParser.cc \ HttpParser.h \ HttpReply.cc \ + RequestFlags.h \ + RequestFlags.cc \ HttpRequest.cc \ HttpRequestMethod.cc \ HttpStatusLine.cc \ @@ -3760,8 +3782,8 @@ tests_testURL_SOURCES = \ StoreMetaVary.cc \ StoreSwapLogData.cc \ String.cc \ - StrList.h \ - StrList.cc \ + StrList.h \ + StrList.cc \ SwapDir.cc \ MemStore.cc \ tests/stub_debug.cc \ diff --git a/src/RequestFlags.cc b/src/RequestFlags.cc new file mode 100644 index 0000000000..e19df2e275 --- /dev/null +++ b/src/RequestFlags.cc @@ -0,0 +1,97 @@ +/* + * DEBUG: section 73 HTTP Request + * AUTHOR: Duane Wessels + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +#include "squid.h" +#include "Debug.h" +#include "RequestFlags.h" + +// TODO: move to .cci +/* RequestFlags */ +bool +RequestFlags::resetTCP() const +{ + return resetTCP_; +} + +void +RequestFlags::setResetTCP() +{ + debugs(73, 9, "request_flags::setResetTCP"); + resetTCP_ = true; +} + +void +RequestFlags::clearResetTCP() +{ + debugs(73, 9, "request_flags::clearResetTCP"); + resetTCP_ = false; +} + +void +RequestFlags::destinationIPLookupCompleted() +{ + destinationIPLookedUp_ = true; +} + +bool +RequestFlags::destinationIPLookedUp() const +{ + return destinationIPLookedUp_; +} + +bool +RequestFlags::isRanged() const +{ + return isRanged_; +} + +void +RequestFlags::setRanged() +{ + isRanged_ = true; +} + +void +RequestFlags::clearRanged() +{ + isRanged_ = false; +} + + +RequestFlags +RequestFlags::cloneAdaptationImmune() const +{ + // At the time of writing, all flags where either safe to copy after + // adaptation or were not set at the time of the adaptation. If there + // are flags that are different, they should be cleared in the clone. + return *this; +} diff --git a/src/RequestFlags.h b/src/RequestFlags.h new file mode 100644 index 0000000000..738a7284ca --- /dev/null +++ b/src/RequestFlags.h @@ -0,0 +1,118 @@ +#ifndef SQUID_REQUESTFLAGS_H_ +#define SQUID_REQUESTFLAGS_H_ +/* + * DEBUG: section 73 HTTP Request + * AUTHOR: Duane Wessels + * + * SQUID Web Proxy Cache http://www.squid-cache.org/ + * ---------------------------------------------------------- + * + * Squid is the result of efforts by numerous individuals from + * the Internet community; see the CONTRIBUTORS file for full + * details. Many organizations have provided support for Squid's + * development; see the SPONSORS file for full details. Squid is + * Copyrighted (C) 2001 by the Regents of the University of + * California; see the COPYRIGHT file for full details. Squid + * incorporates software developed and/or copyrighted by other + * sources; see the CREDITS file for full details. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA. + * + */ + +class RequestFlags { +public: + RequestFlags(): + nocache(0), ims(0), auth(0), cachable(0), + hierarchical(0), loopdetect(0), proxy_keepalive(0), proxying(0), + refresh(0), redirected(0), need_validation(0), + fail_on_validation_err(0), stale_if_hit(0), accelerated(0), + ignore_cc(0), intercepted(0), hostVerified(0), spoof_client_ip(0), + internal(0), internalclient(0), must_keepalive(0), pinned(0), + canRePin(0), chunked_reply(0), stream_error(0), sslPeek(0), + sslBumped(0), destinationIPLookedUp_(false), resetTCP_(false), + isRanged_(false) { +#if USE_HTTP_VIOLATIONS + nocache_hack = 0; +#endif +#if FOLLOW_X_FORWARDED_FOR + done_follow_x_forwarded_for = 0; +#endif /* FOLLOW_X_FORWARDED_FOR */ + } + + unsigned int nocache :1; ///< whether the response to this request may be READ from cache + unsigned int ims :1; + unsigned int auth :1; + unsigned int cachable :1; ///< whether the response to thie request may be stored in the cache + unsigned int hierarchical :1; + unsigned int loopdetect :1; + unsigned int proxy_keepalive :1; + unsigned int proxying :1; /* this should be killed, also in httpstateflags */ + unsigned int refresh :1; + unsigned int redirected :1; + unsigned int need_validation :1; + unsigned int fail_on_validation_err :1; ///< whether we should fail if validation fails + unsigned int stale_if_hit :1; ///< reply is stale if it is a hit +#if USE_HTTP_VIOLATIONS + /* for changing/ignoring no-cache requests */ + /* TODO: remove the conditional definition, move ifdef to setter */ + unsigned int nocache_hack :1; +#endif + unsigned int accelerated :1; + unsigned int ignore_cc :1; + unsigned int intercepted :1; ///< intercepted request + unsigned int hostVerified :1; ///< whether the Host: header passed verification + unsigned int spoof_client_ip :1; /**< spoof client ip if possible */ + unsigned int internal :1; + unsigned int internalclient :1; + unsigned int must_keepalive :1; + unsigned int connection_auth :1; /** Request wants connection oriented auth */ + unsigned int connection_auth_disabled :1; /** Connection oriented auth can not be supported */ + unsigned int connection_proxy_auth :1; /** Request wants connection oriented auth */ + unsigned int pinned :1; /* Request sent on a pinned connection */ + unsigned int canRePin :1; ///< OK to reopen a failed pinned connection + unsigned int auth_sent :1; /* Authentication forwarded */ + unsigned int no_direct :1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */ + unsigned int chunked_reply :1; /**< Reply with chunked transfer encoding */ + unsigned int stream_error :1; /**< Whether stream error has occured */ + unsigned int sslPeek :1; ///< internal ssl-bump request to get server cert + unsigned int sslBumped :1; /**< ssl-bumped request*/ + +#if FOLLOW_X_FORWARDED_FOR + /* TODO: move from conditional definition to conditional setting */ + unsigned int done_follow_x_forwarded_for :1; +#endif /* FOLLOW_X_FORWARDED_FOR */ + + // When adding new flags, please update cloneAdaptationImmune() as needed. + bool resetTCP() const; + void setResetTCP(); + void clearResetTCP(); + void destinationIPLookupCompleted(); + bool destinationIPLookedUp() const; + // returns a partial copy of the flags that includes only those flags + // that are safe for a related (e.g., ICAP-adapted) request to inherit + RequestFlags cloneAdaptationImmune() const; + + bool isRanged() const; + void setRanged(); + void clearRanged(); +private: + + bool destinationIPLookedUp_:1; + bool resetTCP_:1; ///< request to reset the TCP stream + bool isRanged_ :1; +}; + +#endif /* SQUID_REQUESTFLAGS_H_ */ diff --git a/src/Store.h b/src/Store.h index 5fedd563bd..04c182d331 100644 --- a/src/Store.h +++ b/src/Store.h @@ -42,6 +42,7 @@ #include "Range.h" #include "RefCount.h" #include "RemovalPolicy.h" +#include "RequestFlags.h" #include "StoreIOBuffer.h" #include "StoreStats.h" @@ -378,7 +379,8 @@ SQUIDCEXTERN StoreEntry *storeGetPublicByRequest(HttpRequest * request); SQUIDCEXTERN StoreEntry *storeGetPublicByRequestMethod(HttpRequest * request, const HttpRequestMethod& method); /// \ingroup StoreAPI -SQUIDCEXTERN StoreEntry *storeCreateEntry(const char *, const char *, request_flags, const HttpRequestMethod&); +class RequestFlags; +extern StoreEntry *storeCreateEntry(const char *, const char *, const RequestFlags &, const HttpRequestMethod&); /// \ingroup StoreAPI SQUIDCEXTERN void storeInit(void); diff --git a/src/acl/Asn.cc b/src/acl/Asn.cc index 6ed8056cae..c0b94d7d65 100644 --- a/src/acl/Asn.cc +++ b/src/acl/Asn.cc @@ -32,22 +32,23 @@ */ #include "squid.h" -#include "mgr/Registration.h" -#include "radix.h" -#include "HttpRequest.h" -#include "StoreClient.h" -#include "Store.h" #include "acl/Acl.h" #include "acl/Asn.h" #include "acl/Checklist.h" -#include "acl/SourceAsn.h" #include "acl/DestinationAsn.h" #include "acl/DestinationIp.h" +#include "acl/SourceAsn.h" #include "cache_cf.h" +#include "forward.h" #include "HttpReply.h" +#include "HttpRequest.h" #include "ipcache.h" -#include "forward.h" +#include "mgr/Registration.h" +#include "radix.h" +#include "RequestFlags.h" #include "SquidConfig.h" +#include "Store.h" +#include "StoreClient.h" #include "StoreClient.h" #include "wordlist.h" @@ -248,7 +249,7 @@ asnCacheStart(int as) asState->request = HTTPMSGLOCK(req); if ((e = storeGetPublic(asres, METHOD_GET)) == NULL) { - e = storeCreateEntry(asres, asres, request_flags(), METHOD_GET); + e = storeCreateEntry(asres, asres, RequestFlags(), METHOD_GET); asState->sc = storeClientListAdd(e, asState); FwdState::fwdStart(Comm::ConnectionPointer(), e, asState->request); } else { diff --git a/src/client_side_reply.cc b/src/client_side_reply.cc index 323a40af15..4cafe42717 100644 --- a/src/client_side_reply.cc +++ b/src/client_side_reply.cc @@ -54,6 +54,7 @@ #include "mime_header.h" #include "neighbors.h" #include "refresh.h" +#include "RequestFlags.h" #include "SquidConfig.h" #include "SquidTime.h" #include "Store.h" @@ -132,7 +133,7 @@ void clientReplyContext::setReplyToError(const HttpRequestMethod& method, ErrorS http->al->http.code = errstate->httpStatus; - createStoreEntry(method, request_flags()); + createStoreEntry(method, RequestFlags()); assert(errstate->callback_data == NULL); errorAppendEntry(http->storeEntry(), errstate); /* Now the caller reads to get this */ @@ -226,7 +227,7 @@ clientReplyContext::restoreState() void clientReplyContext::startError(ErrorState * err) { - createStoreEntry(http->request->method, request_flags()); + createStoreEntry(http->request->method, RequestFlags()); triggerInitialStoreRead(); errorAppendEntry(http->storeEntry(), err); } @@ -656,7 +657,7 @@ clientReplyContext::processMiss() if (r->flags.loopdetect) { http->al->http.code = HTTP_FORBIDDEN; err = clientBuildError(ERR_ACCESS_DENIED, HTTP_FORBIDDEN, NULL, http->getConn()->clientConnection->remote, http->request); - createStoreEntry(r->method, request_flags()); + createStoreEntry(r->method, RequestFlags()); errorAppendEntry(http->storeEntry(), err); triggerInitialStoreRead(); return; @@ -994,7 +995,7 @@ clientReplyContext::purgeDoPurgeHead(StoreEntry *newEntry) /* FIXME: This doesn't need to go through the store. Simply * push down the client chain */ - createStoreEntry(http->request->method, request_flags()); + createStoreEntry(http->request->method, RequestFlags()); triggerInitialStoreRead(); @@ -1009,7 +1010,7 @@ clientReplyContext::traceReply(clientStreamNode * node) { clientStreamNode *nextNode = (clientStreamNode *)node->node.next->data; StoreIOBuffer localTempBuffer; - createStoreEntry(http->request->method, request_flags()); + createStoreEntry(http->request->method, RequestFlags()); localTempBuffer.offset = nextNode->readBuffer.offset + headers_sz; localTempBuffer.length = nextNode->readBuffer.length; localTempBuffer.data = nextNode->readBuffer.data; @@ -1895,7 +1896,7 @@ clientReplyContext::sendNotModified() HttpReply *const temprep = e->getReply()->make304(); http->logType = LOG_TCP_IMS_HIT; removeClientStoreReference(&sc, http); - createStoreEntry(http->request->method, request_flags()); + createStoreEntry(http->request->method, RequestFlags()); e = http->storeEntry(); // Copy timestamp from the original entry so the 304 // reply has a meaningful Age: header. @@ -2157,7 +2158,7 @@ clientReplyContext::sendMoreData (StoreIOBuffer result) /* Using this breaks the client layering just a little! */ void -clientReplyContext::createStoreEntry(const HttpRequestMethod& m, request_flags reqFlags) +clientReplyContext::createStoreEntry(const HttpRequestMethod& m, RequestFlags reqFlags) { assert(http != NULL); /* diff --git a/src/client_side_reply.h b/src/client_side_reply.h index a063994001..155b814d3e 100644 --- a/src/client_side_reply.h +++ b/src/client_side_reply.h @@ -31,11 +31,12 @@ #ifndef SQUID_CLIENTSIDEREPLY_H #define SQUID_CLIENTSIDEREPLY_H -#include "RefCount.h" -#include "HttpHeader.h" +#include "client_side_request.h" #include "clientStream.h" +#include "HttpHeader.h" +#include "RefCount.h" +#include "RequestFlags.h" #include "StoreClient.h" -#include "client_side_request.h" class ErrorState; #include "ip/forward.h" @@ -82,7 +83,7 @@ public: #endif /// creates a store entry for the reply and appends err to it void setReplyToError(const HttpRequestMethod& method, ErrorState *err); - void createStoreEntry(const HttpRequestMethod& m, request_flags flags); + void createStoreEntry(const HttpRequestMethod& m, RequestFlags flags); void removeStoreReference(store_client ** scp, StoreEntry ** ep); void removeClientStoreReference(store_client **scp, ClientHttpRequest *http); void startError(ErrorState * err); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index 8bce891ae1..7731e9d313 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1106,7 +1106,7 @@ clientInterpretRequestHeaders(ClientHttpRequest * http) request->range = req_hdr->getRange(); if (request->range) { - request->flags.range = 1; + request->flags.setRanged(); clientStreamNode *node = (clientStreamNode *)http->client_stream.tail->data; /* XXX: This is suboptimal. We should give the stream the range set, * and thereby let the top of the stream set the offset when the diff --git a/src/http.cc b/src/http.cc index 73ffa217da..6d0ed19a77 100644 --- a/src/http.cc +++ b/src/http.cc @@ -1652,7 +1652,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request, /* pretend it's not a range request */ delete request->range; request->range = NULL; - request->flags.range = 0; + request->flags.clearRanged(); } /* append Via */ diff --git a/src/icmp/net_db.cc b/src/icmp/net_db.cc index f0b0c3b30a..8d199d1542 100644 --- a/src/icmp/net_db.cc +++ b/src/icmp/net_db.cc @@ -1335,7 +1335,7 @@ netdbExchangeStart(void *data) assert(NULL != ex->r); ex->r->http_ver = HttpVersion(1,1); ex->connstate = STATE_HEADER; - ex->e = storeCreateEntry(uri, uri, request_flags(), METHOD_GET); + ex->e = storeCreateEntry(uri, uri, RequestFlags(), METHOD_GET); ex->buf_sz = NETDB_REQBUF_SZ; assert(NULL != ex->e); ex->sc = storeClientListAdd(ex->e, ex); diff --git a/src/mgr/ActionParams.h b/src/mgr/ActionParams.h index 095d134315..75ab674e51 100644 --- a/src/mgr/ActionParams.h +++ b/src/mgr/ActionParams.h @@ -9,6 +9,7 @@ #include "HttpRequestMethod.h" #include "ipc/forward.h" #include "mgr/QueryParams.h" +#include "RequestFlags.h" namespace Mgr { @@ -26,7 +27,7 @@ public: /* details of the client HTTP request that caused the action */ String httpUri; ///< HTTP request URI _method_t httpMethod; ///< HTTP request method - request_flags httpFlags; ///< HTTP request flags + RequestFlags httpFlags; ///< HTTP request flags String httpOrigin; ///< HTTP Origin: header (if any) /* action parameters extracted from the client HTTP request */ diff --git a/src/mime.cc b/src/mime.cc index 0d49ba7f58..2d14023fd2 100644 --- a/src/mime.cc +++ b/src/mime.cc @@ -43,6 +43,7 @@ #include "MemBuf.h" #include "mime.h" #include "MemObject.h" +#include "RequestFlags.h" #include "SquidConfig.h" #include "Store.h" #include "StoreClient.h" @@ -431,7 +432,7 @@ MimeIcon::created (StoreEntry *newEntry) int n; - request_flags flags; + RequestFlags flags; struct stat sb; diff --git a/src/neighbors.cc b/src/neighbors.cc index 0ef005c88c..3677cf4353 100644 --- a/src/neighbors.cc +++ b/src/neighbors.cc @@ -54,6 +54,7 @@ #include "neighbors.h" #include "PeerDigest.h" #include "PeerSelectState.h" +#include "RequestFlags.h" #include "SquidConfig.h" #include "SquidMath.h" #include "SquidTime.h" @@ -1375,7 +1376,7 @@ peerCountMcastPeersStart(void *data) snprintf(url, MAX_URL, "http://"); p->in_addr.ToURL(url+7, MAX_URL -8 ); strcat(url, "/"); - fake = storeCreateEntry(url, url, request_flags(), METHOD_GET); + fake = storeCreateEntry(url, url, RequestFlags(), METHOD_GET); HttpRequest *req = HttpRequest::CreateFromUrl(url); psstate = new ps_state; psstate->request = HTTPMSGLOCK(req); diff --git a/src/store.cc b/src/store.cc index 2e2213f808..941c2c0054 100644 --- a/src/store.cc +++ b/src/store.cc @@ -48,6 +48,7 @@ #include "mgr/StoreIoAction.h" #include "profiler/Profiler.h" #include "repl_modules.h" +#include "RequestFlags.h" #include "SquidConfig.h" #include "SquidTime.h" #include "Stack.h" @@ -817,7 +818,7 @@ StoreEntry::setPublicKey() } StoreEntry * -storeCreateEntry(const char *url, const char *log_url, request_flags flags, const HttpRequestMethod& method) +storeCreateEntry(const char *url, const char *log_url, const RequestFlags &flags, const HttpRequestMethod& method) { StoreEntry *e = NULL; MemObject *mem = NULL; @@ -1966,7 +1967,7 @@ StoreEntry::hasIfNoneMatchEtag(const HttpRequest &request) const { const String reqETags = request.header.getList(HDR_IF_NONE_MATCH); // weak comparison is allowed only for HEAD or full-body GET requests - const bool allowWeakMatch = !request.flags.range && + const bool allowWeakMatch = !request.flags.isRanged() && (request.method == METHOD_GET || request.method == METHOD_HEAD); return hasOneOfEtags(reqETags, allowWeakMatch); } diff --git a/src/store_digest.cc b/src/store_digest.cc index 784fbbe2b1..b1133c83ac 100644 --- a/src/store_digest.cc +++ b/src/store_digest.cc @@ -377,7 +377,7 @@ storeDigestRebuildStep(void *datanotused) static void storeDigestRewriteStart(void *datanotused) { - request_flags flags; + RequestFlags flags; char *url; StoreEntry *e; diff --git a/src/structs.h b/src/structs.h index af8a4b7b4e..a47763582e 100644 --- a/src/structs.h +++ b/src/structs.h @@ -235,75 +235,6 @@ public: Http, Ftp, Gopher; }; -struct request_flags { - request_flags(): range(0),nocache(0),ims(0),auth(0),cachable(0),hierarchical(0),loopdetect(0),proxy_keepalive(0),proxying(0),refresh(0),redirected(0),need_validation(0),fail_on_validation_err(0),stale_if_hit(0),accelerated(0),ignore_cc(0),intercepted(0),hostVerified(0),spoof_client_ip(0),internal(0),internalclient(0),must_keepalive(0),pinned(0),canRePin(0),chunked_reply(0),stream_error(0),sslPeek(0),sslBumped(0),destinationIPLookedUp_(0) { -#if USE_HTTP_VIOLATIONS - nocache_hack = 0; -#endif -#if FOLLOW_X_FORWARDED_FOR - done_follow_x_forwarded_for = 0; -#endif /* FOLLOW_X_FORWARDED_FOR */ - } - - unsigned int range:1; - unsigned int nocache:1; ///< whether the response to this request may be READ from cache - unsigned int ims:1; - unsigned int auth:1; - unsigned int cachable:1; ///< whether the response to thie request may be stored in the cache - unsigned int hierarchical:1; - unsigned int loopdetect:1; - unsigned int proxy_keepalive:1; -unsigned int proxying: - 1; /* this should be killed, also in httpstateflags */ - unsigned int refresh:1; - unsigned int redirected:1; - unsigned int need_validation:1; - unsigned int fail_on_validation_err:1; ///< whether we should fail if validation fails - unsigned int stale_if_hit:1; ///< reply is stale if it is a hit -#if USE_HTTP_VIOLATIONS - unsigned int nocache_hack:1; /* for changing/ignoring no-cache requests */ -#endif - unsigned int accelerated:1; - unsigned int ignore_cc:1; - unsigned int intercepted:1; ///< intercepted request - unsigned int hostVerified:1; ///< whether the Host: header passed verification - unsigned int spoof_client_ip:1; /**< spoof client ip if possible */ - unsigned int internal:1; - unsigned int internalclient:1; - unsigned int must_keepalive:1; - unsigned int connection_auth:1; /** Request wants connection oriented auth */ - unsigned int connection_auth_disabled:1; /** Connection oriented auth can not be supported */ - unsigned int connection_proxy_auth:1; /** Request wants connection oriented auth */ - unsigned int pinned:1; /* Request sent on a pinned connection */ - unsigned int canRePin:1; ///< OK to reopen a failed pinned connection - unsigned int auth_sent:1; /* Authentication forwarded */ - unsigned int no_direct:1; /* Deny direct forwarding unless overriden by always_direct. Used in accelerator mode */ - unsigned int chunked_reply:1; /**< Reply with chunked transfer encoding */ - unsigned int stream_error:1; /**< Whether stream error has occured */ - unsigned int sslPeek:1; ///< internal ssl-bump request to get server cert - unsigned int sslBumped:1; /**< ssl-bumped request*/ - - // When adding new flags, please update cloneAdaptationImmune() as needed. - - bool resetTCP() const; - void setResetTCP(); - void clearResetTCP(); - void destinationIPLookupCompleted(); - bool destinationIPLookedUp() const; - - // returns a partial copy of the flags that includes only those flags - // that are safe for a related (e.g., ICAP-adapted) request to inherit - request_flags cloneAdaptationImmune() const; - -#if FOLLOW_X_FORWARDED_FOR - unsigned int done_follow_x_forwarded_for; -#endif /* FOLLOW_X_FORWARDED_FOR */ -private: - - unsigned int reset_tcp:1; - unsigned int destinationIPLookedUp_:1; -}; - #if USE_SSL struct _sslproxy_cert_sign { int alg; diff --git a/src/tests/stub_store.cc b/src/tests/stub_store.cc index 136debf5d8..bcc1f6a761 100644 --- a/src/tests/stub_store.cc +++ b/src/tests/stub_store.cc @@ -1,4 +1,5 @@ #include "squid.h" +#include "RequestFlags.h" #define STUB_API "store.cc" #include "tests/STUB.h" @@ -115,7 +116,7 @@ void storeEntryReplaceObject(StoreEntry *, HttpReply *) STUB SQUIDCEXTERN StoreEntry *storeGetPublic(const char *uri, const HttpRequestMethod& method) STUB_RETVAL(NULL) SQUIDCEXTERN StoreEntry *storeGetPublicByRequest(HttpRequest * request) STUB_RETVAL(NULL) SQUIDCEXTERN StoreEntry *storeGetPublicByRequestMethod(HttpRequest * request, const HttpRequestMethod& method) STUB_RETVAL(NULL) -SQUIDCEXTERN StoreEntry *storeCreateEntry(const char *, const char *, request_flags, const HttpRequestMethod&) STUB_RETVAL(NULL) +extern StoreEntry *storeCreateEntry(const char *, const char *, const RequestFlags &, const HttpRequestMethod&) STUB_RETVAL(NULL) SQUIDCEXTERN void storeInit(void) STUB SQUIDCEXTERN void storeConfigure(void) STUB SQUIDCEXTERN void storeFreeMemory(void) STUB diff --git a/src/tests/testCoss.cc b/src/tests/testCoss.cc index ba48d2ee10..d2cabb711f 100644 --- a/src/tests/testCoss.cc +++ b/src/tests/testCoss.cc @@ -9,6 +9,7 @@ #include "MemObject.h" #include "HttpHeader.h" #include "HttpReply.h" +#include "RequestFlags.h" #include "StoreFileSystem.h" #include "testStoreSupport.h" #include "SquidConfig.h" @@ -188,7 +189,7 @@ testCoss::testCossSearch() /* add an entry */ { /* Create "vary" base object */ - request_flags flags; + RequestFlags flags; flags.cachable = 1; StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET); HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const diff --git a/src/tests/testNull.cc b/src/tests/testNull.cc index eb9cba8af6..0e2bcf59d8 100644 --- a/src/tests/testNull.cc +++ b/src/tests/testNull.cc @@ -9,6 +9,7 @@ #include "MemObject.h" #include "HttpHeader.h" #include "HttpReply.h" +#include "RequestFlags.h" #include "SquidConfig.h" #include "StoreFileSystem.h" #include "testStoreSupport.h" @@ -159,7 +160,7 @@ testNull::testNullSearch() /* add an entry */ { /* Create "vary" base object */ - request_flags flags; + RequestFlags flags; flags.cachable = 1; StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET); /* We are allowed to do this typecast */ diff --git a/src/tests/testRock.cc b/src/tests/testRock.cc index de5167dd2b..9ba5666657 100644 --- a/src/tests/testRock.cc +++ b/src/tests/testRock.cc @@ -8,6 +8,7 @@ #include "HttpReply.h" #include "Mem.h" #include "MemObject.h" +#include "RequestFlags.h" #include "SquidConfig.h" #include "Store.h" #include "StoreFileSystem.h" @@ -163,7 +164,7 @@ testRock::storeInit() StoreEntry * testRock::createEntry(const int i) { - request_flags flags; + RequestFlags flags; flags.cachable = 1; char url[64]; snprintf(url, sizeof(url), "dummy url %i", i); diff --git a/src/tests/testUfs.cc b/src/tests/testUfs.cc index 87a99767f7..1213414642 100644 --- a/src/tests/testUfs.cc +++ b/src/tests/testUfs.cc @@ -8,6 +8,7 @@ #include "HttpReply.h" #include "Mem.h" #include "MemObject.h" +#include "RequestFlags.h" #include "SquidConfig.h" #include "Store.h" #include "SwapDir.h" @@ -140,7 +141,7 @@ testUfs::testUfsSearch() /* add an entry */ { /* Create "vary" base object */ - request_flags flags; + RequestFlags flags; flags.cachable = 1; StoreEntry *pe = storeCreateEntry("dummy url", "dummy log url", flags, METHOD_GET); HttpReply *rep = (HttpReply *) pe->getReply(); // bypass const diff --git a/src/urn.cc b/src/urn.cc index ab64ff7df3..c5c5964042 100644 --- a/src/urn.cc +++ b/src/urn.cc @@ -40,6 +40,7 @@ #include "icmp/net_db.h" #include "MemBuf.h" #include "mime_header.h" +#include "RequestFlags.h" #include "SquidTime.h" #include "Store.h" #include "StoreClient.h" @@ -256,7 +257,7 @@ UrnState::created(StoreEntry *newEntry) urlres_e = newEntry; if (urlres_e->isNull()) { - urlres_e = storeCreateEntry(urlres, urlres, request_flags(), METHOD_GET); + urlres_e = storeCreateEntry(urlres, urlres, RequestFlags(), METHOD_GET); sc = storeClientListAdd(urlres_e, this); FwdState::fwdStart(Comm::ConnectionPointer(), urlres_e, urlres_r); } else {