user80168
user80168

Reputation:

WWW::Mechanize and "HTTP::Message content must be bytes at..."

I'm writing simple program which has to change some data on Polish auction site.

One of the steps involves loading edit page, changing one value, and submitting it.

Sample page can be viewed here: http://depesz.com/various/new_item.php.html - this is just static copy of such edit page.

Relevant part of my perl code:

$agent->form_number( 1 );
$agent->submit();
$agent->form_number( 1 );

my $q = $agent->current_form()->find_input( 'scheme_id' );
$agent->field('scheme_id', '1025');
# $agent->field('description', encode('utf-8', $agent->value("description")));
# $agent->field('location', encode('utf-8', $agent->value("location")));
# $agent->field('transport_shipment_description', encode('utf-8', $agent->value("transport_shipment_description")));
$agent->submit;
print $agent->response->decoded_content . "\n";

After first submit I get the page I showed. Then I change value in scheme_id field to 1025, and submit the form.

Afterward I get:

HTTP::Message content must be bytes at /usr/local/share/perl/5.8.8/HTTP/Request/Common.pm line 91

I tried to recode values on text fields on the form - hence the agent->field(... encode) lines, but it didn't help.

At the moment I have no idea what on the form can make WWW::Mechanize fail in such way, but I clearly cannot fix in on my own.

Is there any way to debug this situation? Or perhaps I should do something differently?

Upvotes: 1

Views: 1819

Answers (2)

h4ck3rm1k3
h4ck3rm1k3

Reputation: 2100

I have the same problem. Solved it with : my $newcontent = encode('utf-8', $file); before posting the content!

thanks, mike

see http://www.perlmonks.org/?node_id=647935

Upvotes: 0

Frakkle
Frakkle

Reputation: 801

Make sure your LWP and WWW-Mechanize modules are fully up to date. LWP fixed a number of encoding problems in late 2008, if I recall correctly.

Upvotes: 1

Related Questions