Selective debug

Hello,

I wish to be able to make A10 add debug header informations in the response header when I add a certain header in the request. I dont want all the requests to be in debug mode, just the one I send. I ended up with this code :

when HTTP_REQUEST {
  set ::DEBUG 0
  # detection debug
  if { [HTTP::header exists “X-Debug”] } {
      log local0.DEBUG “DEBUG FORCE”
      set ::DEBUG 1

  \}
\}

when HTTP\_RESPONSE \{
  if \{ $::DEBUG == 1 \} \{
    HTTP::header insert "X-Debug-A10" "[LB::server pool] [LB::server name]"
  \}
\}

but this doesn’t work because of the scope of the DEBUG variable.
If I add the DEBUG variable to the HTTP_INIT event, it’s scope becomes global to the aflex and all the subsequent requests are treated in DEBUG mode.
How could I achieve this ?

Thanks for your help,

Olivier

instead of HTTP_INIT I meant RULE_INIT…

Try something like the following:
when RULE_INIT {
set ::DEBUG 0
`}

when HTTP_REQUEST { # detection debug if { [HTTP::header exists “X-Debug”] } { log local0.DEBUG “DEBUG FORCE” set ::DEBUG 1 } }

when HTTP_RESPONSE { if { $::DEBUG == 1 } { HTTP::header insert “X-Debug-A10” “[LB::server pool] [LB::server name]” set ::DEBUG 0 } }`