Forum Discussion
Rusty_Hale_8009
Nimbostratus
Jan 25, 2005Help getting iRule to persist on info in the payload
I need to be able to go down into the payload and grab a hash value and then use that value to persist with. I have a base rule that I am testing just to get my syntax right.
when HTTP_REQUEST_DATA {
set content_length 429496
HTTP::collect $content_length
set rpc-id {[findstr [HTTP::payload] "Authorization:" 14, 20]}
log local0. "WE RECORDED [$rpc-id] AS THE PERSIST VARIABLE"
HTTP::release
}
The app is actually rpc over http for Exchange 2003. Since RPC over http does not have a http header, I have to find a value in the payload and use that to persist with. With Ethereal, I found an authenication hash value but my rule keeps giving me an error:
TCL error: Rule rpc-persist - can't read "rpc": no such variable while executing "log local0. "WE RECORDED $rpc-id AS THE PERSIST VARIABLE""
Right now, I am just trying to get a value into the variable. I have not even attempted to add the code to do the persistence. Any help would be appreciated. Thanks.
- bl0ndie_127134Historic F5 AccountYou don't need to add a square braket when dereferencing variables in tcl. Try this syntax.
log local0. "WE RECORDED $rpc-id AS THE PERSIST VARIABLE"
- drteeth_127330Historic F5 AccountIf that doesn't work, try this:
log local0. "WE RECORDED ${rpc-id} AS THE PERSIST VARIABLE"
- Rusty_Hale_8009
Nimbostratus
I changed the iRule to: - bl0ndie_127134Historic F5 AccountAre you handling the HTTP_REQUEST event? HTTP::collect *must* be called from HTTP_REQUEST/HTTP_RESPONSE events otherwise HTTP_REQUEST_DATA/HTTP_RESPONSE_DATA events will not fire. That would explain why you are not seing any log entries.
- Rusty_Hale_8009
Nimbostratus
So it should look something like this? - unRuleY_95363Historic F5 AccountRusty,
when HTTP_REQUEST { set content_length [HTTP::header Content-Length] HTTP::collect $content_length } when HTTP_REQUEST_DATA { set rpc_id [findstr [HTTP::payload] "Authorization:" 14 20] persist uie $rpc_id log local0. "WE RECORDED $rpc_id AS THE PERSIST VARIABLE" HTTP::release }
- Rusty_Hale_8009
Nimbostratus
That was a huge help. The log file shows that the variable is empty. I just have a couple of questions. The current rule is looking in the http header. Since the information I am trying to get is in the payload, should I not be using payload instead of header? This is the string I am trying to get in the variable: - bl0ndie_127134Historic F5 AccountRusty, the value for Authorization is in the HTTP header, so you don't need to call HTTP::collect in order to extract and persist on that value. Here is a modified rule that I think will do the trick.
when HTTP_REQUEST { set rpc_id [HTTP::header value "Authorization"] persist uie $rpc_id log local0. "WE RECORDED ${rpc_id} AS THE PERSIST VARIABLE" }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects