Forum Discussion
CraigM_17826
Altocumulus
Dec 02, 2009Very odd behaviour when URI contains a - or _ in a string you are checking for
Hi everyone,
I think I have come across an odd issue with using string compares for selecting pools. I am checking for a specfic piece of text in a URL and if it is found it will use a certain pool. If the pool members are down then it will use an alternate pool. Here is the code extract fro within the HTTP_REQUEST context
if { [string tolower [HTTP::uri]] contains "/exam-services" } {
if { [active_members "ExamServices"] > 0 } {
pool "ExamServices"
return 0
} else {
HTTP::redirect "http://server1.acme.com/exam-services"
pool "ExamServices_Error"
return 0
}
}
This is what happens
www.acme.com/exam-services (fails)
www.acme.com/exam-serices/ (works)
When it fails, I get the following error from WebSphere
SRVE0255E: A WebGroup/Virtual Host to handle /exam%2Dservices/ has not been defined.
SRVE0255E: A WebGroup/Virtual Host to handle www.acme.com:10040 has not been defined.
What is odd is that WebSphere is showing the URI as exam%2Dserices. Why it is doing this is odd, and why adding a trailing / to the URI causes it to work.
Now I do have a lot of other URI compararions and they all work but I jsut realised this particular URI comparison the ONLY one which has a -in the URI. So I changed the test to check for examservices and made th required change and it now works
www.acme.com/examservices
www.acme.com/examservices/
So I am now wondering why the - character is causing the string comparison is causing the pool based connection to act this way. Out of interest I put the search string back to exam-services and changed the piece of code to use a http::redirect instead of pool and it worked fine, though a redirect is not what I require.
I have since done some tests using _ and . in the string with the following results
www.acme.com/exam_services
(fails with SRVE0255E: A WebGroup/Virtual Host to handle /exam%5Fservices/ has not been defined)
www.acme.com/exam_services/ (works)
www.acme.com/exam.services (works)
So whatever this issue is it is only manifesting itself when I use either a - or _ in the URI.
Does anyone have any idea why this is occuring? Unfortunatley I have no control over the URI the company want's to use and our marketing people are adament it has to be /exam-services
I have also tried using starts_within the test with no changes, all of the above tests behave in the same way with the same results as when using contains
Regards
Craig
- The_Bhattman
Nimbostratus
Hi Craig,when HTTP_REQUEST { if { [string tolower [HTTP::uri]] contains "/exam-services" } { if { [active_members ExamServices] > 0 } { pool ExamServices } else { pool ExamServices_Error } } }
- The_Bhattman
Nimbostratus
Hi Brian,when HTTP_REQUEST { log local0. "This is the uri: [HTTP::uri] that the irule receives" if { [string tolower [HTTP::uri]] contains "/exam-services" } { if { [active_members ExamServices] > 0 } { pool ExamServices } else { pool ExamServices_Error } } }
- CraigM_17826
Altocumulus
Hi everyone, - CraigM_17826
Altocumulus
Hi all,
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