]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
RequestFlags: added missing default values, made all data fields unconditional, added...
authorFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 12 Sep 2012 11:19:27 +0000 (13:19 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Wed, 12 Sep 2012 11:19:27 +0000 (13:19 +0200)
src/RequestFlags.h
src/auth/negotiate/UserRequest.cc
src/auth/negotiate/auth_negotiate.cc
src/auth/ntlm/UserRequest.cc
src/auth/ntlm/auth_ntlm.cc
src/client_side_reply.cc
src/client_side_request.cc
src/forward.cc
src/http.cc

index f9f21c442423f401437e5d51adb742e05bb613c6..1ba2dc814f86d27088b6dc4263af6e5dd526f337 100644 (file)
@@ -38,19 +38,15 @@ public:
         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),
+        fail_on_validation_err(0), stale_if_hit(0), nocache_hack(0), accelerated(0),
         ignore_cc(0), intercepted(0), hostVerified(0), spoof_client_ip(0),
-        internal(0), internalclient(0), must_keepalive(0), pinned(false),
+        internal(0), internalclient(false), must_keepalive(false), connection_auth_wanted(false), connection_auth_disabled(false), connection_proxy_auth(false), pinned_(false),
         canRePin_(false), authSent_(false), noDirect_(false), chunkedReply_(false),
         streamError_(false), sslPeek_(false),
         doneFollowXForwardedFor(!FOLLOW_X_FORWARDED_FOR),
         sslBumped_(false), destinationIPLookedUp_(false), resetTCP_(false),
         isRanged_(false)
-    {
-#if USE_HTTP_VIOLATIONS
-        nocache_hack = 0;
-#endif
-    }
+    {}
 
     unsigned int nocache :1; ///< whether the response to this request may be READ from cache
     unsigned int ims :1;
@@ -65,22 +61,14 @@ public:
     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 */
+    /* for changing/ignoring no-cache requests. Unused unless USE_HTTP_VIOLATIONS */
     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 */
 
     // When adding new flags, please update cloneAdaptationImmune() as needed.
     bool resetTCP() const;
@@ -129,11 +117,32 @@ public:
     bool canRePin() const { return canRePin_; }
     void allowRepinning() { canRePin_=true; }
 
-    void markPinned() { pinned = true; }
-    void clearPinned() { pinned = false; }
-    bool connPinned() const { return pinned; }
+    void markPinned() { pinned_ = true; }
+    void clearPinned() { pinned_ = false; }
+    bool pinned() const { return pinned_; }
+
+    //XXX: oddly this is set in client_side_request.cc, but never checked.
+    bool wantConnectionProxyAuth() { return connection_proxy_auth; }
+    void requestConnectionProxyAuth() { connection_proxy_auth=true; }
+
+    void disableConnectionAuth() { connection_auth_disabled=true; }
+    bool connectionAuthDisabled() { return connection_auth_disabled; }
+
+    void wantConnectionAuth() { connection_auth_wanted=true; }
+    bool connectionAuthWanted() { return connection_auth_wanted; }
+
+    void setMustKeepalive() { must_keepalive = true; }
+    bool mustKeepalive() { return must_keepalive; }
+
+    //XXX: oddly this is set in client_side_request.cc but never checked.
+    void setInternalClient() { internalclient=true;}
 private:
