Forum Discussion
Need to grab variable data from HTTP::Location, then append that to the HTTP::Location
Gang,
I have an opportunity to solve yet another crapplication issue. The owners of a website need to have variable information read from their HTTP::Location header, then extracted and appended to the same HTTP::Location header so that the ingesting web service can properly process the incoming header information. Now that you're all confused, here's an example of what I need done:
Needs to change to this: Location: https://www.abc.com/lotsastuff/lotsastuff/lotsastuff/&redirect_uri=http%3A%2F%2Fwww.def.com%2F12345%2Fredirect_uri&nonce=Czh6KHqfsh5YLBV37JD4Upjsx44xAyQ-ODTKkP9HdGU&locale=12345
The "12345" is pulled from the five characters following "; That "12345" will change, but the "; will NOT change. I just need to grab that information from the five characters following "; and append that as the "locale=12345" to the header and send it out.
This will be in an HTTP_RESPONSE iRule.
I can append static information ("&stuff=1", in this case) using the following iRule: when HTTP_RESPONSE { if { [HTTP::is_redirect] && [string tolower [HTTP::header Location]] contains "; } { HTTP::header replace Location "[HTTP::header value Location]&stuff=1" } }
Now I need to extend that to grab variable information from the existing Location header.
Any help you can provide is appreciated. Please let me know if I can help clarify my ask in any way.
Thanks.
Joe
- Stanislas_Piro2
Cumulonimbus
Hi,
you can try this code:
when HTTP_RESPONSE { if { [HTTP::is_redirect] && [string tolower [HTTP::header Location]] contains "www.def.com" } { set redirect_uri [URI::decode [URI::query [HTTP::uri] redirect_uri]] scan $redirect_uri {http://www.def.com/%[^/]/} locale HTTP::header replace Location "[HTTP::header value Location]&locale=$locale" } }
Recent Discussions
Related Content
* 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