Technical Forum
Ask questions. Discover Answers.
cancel
Showing results for 
Search instead for 
Did you mean: 

HTTP::Collect results in garbled HTTP::Payload when using non-english characters

bc1
Nimbostratus
Nimbostratus

Hi there,

I'm using an irule to collect a POSTed payload, manipulate the content and then POST on to the back-end pool, however when non-english characters are used then the collected payload is garbled even before I start any processing:

If I post for example:

â ê î ô û á é í ó ú ü ñ

I get the following in HTTP_REQUEST_DATA:

â ê î ô û á é í ó ú ü ñ

I've looked through devcentral but the examples don't seem to relate to this or else they relate to the URI .. Is there a best-practice on how to correct this?

Many thanks!

when HTTP_REQUEST {
  HTTP::collect 1048576
}

when HTTP_REQUEST_DATA {
  log local0. [HTTP::payload]
}
1 REPLY 1

Kai_Wilke
MVP
MVP

Hi bc,

the programming language of iRules is TCL which uses always UTF-8 to represent a string. If your input contains highbit ASCII charcters (e.g. Win1252, Latin-1, ISO-8859-1) certain TCL commands will silently change the used encoding.

To reformat UTF-8 back to its ASCII representation you could try a

set output [binary format A* $input]
. By doing so the UTF-8 encoded string representation of the
$input
will shimmer to a binary
$output
which is encoded in plain-ASCII.

Cheers, Kai


iRule can do… 😉