URI::host¶
Description¶
Returns the host portion of a given URI.
Examples¶
when RULE_INIT {
# Loop through some test URLs and URIs and log the URI::host value
foreach uri [list \
http://example.com/file.ext \
http://example.com:80/file.ext \
https://example.com:443/file.ext \
ftp://example.com/file.ext \
sip://example.com/file.ext \
myproto://example.com/file.ext \
/example.com \
/uri?url=http://example.com/uri \
] {
log local0. "\[URI::host $uri\]: [URI::host $uri]"
}
}
# Log output:
[URI::host http://example.com/file.ext]: example.com
[URI::host http://example.com:80/file.ext]: example.com
[URI::host https://example.com:443/file.ext]: example.com
[URI::host ftp://example.com/file.ext]: example.com
[URI::host sip://example.com/file.ext]: example.com
[URI::host myproto://example.com/file.ext]: example.com
[URI::host /example.com]:
[URI::host /uri?url=http://example.com/uri]:
Sample log output from the above rule:
- Host of url http://www.foo.com/app/file.ext is www.foo.com
- Protocol of url http://www.foo.com/app/file.ext is http