I've run into a problem with UTF-8 and HTTP::Request::Common::POST, as illustrated by the script
below.
In brief, the POST request seems to end up with all UTF-8
chars deleted.
AFAICS, the following regex on line 16 of package
URI::_query seems to be causing the problem.
$q =~ s/([^$URI::uric])/$URI::Escape::escapes{$1}/go;
but it's not clear to me why.
Any suggestions, or fixes ?
Steve Collyer
############# script follows ####################
#!/usr/bin/perl
use LWP;
use HTTP::Request::Common;
use Encode;
use charnames qw(greek);
binmode(STDOUT, ":utf8");
my $utf8_data = "<\N{alpha}\N{beta}\N{gamma}\N{delta}>";
print $utf8_data, "\n\n";
print Encode::is_utf8($utf8_data)
? "\$utf8_data marked as UTF-8\n\n"
: "\$utf8_data not marked as UTF-8\n\n";
my $request = POST("http://192.168.0.1/test",
Content => [
data => $utf8_data,
more_data => "some more data",
]
);
my $req_string = $request->as_string();
print Encode::is_utf8($req_string)
? "\$req_string marked as UTF-8\n\n"
: "\$req_string not marked as UTF-8\n\n";
print $req_string, "\n";
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.