cancel
Showing results for 
Search instead for 
Did you mean: 

iRule script injection and chunked Response page issue

steve_michaels
Nimbostratus
Nimbostratus

We are using a modified version of this iRule: https://devcentral.f5.com/s/articles/google-analytics-script-injection-911

(See our iRule below) to inject a script into HTTP Responses. This iRule works fine for unchunked HTTP Response pages.

However we have some Response pages returned by the backend server that are chunked and this iRule fails. For those pages, logging shows

this Out of bounds error from the iRule:

 

Nov 1 10:48:39 xxxxxxx.jhuapl.edu err tmm[19381]: 01220001:3: TCL error: /Common/xxxCUI <HTTP_RESPONSE_DATA> - Out of bounds (line 1)    invoked from within "HTTP::payload replace 0 $content_length [string map [list $search "[subst -nocommands -nobackslashes [ifile get cui]]</body>"] [HTTP::payload]]"

 

  • - We believe we’re getting the error above because content length doesn’t exist in our chunked responses, so it’s getting set to 1000000 and we’re getting an out of bounds on payloads that are shorter than that.
  • - We tried setting the replace length to be that of the payload length, but then it doesn’t seem to “rechunk” the response correctly and parts seem to be missing.
  • - We’ve tried doing a Stream replace with an expression, but it doesn’t find and replace the content we’re targeting.

 

Any ideas on how to handle this issue / use case are appreciated.

BigIP version = 15.1.2.1

Thanks

-Steve M

 

1 ACCEPTED SOLUTION

Hello Steve.

 

Try to downgrade your HTTP connection in order to avoid "Transfer-Encoding: chunked"

when HTTP_REQUEST { HTTP::header remove "Accept-Encoding" if { [HTTP::version] eq "1.1" } { if { [HTTP::header is_keepalive] } { HTTP::header replace "Connection" "Keep-Alive" } HTTP::version "1.0" } }

Regards,

Dario.

Regards,
Dario.

View solution in original post

3 REPLIES 3

Hello Steve.

 

Try to downgrade your HTTP connection in order to avoid "Transfer-Encoding: chunked"

when HTTP_REQUEST { HTTP::header remove "Accept-Encoding" if { [HTTP::version] eq "1.1" } { if { [HTTP::header is_keepalive] } { HTTP::header replace "Connection" "Keep-Alive" } HTTP::version "1.0" } }

Regards,

Dario.

Regards,
Dario.

steve_michaels
Nimbostratus
Nimbostratus

@Dario - Thanks very much for that suggestion. It worked for our use case. High-5 to you for that help!

-Steve

Great to hear that your issue is solved now.

Please, don't forget to mark my answer as "the best" to help other people to find it.

Regards,

Dario. ​

Regards,
Dario.