/*
- * Copyright (C) 1996-2017 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.
// To improve diagnostic, remember exactly how an unsupported scheme looks like.
// XXX: Object users may rely on toLower() canonicalization that we refuse to provide.
if (img && theScheme_ == AnyP::PROTO_UNKNOWN)
- image_ = img;
+ image_ = img;
// XXX: A broken caller supplies an image of an absent scheme?
// XXX: We assume that the caller is using a lower-case image.
else if (img && theScheme_ == AnyP::PROTO_NONE)
- image_ = img;
+ image_ = img;
else if (theScheme_ > AnyP::PROTO_NONE && theScheme_ < AnyP::PROTO_MAX)
image_ = LowercaseSchemeNames_.at(theScheme_);
}
}
+const AnyP::ProtocolType
+AnyP::UriScheme::FindProtocolType(const SBuf &scheme)
+{
+ if (scheme.isEmpty())
+ return AnyP::PROTO_NONE;
+
+ Init();
+
+ auto img = scheme;
+ img.toLower();
+ // TODO: use base/EnumIterator.h if possible
+ for (int i = AnyP::PROTO_NONE + 1; i < AnyP::PROTO_UNKNOWN; ++i) {
+ if (LowercaseSchemeNames_.at(i) == img)
+ return AnyP::ProtocolType(i);
+ }
+
+ return AnyP::PROTO_UNKNOWN;
+}
+
unsigned short
AnyP::UriScheme::defaultPort() const
{