ICAP based on file type

Hi

I’m trying to implemet ICAP based on file types. Only certain file types allowed to be forwarded to ICAP server.

I tried to implemet this iRule:

when HTTP_REQUEST {
if {([HTTP::method] eq "POST")} {
set path [HTTP::path]
switch -glob $path {
    "*.doc" -
    "*.pdf" - 
    "*.docx" -
    "*.xlx" -
    "*.xlsx" {
    log local0. "Requested uri: [HTTP::uri] from IP: [IP::local_addr] forwarded to ICAP"
        ADAPT::enable request enable
    }
    "*.html" -
    "*.js" {
    log local0. "Requested uri: [HTTP::uri] from IP: [IP::local_addr] no need for ICAP"
        ADAPT::enable request disable
    }
    default {
    log local0. "Requested uri: [HTTP::uri] from IP: [IP::local_addr] redirected to blockpage"
    HTTP::redirect http://blabla.com/virus.html
    }
}
}
}

But the thing is that the http path does not end with *.doc or any other file type in the irule.

What is the http header to check that contains the ?

Thanks!

ok .. so I customized the irule to do the following:

when HTTP_REQUEST {
if {([HTTP::method] eq "POST") and [string tolower [HTTP::host]] eq "blabla.com" and [HTTP::header exists "Content-Disposition"] } {
switch -glob [HTTP::header value "Content-Disposition"] {
    "*filename=*.doc*" -
    "*filename=*.pdf*" - 
    "*filename=*.docx*" -
    "*filename=*.xlx*" -
    "*filename=*.xlxs*" {
 log local0. "Requested uri: [HTTP::uri] from IP: [IP::local_addr] forwarded to ICAP"
        ADAPT::enable request enable
    }
    default {
    log local0. "Requested uri: [HTTP::uri] from IP: [IP::local_addr] redirected to blockpage"
    HTTP::redirect http://blabla.com/virus.html
    }
}
}
}

Still is not working

I don’t see in the f12 tool the Content-Disposition header ..

Should I see that header there ? or the maybe web application is not including the Content-Disposition header ?

What I’m missing here ? ..