From: wessels <> Date: Thu, 12 Jan 2006 04:05:50 +0000 (+0000) Subject: Fixed a couple of bugs with ClientHttpRequest::doCallouts() X-Git-Tag: SQUID_3_0_PRE4~372 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=57abaac031ad603331e6b5a7c99de482f2a5f6c5;p=thirdparty%2Fsquid.git Fixed a couple of bugs with ClientHttpRequest::doCallouts() - The "no_cache" rule check was never happening because flags.cachable was always 0 at that point. clientInterpretRequestHeaders() must be called before doing the "no_cache" checks. - ClientRequestContext::checkNoCache had an extra cbdataReference() call which caused a cbdata leak. - Converted the *_done flags to bool (instead of single-bit ints). --- diff --git a/src/ClientRequestContext.h b/src/ClientRequestContext.h index 85ff1e75dd..40fa16bf28 100644 --- a/src/ClientRequestContext.h +++ b/src/ClientRequestContext.h @@ -29,19 +29,15 @@ public: ACLChecklist *acl_checklist; /* need ptr back so we can unreg if needed */ int redirect_state; -int http_access_done: - 1; + bool http_access_done; #if ICAP_CLIENT -int icap_acl_check_done: - 1; + bool icap_acl_check_done; #endif -int redirect_done: - 1; - -int no_cache_done: - 1; + bool redirect_done; + bool int no_cache_done; + bool interpreted_req_hdrs; private: CBDATA_CLASS(ClientRequestContext); diff --git a/src/client_side_request.cc b/src/client_side_request.cc index db5608f8c1..e78be14676 100644 --- a/src/client_side_request.cc +++ b/src/client_side_request.cc @@ -1,6 +1,6 @@ /* - * $Id: client_side_request.cc,v 1.55 2005/12/20 23:22:29 wessels Exp $ + * $Id: client_side_request.cc,v 1.56 2006/01/11 21:05:50 wessels Exp $ * * DEBUG: section 85 Client-side Request Routines * AUTHOR: Robert Collins (Originally Duane Wessels in client_side.c) @@ -117,9 +117,10 @@ ClientRequestContext::~ClientRequestContext() ClientRequestContext::ClientRequestContext(ClientHttpRequest *anHttp) : http(anHttp), acl_checklist (NULL), redirect_state (REDIRECT_NONE) { (void) cbdataReference(http); - http_access_done = 0; - redirect_done = 0; - no_cache_done = 0; + http_access_done = false; + redirect_done = false; + no_cache_done = false; + interpreted_req_hdrs = false; } CBDATA_CLASS_INIT(ClientHttpRequest); @@ -344,11 +345,11 @@ clientBeginRequest(method_t method, char const *url, CSCB * streamcallback, /* optional - skip the access check ? */ http->calloutContext = new ClientRequestContext(http); - http->calloutContext->http_access_done = 0; + http->calloutContext->http_access_done = false; - http->calloutContext->redirect_done = 1; + http->calloutContext->redirect_done = true; - http->calloutContext->no_cache_done = 1; + http->calloutContext->no_cache_done = true; http->doCallouts(); @@ -887,7 +888,7 @@ void ClientRequestContext::checkNoCache() { acl_checklist = clientAclChecklistCreate(Config.accessList.noCache, http); - acl_checklist->nonBlockingCheck(checkNoCacheDoneWrapper, cbdataReference(this)); + acl_checklist->nonBlockingCheck(checkNoCacheDoneWrapper, this); } static void @@ -1036,14 +1037,14 @@ ClientHttpRequest::doCallouts() assert(calloutContext); if (!calloutContext->http_access_done) { - calloutContext->http_access_done = 1; + calloutContext->http_access_done = true; calloutContext->clientAccessCheck(); return; } #if ICAP_CLIENT if (TheICAPConfig.onoff && !calloutContext->icap_acl_check_done) { - calloutContext->icap_acl_check_done = 1; + calloutContext->icap_acl_check_done = true; calloutContext->icapAccessCheck(); return; } @@ -1051,7 +1052,7 @@ ClientHttpRequest::doCallouts() #endif if (!calloutContext->redirect_done) { - calloutContext->redirect_done = 1; + calloutContext->redirect_done = true; assert(calloutContext->redirect_state == REDIRECT_NONE); if (Config.Program.redirect) { @@ -1061,8 +1062,13 @@ ClientHttpRequest::doCallouts() } } + if (!calloutContext->interpreted_req_hdrs) { + calloutContext->interpreted_req_hdrs = 1; + clientInterpretRequestHeaders(this); + } + if (!calloutContext->no_cache_done) { - calloutContext->no_cache_done = 1; + calloutContext->no_cache_done = true; if (Config.accessList.noCache && request->flags.cachable) { calloutContext->checkNoCache(); @@ -1073,7 +1079,6 @@ ClientHttpRequest::doCallouts() cbdataReferenceDone(calloutContext->http); delete calloutContext; calloutContext = NULL; - clientInterpretRequestHeaders(this); #if HEADERS_LOG headersLog(0, 1, request->method, request);