-    bool pinned :1; ///< Request sent on a pinned connection
+    bool internalclient :1;
+    bool must_keepalive :1;
+    bool connection_auth_wanted :1; /** Request wants connection oriented auth */
+    bool connection_auth_disabled :1; ///< Connection oriented auth can't be supported
+    bool connection_proxy_auth :1; ///< Request wants connection oriented auth
+    bool pinned_ :1; ///< Request sent on a pinned connection
     bool canRePin_ :1; ///< OK to reopen a failed pinned connection
     bool authSent_ :1; ///< Authentication was forwarded
     /** Deny direct forwarding unless overriden by always_direct.
index ac4e71cc593c9d575e1d6824740f108c952d1a6a..8ea4d1a7d6d12ed71badda02d84d9e84d1245eaa 100644 (file)
@@ -286,7 +286,7 @@ Auth::Negotiate::UserRequest::HandleReply(void *data, void *lastserver, char *re
             ++arg;
         }
         safe_free(lm_request->server_blob);
-        lm_request->request->flags.must_keepalive = 1;
+        lm_request->request->flags.setMustKeepalive();
         if (lm_request->request->flags.proxy_keepalive) {
             lm_request->server_blob = xstrdup(blob);
             auth_user_request->user()->credentials(Auth::Handshake);
index 556f9c072ca6e32059bef958e9a62a6130ed2d2d..c36e7dc553e7c83aeb69c6d5d0169425b14cf3a5 100644 (file)
@@ -218,7 +218,7 @@ Auth::Negotiate::Config::fixHeader(Auth::UserRequest::Pointer auth_user_request,
         return;
 
     /* Need keep-alive */
-    if (!request->flags.proxy_keepalive && request->flags.must_keepalive)
+    if (!request->flags.proxy_keepalive && request->flags.mustKeepalive())
         return;
 
     /* New request, no user details */
