Jukka_Vaisanen_
May 03, 2007Nimbostratus
Matching binary data with NULLs from HTTP post data
I need to be able to select a different pool if a HTTP POST contains a certain string. However the HTTP post data is completely arbitrary binary mush and in there I need to pick out a series of bytes followed by a string of ascii characters and terminated by a NULL (0x00).
My understanding is that TCL strings are semi-8-bit clean.. they can contain 8 bit characters but not NULLs. So what can I do in this case? Below is my first attempt which however doesn't seem to work (not surprised).
when HTTP_REQUEST {
if { [HTTP::method] == "POST" } {
HTTP::collect [HTTP::header Content-Length]
}
}
when HTTP_REQUEST_DATA {
if { [HTTP::payload] matches_regex "\x03\xB0(.*)\x00" } {
pool B_pool
} else {
pool A_pool
}
HTTP::release
}