#include <Uri.h>

Collaboration diagram for AnyP::Uri:

Public Member Functions

 Uri ()
 Uri (AnyP::UriScheme const &aScheme)
 Uri (const Uri &other)
Urioperator= (const Uri &o)
void clear ()
void touch ()
 clear the cached URI display forms More...
bool parse (const HttpRequestMethod &, const char *url)
AnyP::UriScheme const & getScheme () const
void setScheme (const AnyP::ProtocolType &p, const char *str)
 convert the URL scheme to that given More...
void userInfo (const SBuf &s)
const SBufuserInfo () const
void host (const char *src)
const char * host (void) const
int hostIsNumeric (void) const
Ip::Address const & hostIP (void) const
void port (unsigned short p)
unsigned short port () const
void path (const char *p)
void path (const SBuf &p)
const SBufpath () const
SBufauthority (bool requirePort=false) const
SBufabsolute () const

Static Public Member Functions

static char * cleanup (const char *uri)
static const SBufSlashPath ()
 the static '/' default URL-path More...
static const SBufAsterisk ()
 the static '*' pseudo-URI More...

Private Member Functions

void parseFinish (const AnyP::ProtocolType, const char *const, const char *const, const char *const, const SBuf &, const int)
 Update the URL object with parsed URI data. More...

Private Attributes

AnyP::UriScheme scheme_
SBuf userInfo_
 string representation of the URI authority name or IP More...
bool hostIsNumeric_
 whether the authority 'host' is a raw-IP More...
Ip::Address hostAddr_
 binary representation of the URI authority if it is a raw-IP More...
unsigned short port_
 URL port. More...
SBuf path_
 URI path segment. More...
SBuf authorityHttp_
 RFC 7230 section 5.3.3 authority, maybe without default-port. More...
SBuf authorityWithPort_
 RFC 7230 section 5.3.3 authority with explicit port. More...
SBuf absolute_
 RFC 7230 section 5.3.2 absolute-URI. More...

Detailed Description

Represents a Uniform Resource Identifier. Can store both URL or URN representations.

Governed by RFC 3986

Definition at line 30 of file Uri.h.

Constructor & Destructor Documentation

◆ Uri() [1/3]

AnyP::Uri::Uri ( )

Definition at line 35 of file Uri.h.

References host_.

◆ Uri() [2/3]

AnyP::Uri::Uri ( AnyP::UriScheme const &  aScheme)

Definition at line 931 of file Uri.cc.

References host_.

◆ Uri() [3/3]

AnyP::Uri::Uri ( const Uri other)

Definition at line 37 of file Uri.h.

References operator=().

Member Function Documentation

◆ absolute()

SBuf & AnyP::Uri::absolute ( ) const

The absolute-form URI for currently stored values.

As defined by RFC 7230 section 5.3.3 this form omits the userinfo@ field from RFC 3986 defined authority segments when the protocol scheme is http: or https:.

Definition at line 488 of file Uri.cc.

References absolute_, SBuf::append(), authority(), getScheme(), SBuf::isEmpty(), MAX_URL, path(), AnyP::PROTO_HTTP, AnyP::PROTO_HTTPS, AnyP::PROTO_URN, SBuf::reserveCapacity(), and userInfo().

Referenced by asnCacheStart(), HttpRequest::effectiveRequestUri(), path(), and urlMakeAbsolute().

◆ Asterisk()

const SBuf & AnyP::Uri::Asterisk ( )

Definition at line 33 of file Uri.cc.

Referenced by parse(), path(), and urlCheckRequest().

◆ authority()

SBuf & AnyP::Uri::authority ( bool  requirePort = false) const

The authority-form URI for currently stored values.

As defined by RFC 7230 section 5.3.3 this form omits the userinfo@ field from RFC 3986 defined authority segment.

requirePortwhen true the port will be included, otherwise port will be elided when it is the default for the current scheme.

Definition at line 470 of file Uri.cc.

