URLs¶
API URL functions provide access to URL data stored in marshal buffers. The URL functions can create, copy, retrieve or delete entire URLs; they can also retrieve or modify parts of URLs, such as port or scheme information.
The general form of an Internet URL is:
scheme://user:password@host:port/stuff
The URL data structure includes support for two specific types of internet URLs. HTTP URLs have the form:
http://user:password@host:port/path;params?query#fragment
The URL port is stored as integer. All remaining parts of the URL
(scheme, user, etc.) are stored as strings. Traffic Server URL functions
are named according to the portion of the URL on which they operate. For
instance, the function that retrieves the host portion of a URL is named
TSUrlHostGet
.
To facilitate fast comparisons and reduce storage size, Traffic Server defines several preallocated scheme names.
- “file”
-
char const *TS_URL_SCHEME_FILE¶
-
int TS_URL_LEN_FILE¶
-
char const *TS_URL_SCHEME_FILE¶
- “ftp”
-
char const *TS_URL_SCHEME_FTP¶
-
int TS_URL_LEN_FTP¶
-
char const *TS_URL_SCHEME_FTP¶
- “gopher”
-
char const *TS_URL_SCHEME_GOPHER¶
-
int TS_URL_LEN_GOPHER¶
-
char const *TS_URL_SCHEME_GOPHER¶
- “http”
-
char const *TS_URL_SCHEME_HTTP¶
-
int TS_URL_LEN_HTTP¶
-
char const *TS_URL_SCHEME_HTTP¶
- “https”
-
char const *TS_URL_SCHEME_HTTPS¶
-
int TS_URL_LEN_HTTPS¶
-
char const *TS_URL_SCHEME_HTTPS¶
- “mailto”
-
char const *TS_URL_SCHEME_MAILTO¶
-
int TS_URL_LEN_MAILTO¶
-
char const *TS_URL_SCHEME_MAILTO¶
- “news”
-
char const *TS_URL_SCHEME_NEWS¶
-
int TS_URL_LEN_NEWS¶
-
char const *TS_URL_SCHEME_NEWS¶
- “nntp”
-
char const *TS_URL_SCHEME_NNTP¶
-
int TS_URL_LEN_NNTP¶
-
char const *TS_URL_SCHEME_NNTP¶
- “prospero”
-
char const *TS_URL_SCHEME_PROSPERO¶
-
int TS_URL_LEN_PROSPERO¶
-
char const *TS_URL_SCHEME_PROSPERO¶
- “telnet”
-
char const *TS_URL_SCHEME_TELNET¶
-
int TS_URL_LEN_TELNET¶
-
char const *TS_URL_SCHEME_TELNET¶
- “wais”
-
char const *TS_URL_SCHEME_WAIS¶
-
int TS_URL_LEN_WAIS¶
-
char const *TS_URL_SCHEME_WAIS¶
- “ws”
-
char const *TS_URL_SCHEME_WS¶
-
int TS_URL_LEN_WS¶
-
char const *TS_URL_SCHEME_WS¶
- “wss”
-
char const *TS_URL_SCHEME_WSS¶
-
int TS_URL_LEN_WSS¶
-
char const *TS_URL_SCHEME_WSS¶
The scheme names above are defined in apidefs.h
. When Traffic Server sets the scheme portion of
the URL (or any portion for that matter), it quickly checks to see if the new value is one of the
known values. If it is, then it stores a pointer into a global table (instead of storing the known
value in the marshal buffer). The scheme values listed above are also pointers into this table. This
allows simple pointer comparison of the value returned from TSUrlSchemeGet
or
TSUrlRawSchemeGet
with one of the values listed above. You should use the Traffic Server-defined
values when referring to one of the known schemes, since doing so can prevent the possibility of
spelling errors.
Traffic Server URL functions are listed below:
TSUrlClone()
TSUrlCopy()
TSUrlCreate()
TSUrlPrint()
TSUrlFtpTypeGet()
TSUrlFtpTypeSet()
TSUrlHostGet()
TSUrlHostSet()
TSUrlHttpFragmentGet()
TSUrlHttpFragmentSet()
TSUrlHttpQueryGet()
TSUrlHttpQuerySet()
TSUrlLengthGet()
TSUrlParse()
TSUrlPasswordGet()
TSUrlPasswordSet()
TSUrlPathGet()
TSUrlPathSet()
TSUrlPortGet()
TSUrlRawPortGet()
TSUrlPortSet()
TSUrlSchemeGet()
TSUrlSchemeSet()
TSUrlStringGet()
TSUrlUserGet()
TSUrlUserSet()