Forum Discussion
uni
Altostratus
Feb 20, 2008Different behaviour with HTTP::path and URI::path
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 ...
hoolio
Cirrostratus
Feb 21, 2008Maybe 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...
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects