agidwani_102403
Feb 25, 2008Nimbostratus
STREAM::max_matchsize - HELP - Urgent
All,
We are trying to do a URI rewrite and are running into some kind of buffer limitation with streams.
We get a error message when using the following streams directive
STREAMS::max_matchsize 8192
01070151:3: Rule [global_rewrite] error:
line 21: [command is not valid in current event context (HTTP_REQUEST)] [STREAM::max_matchsize 8192]
---------------------------------------------------------
when HTTP_REQUEST {
set uri [string tolower [HTTP::uri]]
if { ($uri contains "/global/") }
{ pool acecomm }
elseif { ($uri contains "/AC4AC/") or
($uri contains "/awchs54beta/")
}
{
if { $uri contains "/hscs.asmx" } {
pool acecomm
Change the URI of the request, preserving the query arguments, if any.
set args [findstr $uri "?"]
HTTP::uri "/global/hscs.asmx$args"
if {[HTTP::method] equals "POST"} {
Look for /*/hscs.asmx and replace * with "global"
(if you change "global" here you need to change the hard-coded length of 6 below)
Note that this does not fix the Content-Length so we need to do that below
STREAM::expression {@/[^/]*/[Hh][Ss][Cc][Ss].[Aa][Ss][Mm][Xx]@/global/hscs.asmx@}
STREAM::enable
Determine what the original path was
set origpath [findstr $uri "/" 1 "/"]
Store original content-length for POST data
set origlen [HTTP::header "Content-Length"]
Assume replacement string ("global") is 6 characters long, determine difference in
length between "global" and the replacement path
set length_change [expr {6 - [string length $origpath] } ]
set newlen [expr {$origlen + $length_change}]
Set new content length, assuming the stream profile performed exactly one replacement
HTTP::header remove "Content-Length"
HTTP::header insert "Content-Length" [expr {$origlen + $length_change}]
log local0. "origpath=$origpath, change=$length_change, origlen=$origlen"
log local0. "Content length after: [HTTP::header Content-length]"
}
}
}
}