Forum Discussion
Ken_Wong_48678
Sep 20, 2005Historic F5 Account
change content type by irule
Hi guys,
I have written a test irule to change the content type of a specific page. I would like to change the content type of main.css from text/css to application/x-javascript.
...
Sep 20, 2005
When creating variables that you want to persist across multiple events, you'll need to access them in the global namespace (with the "::" prefix).
Here's an example:
when HTTP_REQUEST {
set this_variable_is_local 1
set ::this_variable_is_global 1
}
when HTTP_RESPONSE {
This will fail as this_variable_is_local isn't defined in this scope
if { [info exists this_variable_is_local] } {
if { $this_variable_is_local == 1 } {
}
}
This should succeed.
if { [info exists ::this_variable_is_global] } {
if { $::this_variable_is_global == 1 } {
log local0. "Found this_variable_is_global"
}
}
}
Note, You should always use the "info exists" command before you access a variable that you are unsure exists to avoid runtime errors.
-Joe
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