Forum Discussion
Mattias_Holmber
Nimbostratus
Dec 09, 2008How do I get username from a POST
I have an irule that I want to do some debugging with.
So, basically I just want to write out the POST variable "username" to log.
rule get_user_id {
when HTTP_REQUEST {
if { [HTTP::uri] contains "login" } {
set username [HTTP::username]
log "username: $username"
}
}
}
what do I need more, can find much about it in the forum.
Br, Mattias
2 Replies
- Nicolas_Menant
Employee
Hi,
You won't be able to retrieve data like this if it's a POST method. POST means you have to check the payload, to do this you'll have to use HTTP::collect, HTTP::payload, when HTTP_RESPONSE and when HTTP_RESPONSE_DATAwhen HTTP_REQUEST { if {[HTTP::uri] contains "login"} { HTTP::collect } } when HTTP_REQUEST_DATA { set parameter_vals [split [HTTP::payload] "&"] Break out the POST data for username for {set i 0} {$i < [llength $namevals]} {incr i} { set params [split [lindex $namevals $i] "="] if { [lindex $params 0] equals "username" } { set username [lindex $params 1] } } }
I didn't tested it but should be close
HTH
N. - Mattias_Holmber
Nimbostratus
Thanks, for your replay.
But, I can still not getting it to work.
if I strip it down just to:
when HTTP_REQUEST {
if {[HTTP::uri] contains "login"} {
HTTP::collect
log "found login"
}
}
when HTTP_REQUEST_DATA {
log "[HTTP::payload]"
}
I still not getting any data... except the debug "found" that I added, It also seems that the login process is going alot slower.. Is this rules consuming resources ?
Br, Mattias
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