References SBuf::append(), SBuf::appendf(), authorityHttp_, authorityWithPort_, getScheme(), host(), SBuf::isEmpty(), and port().

Referenced by absolute(), Http::One::Server::buildHttpRequest(), Ftp::Gateway::buildTitleUrl(), clientProcessRequest(), copyOneHeaderFromClientsideRequestToUpstreamRequest(), HttpRequest::effectiveRequestUri(), HttpStateData::httpBuildRequestHeader(), internalRemoteUri(), operator<<(), path(), peerAllowedToUse(), Ssl::ServerBump::ServerBump(), and urlMakeAbsolute().

◆ cleanup()

◆ clear()

void AnyP::Uri::clear ( )

◆ getScheme()

◆ host() [1/2]

void AnyP::Uri::host ( const char *  src)

Definition at line 47 of file Uri.cc.

References debugs, host_, hostAddr_, hostIsNumeric_, Ip::Address::isAnyAddr(), Ip::Address::setEmpty(), Ip::Address::toHostStr(), touch(), and xstrncpy().

Referenced by asnCacheStart(), Format::Format::assemble(), ConnStateData::buildFakeRequest(), Downloader::buildRequest(), carpSelectParent(), HttpStateData::checkDateSkew(), DestinationIPLookup::checkForAsync(), clientProcessRequest(), ErrorState::compileLegacyCode(), FwdState::connectStart(), ICP2State::created(), FwdState::dispatch(), doV2Query(), Ftp::Gateway::ftpRealm(), ftpSendUser(), TunnelStateData::getHost(), clientReplyContext::identifyFoundObject(), Security::BlindPeerConnector::initialize(), Ssl::PeekingPeerConnector::initialize(), ConnStateData::initiateTunneledRequest(), internalRemoteUri(), ACLDestinationASNStrategy::match(), ACLDestinationDomainStrategy::match(), ACLServerNameStrategy::match(), ACLDestinationIP::match(), neighborType(), netdbClosestParent(), netdbUpdatePeer(), Ssl::PeekingPeerConnector::noteNegotiationDone(), operator<<(), ConnStateData::pinConnection(), ConnStateData::postHttpsAccept(), HttpStateData::processReplyBody(), clientReplyContext::purgeRequest(), ConnStateData::serveDelayedError(), PeerPoolMgr::start(), Ftp::Gateway::start(), ConnStateData::switchToHttps(), testHttpRequest::testCreateFromUrl(), testHttpRequest::testIPv6HostColonBug(), tunnelConnectDone(), urlCanonicalFakeHttps(), FwdState::usePinned(), and ConnStateData::validatePinnedConnection().

◆ host() [2/2]

const char* AnyP::Uri::host ( void  ) const

Definition at line 79 of file Uri.h.

References host_.

Referenced by authority(), operator<<(), parseFinish(), and userInfo().

◆ hostIP()

Ip::Address const& AnyP::Uri::hostIP ( void  ) const

Definition at line 81 of file Uri.h.

References hostAddr_.

Referenced by ACLDestinationIP::match().

◆ hostIsNumeric()

int AnyP::Uri::hostIsNumeric ( void  ) const

Definition at line 80 of file Uri.h.

References hostIsNumeric_.

Referenced by ACLDestinationDomainStrategy::match(), and ACLDestinationIP::match().


AnyP::Uri::MEMPROXY_CLASS ( Uri  )

◆ operator=()

Uri& AnyP::Uri::operator= ( const Uri o)

Definition at line 40 of file Uri.h.

References host_, hostAddr_, hostIsNumeric_, path_, port_, scheme_, touch(), and userInfo_.

Referenced by Uri().

◆ parse()

◆ parseFinish()

