Code Comments
Programming Forum and web based access to our favorite programming groups."Don't allow HTTP::Message content to be set to Unicode strings."
I'm going to assume this change above is whats breaking my scripts. My
script is using NicToolServerAPI.pm which in turn uses LWP::UserAgent. The
script dies out with the error above when I run it. I'm not sure what has
to be done, my guess is that the script is POST'ing the URL in plain text
and it needs to be in some other format. I've snipped out a few pieces of
code in hopes that somebody here might be able to give me a quick fix.
===NicToolServerAPI.pm Snip calling LWP::UserAgent====
my $ua = new LWP::UserAgent;
my $req = HTTP::Request->new('POST',$url);
===NicToolServerAPI.pm snip setting $url====
sub send_request {
my $self = shift;
my $url;
if ($NicToolServerAPI::use_https_authentica
tion) {
$url = 'https://'.$NicToolServerAPI::server_host.':'
.$NicToolServerAPI::https_server_port;
} else {
$url = 'http://'.$NicToolServerAPI::server_host.':'
.$NicToolServerAPI::server_port;
}
my $func = 'send_'.$NicToolServerAPI::data_protocol.'_request';
if ($self->can($func)) {
return $self->$func($url,@_);
} else {
return {'error_code'=>501,'error_msg'=>'Data protocol not supported:
'.$NicToolServerAPI::data_protocol};
}
}
Anybody know what I need to do to convert $url to bytes? Is this just a
base64 encode or something?
~Shaun
Post Follow-up to this message* Shaun wrote: >"Don't allow HTTP::Message content to be set to Unicode strings." > >I'm going to assume this change above is whats breaking my scripts. My >script is using NicToolServerAPI.pm which in turn uses LWP::UserAgent. The >script dies out with the error above when I run it. I'm not sure what has >to be done, my guess is that the script is POST'ing the URL in plain text >and it needs to be in some other format. I've snipped out a few pieces of >code in hopes that somebody here might be able to give me a quick fix. Presumably you have to clear the string you are passing in of the UTF-8 flag, e.g. by using Encode::encode or perhaps Encode::_utf8_off. -- Björn Höhrmann · mailto:bjoern@hoehrmann.de · http://bjoern.hoehrmann.de Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de 68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Post Follow-up to this messageCan you try if the newly upload libwww-perl-5.811 fixes your problem. It will not complain about Unicode strings unless they actually contain chars that can't be treated as bytes. --Gisle
Post Follow-up to this messageThis version looks to have fixed the problem! Thanks ~Shaun -----Original Message----- From: gisle.aas@gmail.com [mailto:gisle.aas@gmail.com] On Behalf Of Gisle Aas Sent: Monday, April 14, 2008 1:21 PM To: Shaun Cc: libwww@perl.org Subject: Re: libwww-perl-5.810 (HTTP::Message content not bytes) Can you try if the newly upload libwww-perl-5.811 fixes your problem. It will not complain about Unicode strings unless they actually contain chars that can't be treated as bytes. --Gisle
Post Follow-up to this messagePowered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.