#if USE_ADAPTATION
#include "adaptation/AccessCheck.h"
-#include "ICAP/ICAPConfig.h"
-extern ICAPConfig TheICAPConfig;
+#include "adaptation/Service.h"
#endif
ServerStateData::ServerStateData(FwdState *theFwdState): AsyncJob("ServerStateData"),requestSender(NULL)
sendBodyIsTooLargeError();
return;
}
- // TODO: Should we check received5CBodyTooLarge on the server-side as well?
+ // TODO: Should we check receivedBodyTooLarge on the server-side as well?
startedAdaptation = startAdaptation(service, originalRequest());
ServerStateData::adaptOrFinalizeReply()
{
#if USE_ADAPTATION
-
- if (TheICAPConfig.onoff) {
- Adaptation::AccessCheck *check = new Adaptation::AccessCheck(
- Adaptation::methodRespmod, ICAP::pointPreCache,
- request, virginReply(), adaptationAclCheckDoneWrapper, this);
-
- adaptationAccessCheckPending = true;
- check->check(); // will eventually delete self
+ // TODO: merge with client side and return void to hide the on/off logic?
+ // The callback can be called with a NULL service if adaptation is off.
+ adaptationAccessCheckPending = Adaptation::AccessCheck::Start(
+ Adaptation::methodRespmod, Adaptation::pointPreCache,
+ request, virginReply(), adaptationAclCheckDoneWrapper, this);
+ if (adaptationAccessCheckPending)
return;
- }
-
#endif
setFinalReply(virginReply());
#include "adaptation/Service.h"
#include "adaptation/ServiceGroups.h"
#include "adaptation/AccessRule.h"
+#include "adaptation/Config.h"
#include "adaptation/AccessCheck.h"
cbdata_type Adaptation::AccessCheck::CBDATA_AccessCheck = CBDATA_UNKNOWN;
+bool
+Adaptation::AccessCheck::Start(Method method, VectPoint vp,
+ HttpRequest *req, HttpReply *rep, AccessCheckCallback *cb, void *cbdata) {
+
+ if (Config::Enabled) {
+ // the new check will call the callback and delete self, eventually
+ AccessCheck *check = new AccessCheck(method, vp, req, rep, cb, cbdata);
+ check->check();
+ return true;
+ }
+
+ debugs(83, 3, HERE << "adaptation off, skipping");
+ return false;
+}
+
Adaptation::AccessCheck::AccessCheck(Method aMethod,
VectPoint aPoint,
HttpRequest *aReq,
// checks adaptation_access rules to find a matching adaptation service
class AccessCheck: public virtual AsyncJob
{
-
public:
typedef void AccessCheckCallback(ServicePointer match, void *data);
+
+ // use this to start async ACL checks; returns true if started
+ static bool Start(Method method, VectPoint vp, HttpRequest *req,
+ HttpReply *rep, AccessCheckCallback *cb, void *cbdata);
+
+protected:
+ // use Start to start adaptation checks
AccessCheck(Method, VectPoint, HttpRequest *, HttpReply *, AccessCheckCallback *, void *);
~AccessCheck();
#if USE_ADAPTATION
#include "adaptation/AccessCheck.h"
-#include "ICAP/ICAPConfig.h" /* XXX: replace with generic adaptation config */
+#include "adaptation/Service.h"
static void adaptationAclCheckDoneWrapper(Adaptation::ServicePointer service, void *data);
#endif
}
#if USE_ADAPTATION
-void
-ClientRequestContext::adaptationAccessCheck()
-{
- Adaptation::AccessCheck *check = new Adaptation::AccessCheck(
- Adaptation::methodReqmod, Adaptation::pointPreCache,
- http->request, NULL, adaptationAclCheckDoneWrapper, this);
-
- check->check(); // will eventually delete self
-}
-
static void
adaptationAclCheckDoneWrapper(Adaptation::ServicePointer service, void *data)
{
}
#if USE_ADAPTATION
- if (TheICAPConfig.onoff && !calloutContext->adaptation_acl_check_done) {
- debugs(83, 3, HERE << "Doing calloutContext->adaptationAccessCheck()");
+ if (!calloutContext->adaptation_acl_check_done) {
calloutContext->adaptation_acl_check_done = true;
- calloutContext->adaptationAccessCheck();
- return;
+ if (Adaptation::AccessCheck::Start(
+ Adaptation::methodReqmod, Adaptation::pointPreCache,
+ request, NULL, adaptationAclCheckDoneWrapper, this))
+ return; // will call callback
}
-
#endif
if (!calloutContext->redirect_done) {