Forum Discussion
Danielseyoum
Jul 26, 2007Altostratus
Case sensitivity challenge
I have application that is case sensitive and I have to make sure the case is formated in a way the application will respond.
incoming uri:
/about us --> should be --> /About Us
/corpcomm --> should be --> /CorpComm
/leading the path --> should be --> /Leading the Path
The requirement is for users to type in any case format and iRule to format it in a way the app understand.....
Thanks in advance
- Chris_Seymour_1Historic F5 AccountDaniel,
- Are those requests in the URI or in the payload? It's tricky, but it can be done with a lot of TCL string manipulation. I'll see what I can whip up.
- DanielseyoumAltostratusIt's in the uri.
- Deb_Allen_18Historic F5 AccountStream profile will only work against response data, so that won't do the inbound URI re-writing you need. (But hold that thought, you might need to use it to re-write links in the response -- more on that later.)
class URImap { "about%20us About%20Us" "corpcomm CorpComm" "leading%20the%20path Leading%20the%20Path" }
Here's a post on a similar topic, a few more complexities but overall similar to yours:rule iRule_URI_mapping { when HTTP_REQUEST { set OldRootDir [string tolower [getfield [HTTP::uri] "/" 2]] set NewRootDir [findclass $OldDir1 $::URImap " "] if {$NewRootDir != ""}{ prepend portal path to requested URI & re-write URI with proper case HTTP::uri /irj/portal[string map -nocase [list $OldRootDir $NewRootDir] [HTTP::uri]] } } }
- DanielseyoumAltostratusThanks for the guidance....
- Remove the "-nocase" flag as that isn't supported in iRules.
when HTTP_REQUEST { set new_uri "/" set args [split [string map { "%20" " " } [lindex [split [HTTP::uri] "/"] 1]] " "] for {set i 0} {$i < [llength $args]} {incr i} { set arg [lindex $args $i] if { $arg ne "" } { set CamelCaseToken [string replace $arg 0 0 [string toupper [string range $arg 0 0]]] if { $new_uri eq "/" } { set new_uri "${new_uri}${CamelCaseToken}" } else { set new_uri "${new_uri}%20${CamelCaseToken}" } } else { set new_uri "${new_uri}%20" } } HTTP::uri $new_uri }
http://www.foo.com/hi there -> http://www.foo.com/%20Hi%20There
when HTTP_REQUEST { set new_uri "" Split the URI into it's directories set dirs [split [HTTP::uri] "/"] Loop over all the directories for {set i 0} {$i < [llength $dirs]} {incr i} { set dir [lindex $dirs $i] if { $dir ne "" } { Convert all %20's into Spaces, and then split by that space If we kept %20s the split would return a bunch of empty elements set args [split [string map { "%20" " " } $dir]] set new_sub_dir "" set content_added 0 Loop over all the different words in each directory for {set j 0} {$j < [llength $args]} {incr j} { set arg [lindex $args $j] if { $arg ne "" } { Check for special words that you don't want capitolized switch $arg { "the" - "of" { set CamelCaseToken $arg } default { set CamelCaseToken [string replace $arg 0 0 [string toupper [string range $arg 0 0]]] } } if { $content_added eq 0 } { set new_sub_dir "${new_sub_dir}${CamelCaseToken}" } else { set new_sub_dir "${new_sub_dir}%20${CamelCaseToken}" } set content_added 1 } else { set new_sub_dir "${new_sub_dir}%20" } } set new_uri "${new_uri}/${new_sub_dir}" } } HTTP::uri $new_uri }
http://www.foo.com/hi there/how are you
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