void AnyP::Uri::parseFinish ( const AnyP::ProtocolType  protocol,
const char * const  protoStr,
const char * const  aUrlPath,
const char * const  aHost,
const SBuf aLogin,
const int  aPort 

Definition at line 447 of file Uri.cc.

References host(), path(), port(), setScheme(), and userInfo().

Referenced by parse(), and path().

◆ path() [1/3]

◆ path() [2/3]

void AnyP::Uri::path ( const SBuf p)

Definition at line 87 of file Uri.h.

References absolute(), Asterisk(), authority(), p, parseFinish(), path(), path_, SlashPath(), and touch().

◆ path() [3/3]

const SBuf & AnyP::Uri::path ( ) const

◆ port() [1/2]

◆ port() [2/2]

unsigned short AnyP::Uri::port ( ) const

Definition at line 84 of file Uri.h.

References port_.

Referenced by authority(), operator<<(), and parseFinish().

◆ setScheme()

void AnyP::Uri::setScheme ( const AnyP::ProtocolType p,
const char *  str 

◆ SlashPath()

const SBuf & AnyP::Uri::SlashPath ( )

Definition at line 40 of file Uri.cc.

Referenced by path().

◆ touch()

void AnyP::Uri::touch ( )

Definition at line 462 of file Uri.cc.

References absolute_, authorityHttp_, authorityWithPort_, and SBuf::clear().

Referenced by clear(), host(), operator=(), path(), port(), setScheme(), and userInfo().

◆ userInfo() [1/2]

◆ userInfo() [2/2]

const SBuf& AnyP::Uri::userInfo ( ) const

Definition at line 76 of file Uri.h.

References host(), and userInfo_.

Referenced by absolute(), and parseFinish().

Member Data Documentation

◆ absolute_

SBuf AnyP::Uri::absolute_

Definition at line 158 of file Uri.h.

Referenced by absolute(), and touch().

◆ authorityHttp_

SBuf AnyP::Uri::authorityHttp_

Definition at line 156 of file Uri.h.

Referenced by authority(), and touch().

◆ authorityWithPort_

SBuf AnyP::Uri::authorityWithPort_

Definition at line 157 of file Uri.h.

Referenced by authority(), and touch().

◆ host_

char AnyP::Uri::host_[SQUIDHOSTNAMELEN]

Definition at line 146 of file Uri.h.

Referenced by clear(), host(), operator=(), and Uri().

◆ hostAddr_

Ip::Address AnyP::Uri::hostAddr_

Definition at line 148 of file Uri.h.

Referenced by clear(), host(), hostIP(), and operator=().

◆ hostIsNumeric_

bool AnyP::Uri::hostIsNumeric_

Definition at line 147 of file Uri.h.

Referenced by clear(), host(), hostIsNumeric(), and operator=().

◆ path_

SBuf AnyP::Uri::path_

Definition at line 153 of file Uri.h.

Referenced by operator=(), and path().

◆ port_

unsigned short AnyP::Uri::port_

Definition at line 150 of file Uri.h.

Referenced by clear(), operator=(), and port().

◆ scheme_

AnyP::UriScheme AnyP::Uri::scheme_
The scheme of this URL. This has the 'type code' smell about it. In future we may want to make the methods that dispatch based on the scheme virtual and have a class per protocol.
On the other hand, having Protocol as an explicit concept is useful, see for instance the ACLProtocol acl type. One way to represent this is to have one prototype URL with no host etc for each scheme, another is to have an explicit scheme class, and then each URL class could be a subclass of the scheme. Another way is one instance of a AnyP::UriScheme class instance for each URL scheme we support, and one class for each manner of treating the scheme : a Hierarchical URL, a non-hierarchical URL etc.
Deferring the decision, its a type code for now. RBC 20060507.
In order to make taking any of these routes easy, scheme is private, only settable at construction time, or with explicit setter

Definition at line 140 of file Uri.h.

Referenced by clear(), getScheme(), operator=(), path(), and setScheme().

◆ userInfo_

SBuf AnyP::Uri::userInfo_

Definition at line 142 of file Uri.h.

Referenced by operator=(), and userInfo().

The documentation for this class was generated from the following files:






Web Site Translations