Uri.cc File Reference
#include "squid.h"
#include "anyp/Uri.h"
#include "globals.h"
#include "HttpRequest.h"
#include "rfc1738.h"
#include "SquidConfig.h"
#include "SquidString.h"
Include dependency graph for Uri.cc:

Go to the source code of this file.

Classes

class  URLHostName
 

Functions

void urlInitialize (void)
 
AnyP::ProtocolType urlParseProtocol (const char *b)
 
char * urlCanonicalCleanWithoutRequest (const SBuf &url, const HttpRequestMethod &method, const AnyP::UriScheme &scheme)
 
const char * urlCanonicalFakeHttps (const HttpRequest *request)
 
bool urlIsRelative (const char *url)
 
char * urlMakeAbsolute (const HttpRequest *req, const char *relUrl)
 
int matchDomainName (const char *h, const char *d, uint8_t flags)
 
int urlCheckRequest (const HttpRequest *r)
 
char * urlHostname (const char *url)
 

Variables

static const char valid_hostname_chars_u []
 
static const char valid_hostname_chars []
 

Function Documentation

◆ matchDomainName()

int matchDomainName ( const char *  host,
const char *  domain,
uint8_t  flags = mdnNone 
)

matchDomainName() matches a hostname (usually extracted from traffic) with a domainname when mdnNone or mdnRejectSubsubDomains flags are used according to the following rules:

HOST DOMAIN mdnNone mdnRejectSubsubDomains
foo.com foo.com YES YES
.foo.com foo.com YES YES
x.foo.com foo.com NO NO
foo.com .foo.com YES YES
.foo.com .foo.com YES YES
x.foo.com .foo.com YES YES
.x.foo.com .foo.com YES NO
y.x.foo.com .foo.com YES NO

if mdnHonorWildcards flag is set then the matchDomainName() also accepts optional wildcards on hostname:

HOST DOMAIN MATCH?
*.foo.com x.foo.com YES
*.foo.com .x.foo.com YES
*.foo.com .foo.com YES
*.foo.com foo.com NO

The combination of mdnHonorWildcards and mdnRejectSubsubDomains flags is supported.

Return values
0means the host matches the domain
1means the host is greater than the domain
-1means the host is less than the domain

Definition at line 660 of file Uri.cc.

References mdnHonorWildcards, mdnRejectSubsubDomains, and xtolower.

Referenced by aclHostDomainCompare(), check_domain(), ClientRequestContext::hostHeaderVerify(), neighborType(), and urlInitialize().

◆ urlCanonicalCleanWithoutRequest()

char* urlCanonicalCleanWithoutRequest ( const SBuf url,
const HttpRequestMethod method,
const AnyP::UriScheme scheme 
)
Todo:
AYJ: Performance: This is an almost duplicate of HttpRequest::effectiveRequestUri(). But elides the query-string. After copying it on in the first place! Would be less code to merge the two with a flag parameter. and never copy the query-string part in the first place

Definition at line 518 of file Uri.cc.

References buf, Config, LOCAL_ARRAY, MAX_URL, Http::METHOD_CONNECT, SquidConfig::onoff, AnyP::PROTO_URN, rfc1738_escape_unescaped, SQUIDSBUFPH, SQUIDSBUFPRINT, stringHasCntl(), SquidConfig::strip_query_terms, and xstrncpy().

Referenced by HttpRequest::canonicalCleanUrl(), operator<<(), ClientHttpRequest::setErrorUri(), and ClientHttpRequest::setLogUriToRawUri().

◆ urlCanonicalFakeHttps()

const char* urlCanonicalFakeHttps ( const HttpRequest request)

Yet another alternative to urlCanonical. This one adds the https:// parts to Http::METHOD_CONNECT URL for use in error page outputs. Luckily we can leverage the others instead of duplicating.

Definition at line 547 of file Uri.cc.

References buf, HttpRequest::canonicalCleanUrl(), AnyP::Uri::host(), LOCAL_ARRAY, MAX_URL, HttpRequest::method, Http::METHOD_CONNECT, AnyP::Uri::port(), and HttpRequest::url.

Referenced by ErrorState::Convert(), and operator<<().

◆ urlCheckRequest()

◆ urlHostname()

char* urlHostname ( const char *  url)

Definition at line 858 of file Uri.cc.

References URLHostName::extract(), URLHostName::Host, and SQUIDHOSTNAMELEN.

Referenced by htcpTstReply(), and urnParseReply().

◆ urlInitialize()

void urlInitialize ( void  )

◆ urlIsRelative()

bool urlIsRelative ( const char *  url)

Definition at line 568 of file Uri.cc.

References NULL, and p.

Referenced by operator<<(), and purgeEntriesByHeader().

◆ urlMakeAbsolute()

◆ urlParseProtocol()

AnyP::ProtocolType urlParseProtocol ( const char *  b)

Parse the scheme name from string b, into protocol type. The string must be 0-terminated.

Definition at line 123 of file Uri.cc.

References len, AnyP::PROTO_CACHE_OBJECT, AnyP::PROTO_COAP, AnyP::PROTO_COAPS, AnyP::PROTO_FTP, AnyP::PROTO_GOPHER, AnyP::PROTO_HTTP, AnyP::PROTO_HTTPS, AnyP::PROTO_NONE, AnyP::PROTO_UNKNOWN, AnyP::PROTO_URN, AnyP::PROTO_WAIS, and AnyP::PROTO_WHOIS.

Referenced by AnyP::Uri::parse().

Variable Documentation

◆ valid_hostname_chars

const char valid_hostname_chars[]
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789-."
"[:]"

Definition at line 25 of file Uri.cc.

Referenced by AnyP::Uri::parse().

◆ valid_hostname_chars_u

const char valid_hostname_chars_u[]
static
Initial value:
=
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"abcdefghijklmnopqrstuvwxyz"
"0123456789-._"
"[:]"

Definition at line 19 of file Uri.cc.

Referenced by AnyP::Uri::parse().

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors