Forum Discussion

victor_romero_1's avatar
victor_romero_1
Icon for Nimbostratus rankNimbostratus
Feb 03, 2011

illegal argument using HTTP::respond

Hi,

 

 

Our application servers return a 200 OK message even if it should be a 404 or 500 error code, so we want to capture that using an iRule and return the right error code depending on the message returned by our app servers:

 

 

when HTTP_RESPONSE_DATA {

 

set page_not_found "The requested page was not found."

 

set page_not_live "The requested page is not live."

 

if { ([HTTP::payload] contains "$page_not_found") } {

 

HTTP::respond 404

 

}

 

if { ([HTTP::payload] contains "$page_not_live) } {

 

HTTP::respond 500

 

}

 

}

 

 

 

 

It seems to be working as expected, however we see in the /var/ltm/log files the following error message:

 

 

- Illegal argument. Can't execute in the current context. invoked from within "HTTP::payload"

 

 

I take the only mandatory attribute for the HTTP::respond is the error code.

 

HTTP::respond status_code [content] [noserver] [header_name header value]+

 

 

We're using BIG-IP 9.4.8 Build 407.0 hotfix hf4

 

 

Any ideas?

 

 

Many thanks,

 

Victor

 

 

 

 

 

 

 

4 Replies

  • try adding the optional arguments: HTTP::respond 404 content "404"
  • I didn't think the content parameter was necessary. In a quick test on 10.2.1, I don't see a runtime error when using HTTP::respond 404 with no options.

     

     

    Victor, maybe you could open a case with F5 Support to get a detailed review of your config and the errors.

     

     

    Aaron
  • i don't think it's supposed to be, but I have seen issues with some configurations without it. Could be my sloppy code, though ;-)
  • Hi,

     

     

    Thanks for your comments. Much appreciated.

     

     

    The issue was with the if statement.

     

     

    I've fixed it taking out the [HTTP::payload] from the if statement and creating a new variable that I've used in the if statement, see below:

     

     

    ...

     

    set payload [HTTP::payload]

     

    if { $payload contains $page_not_found } {

     

    ...

     

     

    Victor