/*
- * 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.
return NULL;
/* calculate hash key */
- debugs(39, 2, "carpSelectParent: Calculating hash for " << urlCanonical(request));
+ debugs(39, 2, "carpSelectParent: Calculating hash for " << request->effectiveRequestUri());
/* select CachePeer */
for (k = 0; k < n_carp_peers; ++k) {
SBuf key;
tp = carp_peers[k];
if (tp->options.carp_key.set) {
- //this code follows urlCanonical's pattern.
- // corner cases should use the canonical URL
+ // this code follows URI syntax pattern.
+ // corner cases should use the full effective request URI
if (tp->options.carp_key.scheme) {
- key.append(request->url.getScheme().c_str());
+ key.append(request->url.getScheme().image());
if (key.length()) //if the scheme is not empty
key.append("://");
}
key.appendf(":%u", request->url.port());
}
if (tp->options.carp_key.path) {
- String::size_type pos;
- if ((pos=request->urlpath.find('?'))!=String::npos)
- key.append(SBuf(request->urlpath.substr(0,pos)));
- else
- key.append(SBuf(request->urlpath));
+ // XXX: fix when path and query are separate
+ key.append(request->url.path().substr(0,request->url.path().find('?'))); // 0..N
}
if (tp->options.carp_key.params) {
- String::size_type pos;
- if ((pos=request->urlpath.find('?'))!=String::npos)
- key.append(SBuf(request->urlpath.substr(pos,request->urlpath.size())));
+ // XXX: fix when path and query are separate
+ SBuf::size_type pos;
+ if ((pos=request->url.path().find('?')) != SBuf::npos)
+ key.append(request->url.path().substr(pos)); // N..npos
}
}
// if the url-based key is empty, e.g. because the user is
// asking to balance on the path but the request doesn't supply any,
- // then fall back to canonical URL
+ // then fall back to the effective request URI
if (key.isEmpty())
- key=SBuf(urlCanonical(request));
+ key=request->effectiveRequestUri();
for (const char *c = key.rawContent(), *e=key.rawContent()+key.length(); c < e; ++c)
user_hash += ROTATE_LEFT(user_hash, 19) + *c;