Forum Discussion
Pass variable between HTTP_REQUEST and HTTP_REQUEST_DATA
Hi all,
I'm newbie to iRules.
A simply web application GET the login page, then POST the username/password through jsp.
I set a variable in HTTP_REQUEST event, and try to reference it in HTTP_REQUEST_DATA. It fails with "can't read "variable": no such varilable" error.
I tried to add it to session table but can't find a 'common' variable as the session key (SSL session ID seems differs in HTTP_REQUEST and HTTP_REQUEST_DATA events).
Would anyone please help? Thanks and rgds
6 Replies
- Arnaud_Lemaire
Employee
could you show you irule ?
- nitass_89166
Noctilucent
resource variable is not set on every request/connection. you would get "no such variable" error if it is not on the same connection which the variable is set.
- ST_Wong
Cirrus
that means variable set in one iRules event (e.g. HTTP_REQUEST) will not be available in other iRules event (e.g. HTTP_REQUEST_DATA) ? sorry that my concept about iRules events is unclear. Thanks.
- nitass
Employee
resource variable is not set on every request/connection. you would get "no such variable" error if it is not on the same connection which the variable is set.
- ST_Wong
Cirrus
that means variable set in one iRules event (e.g. HTTP_REQUEST) will not be available in other iRules event (e.g. HTTP_REQUEST_DATA) ? sorry that my concept about iRules events is unclear. Thanks.
- nitass
Employee
that means variable set in one iRules event (e.g. HTTP_REQUEST) will not be available in other iRules event (e.g. HTTP_REQUEST_DATA) ?
no. it is available as long as it is on the same connection.
config root@(ve11a)(cfg-sync In Sync)(Active)(/Common)(tmos) list ltm rule qux ltm rule qux { when HTTP_REQUEST { log local0. "client=[IP::client_addr]:[TCP::client_port] request=[HTTP::request]" if { [HTTP::uri] starts_with "/test" } { set variable 1234 } if { [HTTP::method] equals "POST" } { HTTP::collect [HTTP::header content-length] } } when HTTP_REQUEST_DATA { log local0. "client=[IP::client_addr]:[TCP::client_port]" log local0. "variable=$variable" } } test1 (curl -d "key1=value1" http://172.28.24.10/test/something) Oct 7 02:39:55 ve11a info tmm[15094]: Rule /Common/qux HTTP_REQUEST: client=172.28.24.1:43070 request=POST /test/something HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.24.10 Accept: */* Content-Length: 11 Content-Type: application/x-www-form-urlencoded Oct 7 02:39:55 ve11a info tmm[15094]: Rule /Common/qux HTTP_REQUEST_DATA: client=172.28.24.1:43070 Oct 7 02:39:55 ve11a info tmm[15094]: Rule /Common/qux HTTP_REQUEST_DATA: variable=1234 test2 (curl -d "key1=value1" http://172.28.24.10/something) Oct 7 02:40:04 ve11a info tmm1[15094]: Rule /Common/qux HTTP_REQUEST: client=172.28.24.1:43071 request=POST /something HTTP/1.1 User-Agent: curl/7.15.5 (i686-redhat-linux-gnu) libcurl/7.15.5 OpenSSL/0.9.8b zlib/1.2.3 libidn/0.6.5 Host: 172.28.24.10 Accept: */* Content-Length: 11 Content-Type: application/x-www-form-urlencoded Oct 7 02:40:04 ve11a info tmm1[15094]: Rule /Common/qux HTTP_REQUEST_DATA: client=172.28.24.1:43071 Oct 7 02:40:04 ve11a err tmm1[15094]: 01220001:3: TCL error: /Common/qux HTTP_REQUEST_DATA - can't read "variable": no such variable while executing "log local0. "variable=$variable""
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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