Forum Discussion

Jaime_Quiroga's avatar
Jaime_Quiroga
Icon for Nimbostratus rankNimbostratus
Oct 09, 2019
Solved

IRULE SIDE BAND CONECTION HTTP

Hello

 

I'm working with an irule that makes a connection with a server to get a file from this, and save the information on a table and a sub table, at this moment I have used the sintax command "[table lookup -subtable $db_cache_table [HTTP::path]]", this is good when the /uri match the table /uri,however I need to find the way to do the same sintax with "star_with" or "containts" the path or uri.

any suggestions please?

 

 

 

  • Hi Jaime,

    Can you try this?

    set tableKeys [table keys -subtable $db_cache_table]
    foreach key $tableKeys {
    	if { $key starts_with [HTTP::path] } {
    		# log local0. "KEY: $key
    		# log local0. "PATH: [HTTP::path]"
    	}
    }

2 Replies

  • Hi Jaime,

    Can you try this?

    set tableKeys [table keys -subtable $db_cache_table]
    foreach key $tableKeys {
    	if { $key starts_with [HTTP::path] } {
    		# log local0. "KEY: $key
    		# log local0. "PATH: [HTTP::path]"
    	}
    }
    • Jaime_Quiroga's avatar
      Jaime_Quiroga
      Icon for Nimbostratus rankNimbostratus

      Hello

       

      Thanks for your time in this response. I worked with this code and completed with the next code.

       

      1. when HTTP_REQUEST {
      2.                set path_normal [HTTP::path]
      3.                set tableKeys [table keys -subtable $db_cache_table]
      4.                set new_path_normal [substr $path_normal 1 .]
      5.                foreach key $tableKeys {
      6.                         if { $key contains $new_path_normal } {
      7.                           set path_virtual [table lookup -subtable $db_cache_table $key]
      8.                                   }
      9.                         } 
      10.                set newpath_virtual [string map {" " "" \n "" \r ""} $path_virtual]
      11.                if { $newpath_virtual ne "" } { virtual $newpath_virtual }
      12. }