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 etrieve 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
FTP URLs have the form:
ftp://user:password@host:port/path;type=val
The URL port and FTP type are stored as integers. 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 INKUrlHostGet
.
To facilitate fast comparisons and reduce storage size, Traffic Server defines several preallocated scheme names.
Traffic Server Definition | Pre-Allocated Scheme Name | URL Scheme String Lengths |
INK_URL_SCHEME_FILE |
“file” | INK_URL_LEN_FILE |
INK_URL_SCHEME_FTP |
“ftp” | INK_URL_LEN_FTP |
INK_URL_SCHEME_GOPHER |
“gopher” | INK_URL_LEN_GOPHER |
INK_URL_SCHEME_HTTP |
“http” | INK_URL_LEN_HTTP |
INK_URL_SCHEME_HTTPS |
“https” | INK_URL_LEN_HTTPS |
INK_URL_SCHEME_MAILTO |
“mailto” | INK_URL_LEN_MAILTO |
INK_URL_SCHEME_NEWS |
“news” | INK_URL_LEN_NEWS |
INK_URL_SCHEME_NNTP |
“nntp” | INK_URL_LEN_NNTP |
INK_URL_SCHEME_PROSPERO |
“prospero” | INK_URL_LEN_PROSPERO |
INK_URL_SCHEME_TELNET |
“telnet” | INK_URL_LEN_TELNET |
INK_URL_SCHEME_WAIS |
“wais” | INK_URL_LEN_WAIS |
The scheme names above are defined in InkAPI.h
as const
char*
strings. 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
INKUrlSchemeGet
with one of the values listed above. You should
use the Traffic Server-defined values when referring to one of
the known schemes, since it prevents possible spelling errors.
The URL functions are listed below:
INKUrlClone
INKUrlCopy
INKUrlCreate
INKUrlDestroy
INKUrlPrint
INKUrlFtpTypeGet
INKUrlFtpTypeSet
INKUrlHostGet
INKUrlHostSet
INKUrlHttpFragmentGet
INKUrlHttpFragmentSet
INKUrlHttpParamsGet
INKUrlHttpParamsSet
INKUrlHttpQueryGet
INKUrlHttpQuerySet
INKUrlLengthGet
INKUrlParse
INKUrlPasswordGet
INKUrlPasswordSet
INKUrlPathGet
INKU
r
lPathSet
INKUrlPortGet
INKUrlPortSet
INKUrlSchemeGet
INKUrlSchemeSet
INKUrlStringGet
INKUrlUserGet
INKUrlUserSet