I have noticed a difference in behaviour between the HTTP::path and URI::path commands.
I expected that [HTTP::path] would return the same result as [URI::path [HTTP::uri]], but HTTP::path includes the basename, whereas URI::path does not.
Given my rule below
rule test-rule {
when HTTP_REQUEST {
HTTP::respond 200 content "HTTP path [HTTP::path]\n URI path [URI::path [HTTP::uri]]\n\n"
}
}
The DevCentral Wiki offers a location for F5 and users to contribute documentation, tips, samples, and other best practices for working with F5 products. While hosted through F5 DevCentral, this is not the official documentation for F5 products.
Maybe the naming convention isn’t very intuitive, but it’s very nice to have each of the three commands: HTTP::uri to get the full URI, HTTP::path to get the URI minus the query string, and URI::path to get the path without the object name or file extension. The commands haven’t changed since they were introduced. So no, I don’t think there are any bugs or issues with documentation. It’s just not the most intuitive names.
Aaron
[edit: I just ran into an issue where I was trying to get the path for a URL that wasn’t the one the client requested. I guess I see your point that it would be nice if URI::path $url returned just the path (ie, the URI minus the query string).
Here is a bit of a hack to get the URI and the path for a static string (where you can’t use HTTP::path or HTTP::uri):
set url http://example.com/path/file.html?param=val
Get the URI for a URL without using HTTP::uri (parses: /path/file.html?param=val)
log local0. "URI: [getfield $url [URI::protocol $url]://[URI::host $url] 2]"
Get the path for a URL without using HTTP::path (parses: /path/file.html)
log local0. "path: [getfield [getfield $url [URI::protocol $url]://[URI::host $url] 2] "?" 1]"
This might not be the most optimal solution, but it works…