Forum Discussion

KBerger_52392's avatar
KBerger_52392
Icon for Nimbostratus rankNimbostratus
Jun 18, 2010

Repacing http://*** references in payload

Hi all,

I'm very new to using iRules, so please don't smack me down, if I get anything wrong üòâ

I am working as a software-developer. We have an application which is being accessed via a BigIP over HTTPS. It does the HTTPS-Offload and communicates via HTTP with the underlying nodes. The problem is, that there is one component within the software which will return an absolute address within it's response. As the application relies on its HTTP-Context, it does not know that it can only be accessed via HTTPS, since the Loadbalancer actually connects via HTTP.

So what I wanted to do was to implement an iRule which scans the response-payload of the application-servers and replaces the by using regular expressions for instance. I think I got the rule as i want it to have, but I get a runtime error which tells me, that HTTP::collect is not valid in the current scopy (whatever).

So here comes the rule:



when HTTP_RESPONSE 
{ 
 Get the content length so we can request the data to be 
 processed in the HTTP_RESPONSE_DATA event. 
if { [HTTP::header exists "Content-Length"] && [HTTP::header "Content-Length"] < 1048577 } 
{ 
set content_length [HTTP::header "Content-Length"] 
} 
else 
{ 
set content_length 1048576 
} 
if { $content_length > 0 } 
{ 
HTTP::collect $content_length 
} 
} 
The actual action happens in HTTP_RESPONSE_DATA, but the error occurs above. 
Does anyone have any ideas about why this script fails? 
Is there a better way to achieve what I need to have? 
Best regards and thanks in advance 
Kristof
  • hoolio's avatar
    hoolio
    Icon for Cirrostratus rankCirrostratus
    Hi,

     

     

    I'd suggest using a blank stream profile and a STREAM::expression based iRule to replace http:// with https:// in the response content. See the wiki page for details:

     

     

    http://devcentral.f5.com/wiki/default.aspx/iRules/stream__expression

     

     

    This will be more efficient and a bit simpler than having LTM buffer the response content using HTTP::collect.

     

     

    Aaron