/*
- * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
// TODO: use the authentication system decode to retrieve these details properly.
/* base 64 _decoded_ user:passwd pair */
- const char *basic_cookie = request->header.getAuth(HDR_AUTHORIZATION, "Basic");
+ const char *basic_cookie = request->header.getAuth(Http::HdrType::AUTHORIZATION, "Basic");
if (!basic_cookie)
return;
rep->header.putAuth("Basic", actionName);
#endif
// Allow cachemgr and other XHR scripts access to our version string
- if (request->header.has(HDR_ORIGIN)) {
- rep->header.putExt("Access-Control-Allow-Origin",request->header.getStr(HDR_ORIGIN));
+ if (request->header.has(Http::HdrType::ORIGIN)) {
+ rep->header.putExt("Access-Control-Allow-Origin",request->header.getStr(Http::HdrType::ORIGIN));
#if HAVE_AUTH_MODULE_BASIC
rep->header.putExt("Access-Control-Allow-Credentials","true");
#endif
return;
}
- if (request->header.has(HDR_ORIGIN)) {
- cmd->params.httpOrigin = request->header.getStr(HDR_ORIGIN);
+ if (request->header.has(Http::HdrType::ORIGIN)) {
+ cmd->params.httpOrigin = request->header.getStr(Http::HdrType::ORIGIN);
}
debugs(16, 2, "CacheManager: " <<
if (strncmp(rep->body.content(),"Internal Error:", 15) == 0)
rep->sline.set(Http::ProtocolVersion(1,1), Http::scNotFound);
// Allow cachemgr and other XHR scripts access to our version string
- if (request->header.has(HDR_ORIGIN)) {
- rep->header.putExt("Access-Control-Allow-Origin",request->header.getStr(HDR_ORIGIN));
+ if (request->header.has(Http::HdrType::ORIGIN)) {
+ rep->header.putExt("Access-Control-Allow-Origin",request->header.getStr(Http::HdrType::ORIGIN));
#if HAVE_AUTH_MODULE_BASIC
rep->header.putExt("Access-Control-Allow-Credentials","true");
#endif
char *
CacheManager::PasswdGet(Mgr::ActionPasswordList * a, const char *action)
{
- wordlist *w;
-
- while (a != NULL) {
- for (w = a->actions; w != NULL; w = w->next) {
- if (0 == strcmp(w->key, action))
+ while (a) {
+ for (auto &w : a->actions) {
+ if (w.cmp(action) == 0)
return a->passwd;
- if (0 == strcmp(w->key, "all"))
+ static const SBuf allAction("all");
+ if (w == allAction)
return a->passwd;
}
return NULL;
}
-CacheManager* CacheManager::instance=0;
-
-/**
- \ingroup CacheManagerAPI
- * Singleton accessor method.
- */
CacheManager*
CacheManager::GetInstance()
{
- if (instance == 0) {
- debugs(16, 6, "CacheManager::GetInstance: starting cachemanager up");
+ static CacheManager *instance = nullptr;
+ if (!instance) {
+ debugs(16, 6, "starting cachemanager up");
instance = new CacheManager;
Mgr::RegisterBasics();
}