Forum Discussion

elvisc_26948's avatar
elvisc_26948
Icon for Nimbostratus rankNimbostratus
Feb 24, 2010

STREAM expression not working

The replacement doesnt seem to work...I am basically doing URI replacment using STREAM function.

 

 

Snippet of my code:

 

http_request {

 

 

STREAM::expression "@abc@abc?zzz=123@"

 

STREAM::enable

 

}

 

 

I have profile stream added to vip.

 

 

4 Replies

  • Hi,

    The stream profile only operates on the payload. The URI is in the HTTP headers, so you wouldn't want to use a stream profile and iRule for this. Also, for HTTP, it's not practical to use a stream profile and iRule on a request payload if the search/replace fields are a different length as there is no way to update the Content-Length header.

    With that said, you can use HTTP::uri or HTTP::path to rewrite the URI or path in a request. You can use string map to search for one string and replace it with another.

    Can you give a more exact example of what you're trying to replace in the URI?

    Here is an example that would do exactly what you've tried. But I don't think it will solve the problem if abc is a fairly generic string in the URI.

     
     when HTTP_REQUEST { 
      
         Replace abc with abc?zzzz=123 in the URI 
        HTTP::uri [string map {abc abc?zzzz=123} [HTTP::uri]] 
     } 
     

    Aaron
  • Hi Hoolio,

     

     

    I tried the method before but the thing is that it does replaces the uri but not the subsequent uri the client is requesting... and thats why I went with STREAM expression. I have seen people on F5 forum using it in the HTTP_REQUEST...btw, how do I turn on debug to see if the STREAM expression is doing the replacement correctly? that would help for debugging...

     

     

    thx. Hoolio for your help.

     

     

  • Is the URI you want to rewrite found in the HTTP response headers or the response payload?

     

     

    Can you use a browser plugin like HttpFox for Firefox or Fiddler for IE to check this?

     

     

    To rewrite a URI in the response headers, you can use HTTP::is_redirect and HTTP::header. To rewrite the response payload, you can use a stream profile and STREAM::expression iRule.

     

     

    Here is an example iRule that was designed for rewriting the host in URLs. You could adapt it to handle the URI also (add code to HTTP_REQUEST to rewrite the URI).

     

     

    HTTP Respond Data replacing?

     

    http://devcentral.f5.com/Default.aspx?tabid=53&forumid=5&tpage=1&view=topic&postid=3457134602

     

     

    Aaron