in reply to Re^6: Cant get www:Mechanize to work
in thread Cant get www:Mechanize to work

use WWW::Mechanize 1.54; warn WWW::Mechanize->new->agent; my $mech = WWW::Mechanize->new( agent => 'Windows IE 6'); warn $mech->agent; $mech->agent_alias( 'Windows IE 6'); warn $mech->agent; __END__ WWW-Mechanize/1.54 at - line 2. Windows IE 6 at - line 4. Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) at - line 6.

Replies are listed 'Best First'.
Re^8: Cant get www:Mechanize to work
by yantar (Initiate) on Jun 09, 2009 at 14:18 UTC
    I got:
    WWW-Mechanize/1.5201 at line 21. Windows IE 6 at line 23. Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) at line 25.
    But still when using:
    use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->default_header('Accept-Encoding' => scalar HTTP::Message::decod +able()); $ua->add_handler("request_send", sub { shift->dump; return }); $ua->add_handler("response_done", sub { shift->dump; return }); $ua->get($mech->uri);
    I get:
    GET http://X.X.X.X/Console/login/login.aspx Accept-Encoding: gzip, x-gzip, deflate User-Agent: libwww-perl/5.822 (no content) HTTP/1.1 200 OK Cache-Control: private Connection: close Date: Tue, 09 Jun 2009 14:13:48 GMT Server: Microsoft-IIS/6.0 Content-Length: 14720 Content-Type: text/html; charset=utf-8 Client-Date: Tue, 09 Jun 2009 14:13:48 GMT Client-Peer: X.X.X.X:80 Client-Response-Num: 1 Link: <../vserver.css>; rel="stylesheet"; type="text/css" Refresh: 6010; URL=../login/login.aspx?logoff=true Set-Cookie: ASP.NET_SessionId=szdb2n55z0ovx345pw3a3xnm; path=/; HttpOn +ly Title: Serverb Console - Login X-AspNet-Version: 2.0.50727 X-Meta-CODE-LANGUAGE: C# X-Meta-GENERATOR: Microsoft Visual Studio .NET 7.1 X-Meta-Vs-DefaultClientScript: JavaScript X-Meta-Vs-TargetSchema: http://schemas.microsoft.com/intellisense/ie5 X-Powered-By: ASP.NET

      Why do you expect that setting the User-Agent header on $mech will magically change the User-Agent header on $ua?

        My mistake.

        So how can i see what is $mech actually sending?