HTTP Request Cloning via iRules, Part 1
I implemented the below in my lab environement. I am able get the traffic at test server but getting the java.io.StreamCorruptedException: invalid stream header: C2ACC3AD means data is corrupted somewhere. Cam somebody help me
when HTTP_REQUEST { if {[HTTP::header exists Authorization]} { if { [HTTP::username] equals "xxxxx@xxxx" } { discard } } set hsl [HSL::open -proto UDP -pool pfl2_metrics] log local0. "[IP::client_addr]:[TCP::client_port]: New hsl: $hsl switch -glob [HTTP::uri] { "/uri1" - "/uri1" { switch -glob [HTTP::uri] { "/controller/instance/*/metrics" - "/controller/instance//metrics" { HTTP::header insert "backend" "$poolname"" if {[HTTP::method] eq "POST"} {
Check for Content-Length between 1b and 1Mb if { [HTTP::header Content-Length] >= 1 && [HTTP::header Content-Length] < 1048576 }{
HTTP::collect [HTTP::header Content-Length]
}
elseif {[HTTP::header Content-Length] == 0}{
POST with 0 content-length, so just send the headers
HSL::send $hsl [HTTP::request]
log local0. "[IP::client_addr]:[TCP::client_port]: Sending [HTTP::request]"
}
}
else
{
Request with no payload, so send just the HTTP headers to the clone pool
HSL::send $hsl [HTTP::request]
log local0. "[IP::client_addr]:[TCP::client_port]: Sending [HTTP::request]" }
Debugging only log local0. "Inserted header [HTTP::header "backend"]" pool ${dis_cluster}
}
"URI2*" {
pool ${poolname}_xxxx
}
"URI3*" {
pool ${poolname}_xxxxx
}
"URI4*" -
"URI5*" -
"URI6*" -
"URI7*" -
"URI8*" {
pool ${poolname}_xxxx
}
"/controller/sim/*/user*" {
pool ${poolname}
}
default {
pool ${poolname}_xxxxxxx
}
}
}
"URI9*" {
pool ${poolname}_xxxxxxxx
}
"/URI10*" {
pool ${poolname}_xxxxxxxxx
}
"cURI11*" {
pool ${poolname}_xxxxxxxxxxx
}
default {
pool ${poolname}
}
}
}
default {
pool ${poolname}
}
}
}
when HTTP_REQUEST_DATA { The parser does not allow HTTP::request in this event, but it works set request_cmd "HTTP::request" log local0. "[IP::client_addr]:[TCP::client_port]: Collected [HTTP::payload length] bytes,\ sending [expr {[string length [eval $request_cmd]] + [HTTP::payload length]}] bytes total" HSL::send $hsl "[eval $request_cmd][HTTP::payload]" }
}