Forum Discussion
skbartl_85400
Nimbostratus
Mar 26, 2008Determine URI after setting with HTTP::uri
I have an iRule that uses HTTP::uri to rewrite part of the original URI. For debugging purposes, I would like to write out the value of the new URI to the log. Below is the basic gist of my iRule:
------------------------------------------
log local.0 "URI before: [HTTP::uri]"
HTTP::uri $new_uri
log local.0 "URI after: [HTTP::uri]"
------------------------------------------
The log entries for before and after both have the original URI, not the new URI. Is there any way to get the value of the new URI after changing it with HTTP::uri (in the context of HTTP_REQUEST)? I did find a workaround with the following code, but I was hoping to find a more elegant solution.
------------------------------------------
when HTTP_REQUEST_SEND {
clientside { log local0. "New URI: [HTTP::uri]" }
}
------------------------------------------
Any ideas?
Thanks!
Steve
- The_Bhattman
Nimbostratus
Try thislog local0. "URI before: [HTTP::uri]" set new_uri "[HTTP::uri]\blah\blah" log local0. "URI after: $new_uri"
- skbartl_85400
Nimbostratus
That doesn't seem to assign anything to the variable. It looks like when HTTP::uri is used in the context of setting the uri (vs. reading it), the return value is not the new URI, but rather the status of the assignment. - hoolio
Cirrostratus
The value for HTTP::uri and most other HTTP:: commands is cached in the same event and priority. So even if you modify the URI with HTTP::uri, logging the value of HTTP::uri will still return the original value. As cmbhatt pointed out, you can save the new value to a variable and then log it. Or to double check the change, you can add a log statement in HTTP_REQUEST priority 501. This should be removed once you're done testing as it adds unnecessary load.
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