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"

 

}

 

 

  • Dupe of this post:

     

    http://devcentral.f5.com/Community/GroupDetails/tabid/1082223/aft/2160923/asg/50/Default.aspx

     

     

    Aaron