Corion / WWW-Mechanize-Chrome

automate the Chrome browser
https://metacpan.org/release/WWW-Mechanize-Chrome
Artistic License 2.0
30 stars 12 forks source link

Bugfix: Encode the body on getting it #63

Closed m-yakovenko closed 2 years ago

m-yakovenko commented 3 years ago

On setting the response body to the response, the following error occurred: HTTP::Message content must be bytes

Corion commented 3 years ago

This does not sound sensible. I interpret the error message that the Response was created with a string containing unicode characters (possibly decoded from UTF-8) instead of raw bytes.

Do you have code (and HTML) to reproduce the issue?

m-yakovenko commented 3 years ago

Yes, I do. Here is the snippet:

use utf8;
use strict;
use warnings;
use WWW::Mechanize::Chrome;

$SIG{__DIE__} = sub {
    my $error = shift;
    warn $error;
};

my $link = "http://google.com/maps/search/Furniture+at+Praha/@50.1064625,14.3744223,14z/";
my $mech = WWW::Mechanize::Chrome->new( (
    launch_exe => '/usr/bin/chromium-browser',
    data_directory => '/tmp/chromium',
) );

$mech->get($link);
# The error with HTTP::Message must be occurred on the next step
$mech->content;
$mech->close();
Corion commented 3 years ago

I've pushed a different solution to your PR and released it as 0.68 on CPAN. Can you please tell me if that solution works for your problem?