Forum Discussion
johns
Employee
Mar 02, 2006iRule recognize blank space in URI?
Hi, I need to detect blank space in URI and either remove it or rewrite it:
www.mysite.com/some content/showme.html
to
www.mysite.com/some%20content/showme.html
...
johns
Employee
Mar 28, 2006I ended up with:
when CLIENT_ACCEPTED {
TCP::collect 100
}
when CLIENT_DATA {
Grab characters b/w GET and HTTP version
set matchedURI [regexp -inline "/vMoD.+HTTP" [TCP::payload]]
Find the length of payload up to GET to use as offset
if { [string length $matchedURI] > 0 } {
Parse the URI and convert spaces to %20
set newURI [getfield [getfield $matchedURI " HTTP" 1] "\{" 2]
set encURI [string map { " " %20} $newURI]
Replace the URI with space with the encoded URI
4 is used as offset, counting "GET ", cound not think of better way
TCP::payload replace 4 [string length $newURI] $encURI
log local0. "encURI is $encURI"
set uriRewrite 1
} else {
set uriRewrite 0
log local0. "no match"
}
}
when HTTP_REQUEST {
verify URI is converted as needed with HTTP parser
if {$uriRewrite == 1} {
log local0. "It worked! [HTTP::uri]"
}
}
and it seems to work if I try it with browser (space already encoded since telnet does not seem to let the rule process into HTTP_REQUEST for verification) Would you mind giving me an eyeball on it?
Thanks.
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
