Forum Discussion

Hans_Schneider2's avatar
Hans_Schneider2
Icon for Nimbostratus rankNimbostratus
Jul 23, 2013

UTF8 Encoding Problem

Hello,

 

I need to add some string to a payload that is in UTF8 encoding.

 

When I am using any command after HTTP::collect - all the characters displayed wrong.

 

I found a topic about this, that suggest to use a STREAM profile.

 

But I am not allowed to change virtual server configuration so I cannot use it.

 

Is it another solution?

 

 

Thanks.

 

3 Replies

  • A couple of observations:

     

     

    1. There are generally TWO ways to alter HTTP payloads: STREAM and HTTP::collect/payload. Once you've collected all of the required payload, you can use any manner of string manipulation or regex to manipulate the data. A STREAM profile is *almost* as flexible, but will usually run much faster than the other option.

     

     

    2. You can use an iRule to manipulate a STREAM profile, and only add a generic (blank) STREAM profile to the virtual server configuration.

     

     

    3. Both HTTP::collect/payload and a STREAM profile/iRule are going to work with string data. If you're having UTF8 issues with one, you'll likely have the same problem with the other.

     

     

    4. Whether adding a STREAM profile or an iRule, you're modifying the virtual server configuration regardless.

     

     

    Can you please elaborate on the UTF8 issue?

     

  • You are right.

     

    But when I checked it using Stream the problem did not occured. The issue is I am not allowed to use Stream, only an irule, so i have to use

     

    Http::collect method.

     

     

    The payload in UTF8 (it is the charset defined in the header of Http request), that i have to change with the irule, contains characters that are not English.

     

    In http::collect method when I am using some replace method or simply add in the end of the payload another string - all the characters in the page not represented correctly anymore (each character corrupted in some way).

     

    And a cannot convert the string that i am adding to payload into UTF8 since "encoding" tcl command is disabled in F5 irules.
  • So just to be clear, the STREAM method is still an iRule. You just need a blank STREAM profile applied to the VIP, the same way you need an HTTP profile applied to the VIP to use HTTP commands in an iRule. Take a look at the STREAM::expression wiki page for examples:

     

     

    https://devcentral.f5.com/wiki/iRules.STREAM__expression.ashx

     

     

    Otherwise, can you share your current iRule and specific string examples?