Forum Discussion
Karthik_124840
Mar 18, 2014Nimbostratus
How to check if response contains a specific string using IRules
Hi All,
I have a requirement to change a cookie attribute if the http response has a specific string in it. Can anyone please let me know how it can acheived ?
Kevin_Stewart
Mar 18, 2014Employee
I may be interpreting your requirement a little differently, but if you're asking to change a (set)cookie value based on some matching content in the response, here's an option:
when HTTP_RESPONSE {
if { [HTTP::header Content-Type] contains "text" } {
HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_RESPONSE_DATA {
if { [HTTP::payload] contains "diam" } {
if { [HTTP::cookie exists JSESSIONID] } {
HTTP::cookie value JSESSIONID "foobar"
}
}
}
This can get tricky based on where you might find this data and how large the response payload is. Collecting all of the response payload can cause a performance hit.
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