*/
if ( Config.accessList.miss && !request->client_addr.isNoAddr() &&
- request->protocol != AnyP::PROTO_INTERNAL && request->protocol != AnyP::PROTO_CACHE_OBJECT) {
+ !request->flags.internal && request->url.getScheme() != AnyP::PROTO_CACHE_OBJECT) {
/**
* Check if this host is allowed to fetch MISSES from us (miss_access).
* Intentionally replace the src_addr automatically selected by the checklist code
return;
}
- switch (request->protocol) {
-
- case AnyP::PROTO_INTERNAL:
+ if (request->flags.internal) {
+ debugs(17, 2, "calling internalStart() due to request flag");
internalStart(clientConn, request, entry);
return;
+ }
+
+ switch (request->url.getScheme()) {
case AnyP::PROTO_CACHE_OBJECT:
+ debugs(17, 2, "calling CacheManager due to request scheme " << request->url.getScheme());
CacheManager::GetInstance()->Start(clientConn, request, entry);
return;
#if USE_OPENSSL
if (!request->flags.pinned) {
if ((serverConnection()->getPeer() && serverConnection()->getPeer()->use_ssl) ||
- (!serverConnection()->getPeer() && request->protocol == AnyP::PROTO_HTTPS) ||
+ (!serverConnection()->getPeer() && request->url.getScheme() == AnyP::PROTO_HTTPS) ||
request->flags.sslPeek) {
HttpRequest::Pointer requestPointer = request;
request->peer_login = NULL;
request->peer_domain = NULL;
- switch (request->protocol) {
+ switch (request->url.getScheme()) {
#if USE_OPENSSL
case AnyP::PROTO_HTTPS:
case AnyP::PROTO_CACHE_OBJECT:
- case AnyP::PROTO_INTERNAL:
-
case AnyP::PROTO_URN:
fatal_dump("Should never get here");
break;
#include "SquidConfig.h"
HttpMsg::HttpMsg(http_hdr_owner_type owner): header(owner),
- cache_control(NULL), hdr_sz(0), content_length(0), protocol(AnyP::PROTO_NONE),
+ cache_control(NULL), hdr_sz(0), content_length(0),
pstate(psReadyToParseStartLine)
{}
bool persistent() const;
public:
+ /// HTTP-Version field in the first line of the message.
+ /// see draft-ietf-httpbis-p1-messaging-26 section 3.1
Http::ProtocolVersion http_ver;
HttpHeader header;
int64_t content_length;
- AnyP::ProtocolType protocol;
-
HttpMsgParseState pstate; /* the current parsing state */
BodyPipe::Pointer body_pipe; // optional pipeline to receive message body
rep->pstate = pstate;
rep->body_pipe = body_pipe;
- rep->protocol = protocol;
// keep_alive is handled in hdrCacheInit()
return rep;
}
HttpRequest::initHTTP(const HttpRequestMethod& aMethod, AnyP::ProtocolType aProtocol, const char *aUrlpath)
{
method = aMethod;
- protocol = aProtocol;
+ url.setScheme(aProtocol);
urlpath = aUrlpath;
}
HttpRequest::init()
{
method = Http::METHOD_NONE;
- protocol = AnyP::PROTO_NONE;
+ url.clear();
urlpath = NULL;
login[0] = '\0';
host[0] = '\0';
safe_free(vary_headers);
+ url.clear();
urlpath.clean();
header.clean();
HttpRequest *
HttpRequest::clone() const
{
- HttpRequest *copy = new HttpRequest(method, protocol, urlpath.termedBuf());
+ HttpRequest *copy = new HttpRequest(method, url.getScheme(), urlpath.termedBuf());
// TODO: move common cloning clone to Msg::copyTo() or copy ctor
copy->header.append(&header);
copy->hdrCacheInit();
if (!flags.hostVerified && (flags.intercepted || flags.interceptTproxy))
return false;
- switch (protocol) {
+ switch (url.getScheme()) {
case AnyP::PROTO_HTTP:
case AnyP::PROTO_HTTPS:
if (!method.respMaybeCacheable())
#include "HttpRequestMethod.h"
#include "Notes.h"
#include "RequestFlags.h"
+#include "URL.h"
#if USE_AUTH
#include "auth/UserRequest.h"
public:
HttpRequestMethod method;
+ // TODO expand to include all URI parts
+ URL url; ///< the request URI (scheme only)
+
char login[MAX_LOGIN_SZ];
private:
MEMPROXY_CLASS(URL);
URL() : scheme_() {}
URL(AnyP::UriScheme const &aScheme) : scheme_(aScheme) {}
+
+ void clear() {
+ scheme_=AnyP::PROTO_NONE;
+ }
+
AnyP::UriScheme const & getScheme() const {return scheme_;}
+ /// convert the URL scheme to that given
+ void setScheme(const AnyP::ProtocolType &p) {scheme_=p;}
+
private:
/**
\par
* In order to make taking any of these routes easy, scheme is private
* and immutable, only settable at construction time,
*/
- AnyP::UriScheme const scheme_;
+ AnyP::UriScheme scheme_;
};
MEMPROXY_CLASS_INLINE(URL);
template class ACLStrategised<AnyP::ProtocolType>;
int
-ACLProtocolStrategy::match (ACLData<MatchType> * &data, ACLFilledChecklist *checklist, ACLFlags &)
+ACLProtocolStrategy::match(ACLData<MatchType> * &data, ACLFilledChecklist *checklist, ACLFlags &)
{
- return data->match (checklist->request->protocol);
+ return data->match(checklist->request->url.getScheme());
}
ACLProtocolStrategy *
libecap::protocolWais.assignHostId(AnyP::PROTO_WAIS);
libecap::protocolUrn.assignHostId(AnyP::PROTO_URN);
libecap::protocolWhois.assignHostId(AnyP::PROTO_WHOIS);
- protocolInternal.assignHostId(AnyP::PROTO_INTERNAL);
protocolCacheObj.assignHostId(AnyP::PROTO_CACHE_OBJECT);
protocolIcp.assignHostId(AnyP::PROTO_ICP);
#if USE_HTCP
#endif
case AnyP::PROTO_CACHE_OBJECT:
return protocolCacheObj;
- case AnyP::PROTO_INTERNAL:
- return protocolInternal;
case AnyP::PROTO_ICY:
return protocolIcy;
case AnyP::PROTO_COAP:
#endif
PROTO_URN,
PROTO_WHOIS,
- PROTO_INTERNAL,
PROTO_ICY,
PROTO_UNKNOWN,
PROTO_MAX
//this code follows urlCanonical's pattern.
// corner cases should use the canonical URL
if (tp->options.carp_key.scheme) {
- // temporary, until bug 1961 URL handling is fixed.
- const AnyP::UriScheme sch(request->protocol);
- key.append(sch.c_str());
+ key.append(request->url.getScheme().c_str());
if (key.length()) //if the scheme is not empty
key.append("://");
}
%SRCPORT Client source port
%URI Requested URI
%DST Requested host
- %PROTO Requested protocol
+ %PROTO Requested URL scheme
%PORT Requested port
%PATH Requested URL path
%METHOD Request method
}
if (internalCheck(request->urlpath.termedBuf())) {
- if (internalHostnameIs(request->GetHost()) &&
- request->port == getMyPort()) {
+ if (internalHostnameIs(request->GetHost()) && request->port == getMyPort()) {
+ debugs(33, 2, "internal URL found: " << request->url.getScheme() << "://" << request->GetHost() <<
+ ':' << request->port);
http->flags.internal = true;
} else if (Config.onoff.global_internal_static && internalStaticCheck(request->urlpath.termedBuf())) {
+ debugs(33, 2, "internal URL found: " << request->url.getScheme() << "://" << request->GetHost() <<
+ ':' << request->port << " (global_internal_static on)");
request->SetHost(internalHostname());
request->port = getMyPort();
http->flags.internal = true;
- }
+ } else
+ debugs(33, 2, "internal URL found: " << request->url.getScheme() << "://" << request->GetHost() <<
+ ':' << request->port << " (not this proxy)");
}
- if (http->flags.internal) {
- request->protocol = AnyP::PROTO_HTTP;
+ if (http->flags.internal)
request->login[0] = '\0';
- }
request->flags.internal = http->flags.internal;
setLogUri (http, urlCanonicalClean(request.getRaw()));
*/
http->logType = LOG_TCP_CLIENT_REFRESH_MISS;
processMiss();
- } else if (r->protocol == AnyP::PROTO_HTTP) {
+ } else if (r->url.getScheme() == AnyP::PROTO_HTTP) {
debugs(88, 3, "validate HIT object? YES.");
/*
* Object needs to be revalidated
return;
}
- /** Check for internal requests. Update Protocol info if so. */
- if (http->flags.internal)
- r->protocol = AnyP::PROTO_INTERNAL;
-
assert(r->clientConnectionManager == http->getConn());
/** Start forwarding to get the new object from network */
// Verify forward-proxy requested URL domain matches the Host: header
debugs(85, 3, HERE << "FAIL on validate URL port " << http->request->port << " matches Host: port " << portStr);
hostHeaderVerifyFailed("URL port", portStr);
- } else if (!portStr && http->request->method != Http::METHOD_CONNECT && http->request->port != urlDefaultPort(http->request->protocol)) {
+ } else if (!portStr && http->request->method != Http::METHOD_CONNECT && http->request->port != urlDefaultPort(http->request->url.getScheme())) {
// Verify forward-proxy requested URL domain matches the Host: header
// Special case: we don't have a default-port to check for CONNECT. Assume URL is correct.
- debugs(85, 3, HERE << "FAIL on validate URL port " << http->request->port << " matches Host: default port " << urlDefaultPort(http->request->protocol));
+ debugs(85, 3, "FAIL on validate URL port " << http->request->port << " matches Host: default port " << urlDefaultPort(http->request->url.getScheme()));
hostHeaderVerifyFailed("URL port", "default port");
} else {
// Okay no problem.
if (request->flags.loopDetected)
return 0;
- if (request->protocol == AnyP::PROTO_HTTP)
+ if (request->url.getScheme() == AnyP::PROTO_HTTP)
return method.respMaybeCacheable();
- if (request->protocol == AnyP::PROTO_GOPHER)
+ if (request->url.getScheme() == AnyP::PROTO_GOPHER)
return gopherCachable(request);
- if (request->protocol == AnyP::PROTO_CACHE_OBJECT)
+ if (request->url.getScheme() == AnyP::PROTO_CACHE_OBJECT)
return 0;
return 1;
case 'P':
if (request) {
- p = AnyP::ProtocolType_str[request->protocol];
+ p = request->url.getScheme().c_str();
} else if (!building_deny_info_url) {
p = "[unknown protocol]";
}
break;
case _external_acl_format::EXT_ACL_PROTO:
- str = AnyP::ProtocolType_str[request->protocol];
+ str = request->url.getScheme().c_str();
break;
case _external_acl_format::EXT_ACL_PORT:
{
String newbuf = "%2f";
- if (request->protocol != AnyP::PROTO_FTP)
+ if (request->url.getScheme() != AnyP::PROTO_FTP)
return NULL;
if ( request->urlpath[0]=='/' ) {
if (!hdr_out->has(HDR_HOST)) {
if (request->peer_domain) {
hdr_out->putStr(HDR_HOST, request->peer_domain);
- } else if (request->port == urlDefaultPort(request->protocol)) {
+ } else if (request->port == urlDefaultPort(request->url.getScheme())) {
/* use port# only if not default */
hdr_out->putStr(HDR_HOST, request->GetHost());
} else {
/* append Front-End-Https */
if (flags.front_end_https) {
- if (flags.front_end_https == 1 || request->protocol == AnyP::PROTO_HTTPS)
+ if (flags.front_end_https == 1 || request->url.getScheme() == AnyP::PROTO_HTTPS)
hdr_out->putStr(HDR_FRONT_END_HTTPS, "On");
}
else {
/* use port# only if not default */
- if (request->port == urlDefaultPort(request->protocol)) {
+ if (request->port == urlDefaultPort(request->url.getScheme())) {
hdr_out->putStr(HDR_HOST, request->GetHost());
} else {
httpHeaderPutStrf(hdr_out, HDR_HOST, "%s:%d",
entry->append(msgbuf, strlen(msgbuf));
entry->complete();
} else if (0 == strncmp(upath, "/squid-internal-mgr/", 20)) {
+ debugs(17, 2, "calling CacheManager due to URL-path /squid-internal-mgr/");
CacheManager::GetInstance()->Start(clientConn, request, entry);
} else {
debugObj(76, 1, "internalStart: unknown request:\n",
return;
/* WAIS is not implemented natively */
- if (ps->request->protocol == AnyP::PROTO_WAIS)
+ if (ps->request->url.getScheme() == AnyP::PROTO_WAIS)
return;
peerAddFwdServer(&ps->servers, NULL, HIER_DIRECT);
CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET);
CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost()));
CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath);
- CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol);
+ CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast<AnyP::ProtocolType>(aRequest->url.getScheme()));
CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url));
xfree(url);
CPPUNIT_ASSERT(aRequest->method == Http::METHOD_PUT);
CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost()));
CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath);
- CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol);
+ CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast<AnyP::ProtocolType>(aRequest->url.getScheme()));
CPPUNIT_ASSERT_EQUAL(String("http://foo/bar"), String(url));
xfree(url);
CPPUNIT_ASSERT(aRequest->method == Http::METHOD_CONNECT);
CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost()));
CPPUNIT_ASSERT_EQUAL(String(""), aRequest->urlpath);
- CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_NONE, aRequest->protocol);
+ CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_NONE, static_cast<AnyP::ProtocolType>(aRequest->url.getScheme()));
CPPUNIT_ASSERT_EQUAL(String("foo:45"), String(url));
xfree(url);
}
CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET);
CPPUNIT_ASSERT_EQUAL(String("foo"), String(aRequest->GetHost()));
CPPUNIT_ASSERT_EQUAL(String("/bar"), aRequest->urlpath);
- CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol);
+ CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast<AnyP::ProtocolType>(aRequest->url.getScheme()));
CPPUNIT_ASSERT_EQUAL(String("http://foo:90/bar"), String(url));
xfree(url);
}
CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET);
CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost()));
CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath);
- CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol);
+ CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast<AnyP::ProtocolType>(aRequest->url.getScheme()));
CPPUNIT_ASSERT_EQUAL(String("http://[2000:800::45]/foo"), String(url));
xfree(url);
CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET);
CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost()));
CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath);
- CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol);
+ CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast<AnyP::ProtocolType>(aRequest->url.getScheme()));
CPPUNIT_ASSERT_EQUAL(String("http://[2000:800::45]:90/foo"), String(url));
xfree(url);
CPPUNIT_ASSERT(aRequest->method == Http::METHOD_GET);
CPPUNIT_ASSERT_EQUAL(String("[2000:800::45]"), String(aRequest->GetHost()));
CPPUNIT_ASSERT_EQUAL(String("/foo"), aRequest->urlpath);
- CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, aRequest->protocol);
+ CPPUNIT_ASSERT_EQUAL(AnyP::PROTO_HTTP, static_cast<AnyP::ProtocolType>(aRequest->url.getScheme()));
CPPUNIT_ASSERT_EQUAL(String("http://2000:800::45/foo"), String(url));
xfree(url);
}
if (strncasecmp(b, "whois", len) == 0)
return AnyP::PROTO_WHOIS;
- if (strncasecmp(b, "internal", len) == 0)
- return AnyP::PROTO_INTERNAL;
-
return AnyP::PROTO_NONE;
}
return 210;
case AnyP::PROTO_CACHE_OBJECT:
-
- case AnyP::PROTO_INTERNAL:
return CACHE_HTTP_PORT;
case AnyP::PROTO_WHOIS:
if (request->canonical)
return request->canonical;
- if (request->protocol == AnyP::PROTO_URN) {
+ if (request->url.getScheme() == AnyP::PROTO_URN) {
snprintf(urlbuf, MAX_URL, "urn:" SQUIDSTRINGPH,
SQUIDSTRINGPRINT(request->urlpath));
} else {
{
portbuf[0] = '\0';
- if (request->port != urlDefaultPort(request->protocol))
+ if (request->port != urlDefaultPort(request->url.getScheme()))
snprintf(portbuf, 32, ":%d", request->port);
- const AnyP::UriScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed.
snprintf(urlbuf, MAX_URL, "%s://%s%s%s%s" SQUIDSTRINGPH,
- sch.c_str(),
+ request->url.getScheme().c_str(),
request->login,
*request->login ? "@" : null_string,
request->GetHost(),
LOCAL_ARRAY(char, loginbuf, MAX_LOGIN_SZ + 1);
char *t;
- if (request->protocol == AnyP::PROTO_URN) {
+ if (request->url.getScheme() == AnyP::PROTO_URN) {
snprintf(buf, MAX_URL, "urn:" SQUIDSTRINGPH,
SQUIDSTRINGPRINT(request->urlpath));
} else {
{
portbuf[0] = '\0';
- if (request->port != urlDefaultPort(request->protocol))
+ if (request->port != urlDefaultPort(request->url.getScheme()))
snprintf(portbuf, 32, ":%d", request->port);
loginbuf[0] = '\0';
strcat(loginbuf, "@");
}
- const AnyP::UriScheme sch = request->protocol; // temporary, until bug 1961 URL handling is fixed.
snprintf(buf, MAX_URL, "%s://%s%s%s" SQUIDSTRINGPH,
- sch.c_str(),
+ request->url.getScheme().c_str(),
loginbuf,
request->GetHost(),
portbuf,
char *urlbuf = (char *)xmalloc(MAX_URL * sizeof(char));
- if (req->protocol == AnyP::PROTO_URN) {
+ if (req->url.getScheme() == AnyP::PROTO_URN) {
snprintf(urlbuf, MAX_URL, "urn:" SQUIDSTRINGPH,
SQUIDSTRINGPRINT(req->urlpath));
return (urlbuf);
size_t urllen;
- const AnyP::UriScheme sch = req->protocol; // temporary, until bug 1961 URL handling is fixed.
- if (req->port != urlDefaultPort(req->protocol)) {
+ if (req->port != urlDefaultPort(req->url.getScheme())) {
urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s:%d",
- sch.c_str(),
+ req->url.getScheme().c_str(),
req->login,
*req->login ? "@" : null_string,
req->GetHost(),
);
} else {
urllen = snprintf(urlbuf, MAX_URL, "%s://%s%s%s",
- sch.c_str(),
+ req->url.getScheme().c_str(),
req->login,
*req->login ? "@" : null_string,
req->GetHost()
return 1;
/* does method match the protocol? */
- switch (r->protocol) {
+ switch (r->url.getScheme()) {
case AnyP::PROTO_URN: