Forum Discussion
irfans_38826
Nimbostratus
Feb 28, 2008Search and replace a field in HTTP Header
I know iRules are capable of searching and replacing contents of a field in HTTP header, what I am wondering can it be done on dynamic content, in my case I am wondering if you can search for a particular field and change the case of data in it, so from upper case make it lower, or from lower case make it upper case
Following is example
Incoming request
x-up-calling-line-id:18583360321
x-up-subno:N_NBI_SDG_1184168037000100831348
Outgoing request
x-up-calling-line-id:18583360321
x-up-subno:n_nbi_sdg_1184168037000100831348
In this case data will always be in same field and of same length, what I am looking for is changing the case of data in that field.
I appreciate if someone know the answer if this is possible.
-Irfan
4 Replies
- hoolio
Cirrostratus
Hi,
If you want to perform a replacement with dynamically generated strings, I think you'd need to collect the request data and use regsub and a backreference to replace the matched content with the string set to lowercase. If the replacement strings are the same length as the existing strings, you can use the credit card scrubber rule (Click here) as an example for how to collect the data and replace the strings.
Does anyone know if it would be possible to manipulate the payload with a binary scan and a simpler string map + string tolower combination instead?
Aaron - irfans_38826
Nimbostratus
Aaron,
Thanks for replying back to me , my load balancing experience is limited to netscalers, so it seems like i can collect a data using regex and covert it to lowercase using tolower system call? Does F5 offer full regex in iRules?
-Irfan - hoolio
Cirrostratus
Yes. But there are some TCL-specific variations from standard PCRE regexes. This site has a decent summary (Click here)
To avoid having to escape meta-characters, you can wrap your regex in curly braces:
set my_regex {(?i)[\w]+?[0-9]}
Aaron - hoolio
Cirrostratus
I think I misread the original request. I thought he wanted to replace strings in the content. If it's headers, it should be simple like Stefan suggested:
HTTP::header replace $header_name [string tolower [HTTP::header value $header_name]]
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
