/*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
*
* Squid software is distributed under GPLv2+ license and includes
* contributions from numerous individuals and organizations.
/* DEBUG: section 76 Internal Squid Object handling */
#include "squid.h"
+#include "AccessLogEntry.h"
#include "CacheManager.h"
#include "comm/Connection.h"
#include "errorpage.h"
#include "SquidTime.h"
#include "Store.h"
#include "tools.h"
-#include "URL.h"
#include "util.h"
#include "wordlist.h"
* return Http::scNotFound for others
*/
void
-internalStart(const Comm::ConnectionPointer &clientConn, HttpRequest * request, StoreEntry * entry)
+internalStart(const Comm::ConnectionPointer &clientConn, HttpRequest * request, StoreEntry * entry, const AccessLogEntry::Pointer &ale)
{
ErrorState *err;
const SBuf upath = request->url.path();
entry->complete();
} else if (upath.startsWith(mgrPfx)) {
debugs(17, 2, "calling CacheManager due to URL-path " << mgrPfx);
- CacheManager::GetInstance()->Start(clientConn, request, entry);
+ CacheManager::GetInstance()->start(clientConn, request, entry, ale);
} else {
debugObj(76, 1, "internalStart: unknown request:\n",
request, (ObjPackMethod) & httpRequestPack);
- err = new ErrorState(ERR_INVALID_REQ, Http::scNotFound, request);
+ err = new ErrorState(ERR_INVALID_REQ, Http::scNotFound, request, ale);
errorAppendEntry(entry, err);
}
}
* makes internal url with a given host and port (remote internal url)
*/
char *
-internalRemoteUri(const char *host, unsigned short port, const char *dir, const SBuf &name)
+internalRemoteUri(bool encrypt, const char *host, unsigned short port, const char *dir, const SBuf &name)
{
static char lc_host[SQUIDHOSTNAMELEN];
assert(host && !name.isEmpty());
/*
* append the domain in order to mirror the requests with appended
- * domains
+ * domains. If that fails, just use the hostname anyway.
*/
-
- /* For IPv6 addresses also check for a colon */
- if (Config.appendDomain && !strchr(lc_host, '.') && !strchr(lc_host, ':'))
- strncat(lc_host, Config.appendDomain, SQUIDHOSTNAMELEN -
- strlen(lc_host) - 1);
+ (void)urlAppendDomain(lc_host);
/* build URI */
- URL tmp(AnyP::PROTO_HTTP);
+ AnyP::Uri tmp(AnyP::PROTO_HTTP);
tmp.host(lc_host);
if (port)
tmp.port(port);
static MemBuf mb;
mb.reset();
- mb.appendf("http://" SQUIDSBUFPH, SQUIDSBUFPRINT(tmp.authority()));
+ mb.appendf("%s://" SQUIDSBUFPH, encrypt ? "https" : "http", SQUIDSBUFPRINT(tmp.authority()));
if (dir)
mb.append(dir, strlen(dir));
char *
internalLocalUri(const char *dir, const SBuf &name)
{
- return internalRemoteUri(getMyHostname(),
+ // XXX: getMy*() may return https_port info, but we force http URIs
+ // because we have not checked whether the callers can handle https.
+ const bool secure = false;
+ return internalRemoteUri(secure, getMyHostname(),
getMyPort(), dir, name);
}