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 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"
}
}
if I call it's virtual:curl http://192.168.1.2/path/morepath/base.htm?query
I get the following response: HTTP path /path/morepath/base.htm
URI path /path/morepath/
Do I misunderstand something here, or is this a bug? I'm running 9.3.0, so maybe this issue has been fixed.
- Nicolas_Menant
Employee
Hi
this is no bug,
if you look at the wiki: https://devcentral.f5.com/questions/different-behaviour-with-httppath-and-uripath
HTTP::path is used to retrieve the URI without any parameter that may be within.
Best regards
Nicolas
- uni
Altostratus
Yes, the wiki documents this inconsistent behaviour. - Nicolas_Menant
Employee
Since it's documented in the wiki as it behaves you can already consider it for not being a bug - uni
Altostratus
In the absence of any evidence to the contrary, it's bad design then. - hoolio
Cirrostratus
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.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]"
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