Forum Discussion

Wil_Schultz_101's avatar
Wil_Schultz_101
Icon for Nimbostratus rankNimbostratus
Jan 17, 2012

How can I test to see if HTTP::Status exists?

I'm using an HSL config that prints out some useful syslog information. It works well, except for one type of request. Unfortunately I don't know what that request looks like quite yet, basically I've got a checken/egg thing happening.

 

 

Here's the error I'm seeing:

 

TCL error: /Common/www.my.com_irule - Illegal argument. Invalid client side API (line 15) invoked from within "HTTP::status"

 

 

 

 

 

 

 

 

So here's what I have, the commeted section where HTTP::status is referenced causes this issue. I suspect it's not seeing a status code and complaining. I'd love to test if HTTP::status exists, if not insert XXX as the status code, and if it does insert the real status code.:

 

 

 

when CLIENT_ACCEPTED {

 

set hsl [HSL::open -proto TCP -pool syslog_pool]

 

}

 

 

 

when HTTP_REQUEST {

 

set http_request_time [clock clicks -milliseconds]

 

set remote_addr "[IP::remote_addr]"

 

set LogString1 "<190> $remote_addr \"[HTTP::header Host]\" \"[HTTP::method] [HTTP::uri] HTTP\/[HTTP::version]\" \"[HTTP::header User-Agent]\""

 

}

 

 

 

when HTTP_RESPONSE {

 

 

 

set http_status XXX

 

if { [HTTP::status] } {

 

set http_status [HTTP::status]

 

}

 

 

 

set LogString2 "[HTTP::status] pool_info: [LB::server] (ResponseTime: [expr [clock clicks -milliseconds] - $http_request_time]ms)"

 

set LogString2 "$http_status pool_info: [LB::server] (ResponseTime: [expr [clock clicks -milliseconds] - $http_request_time]ms)"

 

set LogString2 "pool_info: [LB::server] (ResponseTime: [expr [clock clicks -milliseconds] - $http_request_time]ms)"

 

 

 

HSL::send $hsl "$LogString1 | $LogString2 \n"

 

}

 

 

  • Hi Wil,

    This runtime error from HTTP::status is noted in BZ374390. I think it's triggered when the server sends a response before TMM finishes sending the request. You could try using catch to handle any errors. Or you could open a case with F5 Support referencing BZ374390 and ask for a hotfix.

    
    when HTTP_RESPONSE {
    
     Use catch to handle any exception
    if {[catch {HTTP::status} status]==0}{
    log local0. "HTTP::status was successful and returned $status"
    } else {
    log local0. "HTTP::status failed and returned $status"
    }
    }
    

    Aaron