Esteem Monks,
LWP::ConsoleLogger::Easy installs some hooks on LWP::UserAgent for printing headers, content etc. during an LWP transaction.
For a particular website the console is messed up after LWP::ConsoleLogger::Easy prints received JSON response containing turkish characters. I suspect it contains broken unicode or I am sending the wrong headers. For other websites with greek or turkish characters in html it works fine. My question is whether I can do something about it.
use strict; use warnings; use LWP::UserAgent; use LWP::ConsoleLogger::Easy qw/debug_ua/; # with this uncommented, it still breaks but differently #binmode STDERR, ':utf8'; my $url = 'https://geocode.arcgis.com/arcgis/rest/services/World/Geoco +deServer/suggest?f=json&maxSuggestions=6&outSR=%7B%22latestWkid%22:43 +26%7D&text=kayseri'; #my $url = 'https://www.sigmalive.com'; #my $url = 'https://www.havadiskibris.com/'; # this also breaks: # use utf8; # my $url = 'https://geocode.arcgis.com/arcgis/rest/services/World/Geo +codeServer/suggest?f=json&maxSuggestions=6&outSR=%7B%22latestWkid%22: +4326%7D&text=αθήνα'; my $req = HTTP::Request->new( 'GET' => $url, [ 'Connection' => 'keep-alive', 'Accept' => '*/*', 'Accept-Encoding' => 'gzip, deflate, br', 'Accept-Language' => 'en-GB,en;q=0.5', 'Referer' => 'https://livingatlas.arcgis.com/', 'Content-Type' => 'application/json', # 'Content-Type' => 'text/html; charset=utf-8', 'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 13.5; +rv:116.0) Gecko/20100101 Firefox/116.0', 'Origin' => 'https://livingatlas.arcgis.com', 'Sec-Fetch-Dest' => 'empty', 'Sec-Fetch-Mode' => 'cors', 'Sec-Fetch-Site' => 'same-site' ], ); my $ua = LWP::UserAgent->new(); my $logger = debug_ua($ua); my $response = $ua->request($req); #print $response->decoded_content; # the console is messed, this is not printed: print "\n\ndone\n\n"; # echo $? prints 5, so this is reached: exit(5);
many thanks, bliako
In reply to LWP::ConsoleLogger::Easy messes the console on (seemingly) unicode LWP response: is it a case of broken unicode? by bliako
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |