Forum Discussion

Biswajeet_38744's avatar
Biswajeet_38744
Icon for Nimbostratus rankNimbostratus
Apr 01, 2019

HTTP XML irule based on string

Hi Team,

 

I need to write a irule for HTTP POST request with XML if matches string in between UE; the middle 2 characters direct traffic to pool1 or else pool2. Kindly suggest.

 

Thanks, Biswajeet

 

4 Replies

  • Hi Biswajeet,

     

    Please be more specific with your question.

     

    If possible capture your HTTP-POST request with a HTTP-Analyser and copy the entire request into your question (masking / removing sensitive parts of the request is fine)...

     

    Cheers, Kai

     

  • Hi Kai,

    Thanks for a quick response. I need to cater traffic based on this String to respective pools in XML body: It will be always 2 characters. If matches send to pool1 else pool2.

    UE
    

    Hope this clarifies. Appreciate your suggestions.

    Cheers, Biswajeet

  • Hi,

    Can you try this simple Irule. We can add more info after testing (mimetype...)

    when HTTP_REQUEST {
    
    set capture 0
    
        if { [HTTP::header exists Content-length] and ( [HTTP::method] equals "POST" }
            set capture 1
            HTTP::collect [HTTP::header Content-Length]
        }
    }    
    when HTTP_REQUEST_DATA {  
    
    if {$capture} {  
        if { [HTTP::payload] contains "UE<\/circle>" } {        
            log local0. "Logs: trigged wanted post"
        }
    }   
    }
    
  • Hi Kai,

    Thanks for your help. The pools will be defined based on below characters in-between string .

    UE  middle characters PB,JK,UW,HP,RJ,DL,HR,MU,UE,MP,GJ,MH
    

    then select pool1 or else pool2

    My question here is how to match these many strings and select pool.

    Thanks, Biswajeet