Forum Discussion

refra_151287's avatar
Jan 12, 2016

Error during apply iRule

we face the following error when we apply the below irule, is there any suggestions to solve this error.

the error:

 

01070151:3: Rule [/Common/SBP-iRule] error: /Common/SBP-iRule:7: error: [parse error: extra characters after close-brace][then {
set check_request [getfield [HTTP::payload] "," 3];
set static::request_key [getfield $check_request ";" 1];
log local0. "priority 10 response $static::request_key"
}] 

 

the iRule

 

 when HTTP_RESPONSE priority 10 {

        if {
            (([HTTP::status] == "200" ) and
            ([HTTP::header value "Content-Length"] < "200") and
            ([HTTP::payload] contains "REQUEST_ID" )) 
            }then {
                set check_request [getfield [HTTP::payload] "," 3]
                set static::request_key [getfield $check_request ";" 1]
                log local0. "priority 10 response $static::request_key"
          }
}

 

Note: I see this error at all F5 versions except version 12?

1 Reply

  • Hi Refra,

    you may try the following syntax...

     

    when HTTP_RESPONSE priority 10 {
        if { ([HTTP::status] eq 200 ) and
             ([HTTP::header value "Content-Length"] < 200 ) and
             ([HTTP::payload] contains "REQUEST_ID" ) } then {
            set check_request [getfield [HTTP::payload] "," 3]
            set static::request_key [getfield $check_request ";" 1]
            log local0. "priority 10 response $static::request_key"
        }
    }
    

     

    But even with this syntax at your hands, I do strongly believe that you still have to review your code further, since it contains an invalid command usage and a creative writing that may have a hidden impact on the logic.

    1. You can execute the [HTTP::payload] command without collecting the responce data using the [HTTP::collect] command.

    2. Writing/Changing a $static:: variable during request/responce events (aka. data plane) will work, but those informations are then shared across multiple connections processed by the current TMM core. But they wouldn't be shared across different TMM cores (see SOL13033 for further information on CMP compatibility). The valid usecases of this coding technique are limited, but on the otherhand may produce unexpected behaviors when used accidentally...

    So you may want to use the iRule below as a new starting point...

     

    when HTTP_RQUEST priority 10 {
        if { [HTTP::uri equals "/uri_with_content_inspection" } then {
             Executing [HTTP::collect] to inspect the [HTTP::payload], may consume a lot TMM memory. 
             So you should limit those commands to the URIs which are really required 
            set REQUEST_ID_inspection 1
        }
    }
    when HTTP_RESPONSE priority 10 {
        if { ( $REQUEST_ID_inspection ) and
             ( [HTTP::status] eq 200 ) and
             ( [HTTP::header value "Content-Length"] < 200 ) } then {
    
            HTTP::collect [HTTP::header value "Content-Length"]
    
        }
    }
    when HTTP_RESPONSE_DATA priority 10 {
        if { ( $REQUEST_ID_inspection ) and 
             ( [HTTP::payload] contains "REQUEST_ID" ) } then {
            set check_request [getfield [HTTP::payload] "," 3]
            set request_key [getfield $check_request ";" 1]
            log local0. "priority 10 response $request_key"
        }
    }
    

     

    Cheers, Kai