Subject: | UTF-8 handling broken in LWP::Protocol::http |
LWP::Protocol::http does not handle UTF-8 data correctly since
_new_socket has no binmode set and Content-Length is incorrectly
calculated.
Possible fix:
-------------
- Introduce a binary option in LWP::UserAgent construction
- check $self->{ua}{binary} in LWP::Protocol::http and choose
correct handling for $socket and length/bytes (see below)
Unfortunately all other Protocol implementation classes have to
be adapted as well to be consistent ...
Possible short-time workaround:
-------------------------------
no warnings 'redefine';
my $old_code = \&LWP::Protocol::http::_new_socket;
*LWP::Protocol::http::_new_socket = sub {
my $sock = $old_code->(@_);
binmode $sock, ':utf8';
return $sock;
};
*LWP::Protocol::http::length = sub {
use bytes;
length shift;
};