johnie_44525
Oct 07, 2011Nimbostratus
how to mantain iRule HTTP::query case sensitivity
I am trying to resolve a case sensitivity issue with my iRule.
currently, the iRule parses a URL and forwards the URI to the matching site.
here the problem:
- if the parsed URL has mixed upper and lower case, the forwarding URI is only low case.
How can I change the irule to mantain case sensitivity? I see that the "HTTP_REQUEST" uses a [string tolower [HTTP::query]]. should I just remove the "tolower" value?
Any Help would be great!!!
when HTTP_REQUEST {
if {$static::debug}{log -noname *.*.*.* local0.info ""}
if {$static::debug}{log -noname *.*.*.* local0.info "Entering HTTP REQUEST"}
if {$static::debug}{log -noname *.*.*.* local0.info "Raw Request: [HTTP::request]"}
set rawquery [string tolower [HTTP::query]]
if { $rawquery starts_with "https"}{
set host [findstr $rawquery "https://" 8 "/"]
if {$static::debug}{log -noname *.*.*.* local0.info "Value of SSL Host: $host"}
} else {
set host [findstr $rawquery "http://" 7 "/"]
if {$static::debug}{log -noname *.*.*.* local0.info "Value of Host: $host"}
}
if {[class match $host starts_with exempted]}{
if {$static::debug}{log -noname *.*.*.* local0.info "Matched List of Exempted"}
if {$static::debug}{log -noname *.*.*.* local0.info "Raw Query: $rawquery Host: $host"}
HTTP::respond 200
event disable all
return
}
if {[HTTP::uri] equals "/?"}{
log -noname *.*.*.* local0.info "HTTP URI only contained: [HTTP::uri]"
HTTP::respond 200
event disable all
return
}
if {$static::debug}{log -noname *.*.*.* local0.info "Raw Query: $rawquery Host: $host"}
set rawhostip [RESOLV::lookup @*.*.*.* $host]
set hostip [getfield $rawhostip " " 1]
if {$static::debug}{log -noname *.*.*.* local0.info "RawHost IP: $rawhostip"}
if {$static::debug}{log -noname *.*.*.* local0.info "Host IP: $hostip"}
if {$static::debug}{log -noname *.*.*.* local0.info "Host IP: $hostip"}
if { $rawquery starts_with "https"}{
set port 443
set hostlen [expr [string length $host] + 8]
set hostremoved [findstr $rawquery "https://" $hostlen]
if {$static::debug}{log -noname *.*.*.* local0.info "Value of SSL port: $port hostlen: $hostlen hostremoved: $hostremoved"}
} else {
set port 80
set hostlen [expr [string length $host] + 7]
set hostremoved [findstr $rawquery "http://" $hostlen]
if {$static::debug}{log -noname *.*.*.* local0.info "Value of SSL port: $port hostlen: $hostlen hostremoved: $hostremoved"}
}
if {$static::debug}{log -noname *.*.*.* local0.info "Host Len: $hostlen Host Removed: $hostremoved"}
if {$static::debug}{log -noname *.*.*.* local0.info "Host Len: $hostlen Host Removed: $hostremoved"}
if { $hostremoved ne "" }{
if {$static::debug}{log -noname *.*.*.* local0.info "hostremoved not empty. Changing URI to: $hostremoved"}
HTTP::uri $hostremoved
} else {
if {$static::debug}{log -noname *.*.*.* local0.info "hostremoved empty. Changing URI to /"}
HTTP::uri "/"
}
if {$static::debug}{log -noname *.*.*.* local0.info "Changing Host Header to: $host"}
HTTP::header replace "Host" $host
if { $hostip ne "" }{
if {$static::debug}{log -noname *.*.*.* local0.info "hostip isn't empty. Sending traffic to: $hostip:$port"}
node $hostip $port
log -noname *.*.*.* local0.info "Request to $rawquery sent to $host at IP $hostip"
}
}