Search code examples
regexerlangtsung

tsung: parsing respone of a request in dyn_variable using regex


I am trying to capture the response of a HTTP request in TSUNG in a dynamic variable.

   <request subst='true'>
          <dyn_variable name="my_response" re=".*" />

I actually need to capture the line with '200 OK' response. I tried a few other options. re="200 OK" , re=".200 OK."

None of the options are working.

from controller log

=INFO REPORT==== 25-Jan-2016::15:45:39 ===
       ts_search:(6:<0.97.0>) DynVar (RE): Match (my_response=<<>>)        
 Converted: <<>>

Why am I getting empty list(or binary)? Need help with the proper regex. Thanks!


Solution

  • You can use a regex based on a [\s\S] construct (=matches any character including a newline):

    ([\s\S]+200 OK[\s\S]+)
    

    Apparently, the Tsung version you are using utilizes the re.match method and the line you need is not the first one.