index bd2b4ffe13c93317a37f624b5ff747ebac9e79c7..1a99bade69f1aff48e7082e82d139a7967dc87be 100644 (file)
@@ -269,7 +269,7 @@ Auth::Ntlm::UserRequest::HandleReply(void *data, void *lastserver, char *reply)
     if (strncasecmp(reply, "TT ", 3) == 0) {
         /* we have been given a blob to send to the client */
         safe_free(lm_request->server_blob);
-        lm_request->request->flags.must_keepalive = 1;
+        lm_request->request->flags.setMustKeepalive();
         if (lm_request->request->flags.proxy_keepalive) {
             lm_request->server_blob = xstrdup(blob);
             auth_user_request->user()->credentials(Auth::Handshake);
index 8282cc3c3d4d82aac5d159aa390a382bb60f911d..7c4d8c0df2208abed8e24486b9924b2741c51320 100644 (file)
@@ -205,7 +205,7 @@ Auth::Ntlm::Config::fixHeader(Auth::UserRequest::Pointer auth_user_request, Http
         return;
 
     /* Need keep-alive */
-    if (!request->flags.proxy_keepalive && request->flags.must_keepalive)
+    if (!request->flags.proxy_keepalive && request->flags.mustKeepalive())
         return;
 
     /* New request, no user details */
index 9bc6519e2bc15a4d609673f3bb060aa2cba3b9a3..62a958819868bcc3249258599dcf588fe27faf45 100644 (file)
@@ -1401,11 +1401,11 @@ clientReplyContext::buildReplyHeader()
                         ||
                         (strncasecmp(value, "Kerberos", 8) == 0 &&
                          (value[8] == '\0' || value[8] == ' '))) {
-                    if (request->flags.connection_auth_disabled) {
+                    if (request->flags.connectionAuthDisabled()) {
                         hdr->delAt(pos, connection_auth_blocked);
                         continue;
                     }
-                    request->flags.must_keepalive = 1;
+                    request->flags.setMustKeepalive();
                     if (!request->flags.accelerated && !request->flags.intercepted) {
                         httpHeaderPutStrf(hdr, HDR_PROXY_SUPPORT, "Session-Based-Authentication");
                         /*
@@ -1459,22 +1459,22 @@ clientReplyContext::buildReplyHeader()
                                      (request->http_ver >= HttpVersion(1, 1));
 
     /* Check whether we should send keep-alive */
-    if (!Config.onoff.error_pconns && reply->sline.status >= 400 && !request->flags.must_keepalive) {
+    if (!Config.onoff.error_pconns && reply->sline.status >= 400 && !request->flags.mustKeepalive()) {
         debugs(33, 3, "clientBuildReplyHeader: Error, don't keep-alive");
         request->flags.proxy_keepalive = 0;
-    } else if (!Config.onoff.client_pconns && !request->flags.must_keepalive) {
+    } else if (!Config.onoff.client_pconns && !request->flags.mustKeepalive()) {
         debugs(33, 2, "clientBuildReplyHeader: Connection Keep-Alive not requested by admin or client");
         request->flags.proxy_keepalive = 0;
     } else if (request->flags.proxy_keepalive && shutting_down) {
         debugs(88, 3, "clientBuildReplyHeader: Shutting down, don't keep-alive.");
         request->flags.proxy_keepalive = 0;
-    } else if (request->flags.connection_auth && !reply->keep_alive) {
+    } else if (request->flags.connectionAuthWanted() && !reply->keep_alive) {
         debugs(33, 2, "clientBuildReplyHeader: Connection oriented auth but server side non-persistent");
         request->flags.proxy_keepalive = 0;
     } else if (reply->bodySize(request->method) < 0 && !maySendChunkedReply) {
         debugs(88, 3, "clientBuildReplyHeader: can't keep-alive, unknown body size" );
         request->flags.proxy_keepalive = 0;
-    } else if (fdUsageHigh()&& !request->flags.must_keepalive) {
+    } else if (fdUsageHigh()&& !request->flags.mustKeepalive()) {
         debugs(88, 3, "clientBuildReplyHeader: Not many unused FDs, can't keep-alive");
         request->flags.proxy_keepalive = 0;
     } else if (request->flags.sslBumped() && !reply->persistent()) {
index a3ebc67cc1fd337df9e8cb621d24c01061909ce8..b7d51f348b403ead86d4c2b378159233418f93de 100644 (file)
@@ -389,7 +389,7 @@ clientBeginRequest(const HttpRequestMethod& method, char const *url, CSCB * stre
      */
     request->flags.accelerated = http->flags.accel;
 
-    request->flags.internalclient = 1;
+    request->flags.setInternalClient();
 
     /* this is an internally created
      * request, not subject to acceleration
@@ -981,14 +981,15 @@ clientCheckPinning(ClientHttpRequest * http)
     if (!http_conn)
         return;
 
-    request->flags.connection_auth_disabled = http_conn->port->connection_auth_disabled;
-    if (!request->flags.connection_auth_disabled) {
+    if (http_conn->port->connection_auth_disabled)
+        request->flags.disableConnectionAuth();
+    if (!request->flags.connectionAuthDisabled()) {
         if (Comm::IsConnOpen(http_conn->pinning.serverConnection)) {
             if (http_conn->pinning.auth) {
-                request->flags.connection_auth = 1;
+                request->flags.wantConnectionAuth();
                 request->flags.auth = 1;
             } else {
-                request->flags.connection_proxy_auth = 1;
+                request->flags.requestConnectionProxyAuth();
             }
             // These should already be linked correctly.
             assert(request->clientConnectionManager == http_conn);
@@ -996,11 +997,11 @@ clientCheckPinning(ClientHttpRequest * http)
     }
 
     /* check if connection auth is used, and flag as candidate for pinning
-     * in such case.
+     * in such case.;
      * Note: we may need to set flags.connection_auth even if the connection
      * is already pinned if it was pinned earlier due to proxy auth
      */
-    if (!request->flags.connection_auth) {
+    if (!request->flags.connectionAuthWanted()) {
         if (req_hdr->has(HDR_AUTHORIZATION) || req_hdr->has(HDR_PROXY_AUTHORIZATION)) {
             HttpHeaderPos pos = HttpHeaderInitPos;
             HttpHeaderEntry *e;
@@ -1014,10 +1015,10 @@ clientCheckPinning(ClientHttpRequest * http)
                             ||
                             strncasecmp(value, "Kerberos ", 9) == 0) {
                         if (e->id == HDR_AUTHORIZATION) {
-                            request->flags.connection_auth = 1;
+                            request->flags.wantConnectionAuth();
                             may_pin = 1;
                         } else {
-                            request->flags.connection_proxy_auth = 1;
+                            request->flags.requestConnectionProxyAuth();
                             may_pin = 1;
                         }
                     }
index 0442a4b2a8e47ed6125a86c6c293876acd4d666b..526986ba372a248dde06d24b60b9648870060e49 100644 (file)
@@ -886,7 +886,7 @@ FwdState::connectDone(const Comm::ConnectionPointer &conn, comm_err_t status, in
     }
 
 #if USE_SSL
-    if (!request->flags.connPinned() || rePin) {
+    if (!request->flags.pinned() || rePin) {
         if ((serverConnection()->getPeer() && serverConnection()->getPeer()->use_ssl) ||
                 (!serverConnection()->getPeer() && request->protocol == AnyP::PROTO_HTTPS) ||
                 request->flags.sslPeek()) {
index f811b115c95d05f12a24b361d285bdc9adc5b06c..dd98063827edabb85f961259db7de095529884c3 100644 (file)
@@ -716,7 +716,7 @@ HttpStateData::processReplyHeader()
     }
 
     if (!peerSupportsConnectionPinning())
-        request->flags.connection_auth_disabled = 1;
+        request->flags.disableConnectionAuth();
 
     HttpReply *vrep = setVirginReply(newrep);
     flags.headers_parsed = 1;
@@ -837,7 +837,7 @@ bool HttpStateData::peerSupportsConnectionPinning() const
         return true;
 
     /*if the connections it is already pinned it is OK*/
-    if (request->flags.connPinned())
+    if (request->flags.pinned())
         return true;
 
     /*Allow pinned connections only if the Proxy-support header exists in
@@ -1389,15 +1389,15 @@ HttpStateData::processReplyBody()
             if (request->flags.spoof_client_ip)
                 client_addr = request->client_addr;
 
-            if (request->flags.connPinned()) {
+            if (request->flags.pinned()) {
                 ispinned = true;
-            } else if (request->flags.connection_auth && request->flags.authSent()) {
+            } else if (request->flags.connectionAuthWanted() && request->flags.authSent()) {
                 ispinned = true;
             }
 
             if (request->pinnedConnection() && ispinned) {
                 request->pinnedConnection()->pinConnection(serverConnection, request, _peer,
-                        (request->flags.connection_auth != 0));
+                        request->flags.connectionAuthWanted());
             } else {
                 fwd->pconnPush(serverConnection, request->peer_host ? request->peer_host : request->GetHost());
             }
@@ -1988,7 +1988,7 @@ HttpStateData::decideIfWeDoRanges (HttpRequest * request)
     int64_t roffLimit = request->getRangeOffsetLimit();
 
     if (NULL == request->range || !request->flags.cachable
-            || request->range->offsetLimitExceeded(roffLimit) || request->flags.connection_auth)
+            || request->range->offsetLimitExceeded(roffLimit) || request->flags.connectionAuthWanted())
         result = false;
 
     debugs(11, 8, "decideIfWeDoRanges: range specs: " <<
@@ -2021,7 +2021,7 @@ HttpStateData::buildRequestPrefix(MemBuf * mb)
         Packer p;
         httpBuildRequestHeader(request, entry, fwd->al, &hdr, flags);
 
-        if (request->flags.connPinned() && request->flags.connection_auth)
+        if (request->flags.pinned() && request->flags.connectionAuthWanted())
             request->flags.markAuthSent();
         else if (hdr.has(HDR_AUTHORIZATION))
             request->flags.markAuthSent();
@@ -2091,7 +2091,7 @@ HttpStateData::sendRequest()
     /*
      * Is keep-alive okay for all request methods?
      */
-    if (request->flags.must_keepalive)
+    if (request->flags.mustKeepalive())
         flags.keepalive = 1;
     else if (!Config.onoff.server_pconns)
         flags.keepalive = 0;