iRule to insert header ntCoent-Length based in URI
Hello everyone, this time I ask for your help because I am trying to find the way to insert a header named ntCoent-Length which contains the total length in bytes of the content requested. I am balancing the pools based with URIs, which are contained in datagroups, so this insert just should be with certain URIs, contained in this example in the datagroup_C. I designed this iRule but when I tried to log the value it doesn't return nothing, so I am pretty sure it is not inserting the header and the value.
when HTTP_REQUEST {
if { [class match [HTTP::uri] starts_with "datag_A"] } {
pool Pool_A
} elseif { [class match [HTTP::uri] starts_with "datag_B"] } {
pool Pool_B
} elseif { [class match [HTTP::uri] starts_with "datag_C"] } {
HTTP::collect
set urimatch 1
pool Pool_C
} elseif {
pool Pool_default
}
}
when HTTP_RESPONSE_DATA {
if { [info exists urimatch] } {
set ntCoent [HTTP::payload length]
HTTP::release
}
}
when HTTP_RESPONSE {
if { [info exists urimatch] } {
HTTP::header insert ntCoent-Length $ntCoent
log local0. "HTTP ntCoent-Length header = [HTTP::header value "ntCoent-Length"]"
}
}
I have tried a lot of iRules, but it seems this is closer, I also tried to do it by a Traffic Policy but I don't know how to trigger the HTTP::collect within the policy, my policy was moreless:
Match the following conditions:
HTTP URI PATH starts with /example at request
Don the following:
Insert HTTP Header named= ntCoent-Length with value [HTTP::payload length] at response time
Log message The ntCoent-Lenght value is [HTTP::header value ntCoent-Length] at response time
But it doesn't return any value, can you help me please or give me a hint.
Thanks a lot!!!!!