Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 2977
Status: resolved
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors:
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Use a more genereal User-Agent by default
Some sites need to see the "Mozilla" or "MSIE" in the User-Agent to work correctly so I patched my copy of WWW::Mechanize to use "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" instead of "WWW-Mechanize/$VERSION" by default. I know that can be changed at runtime with: my $agent = WWW::Mechanize->new( agent=>"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" ); But it's a pain when I have to update the agent string on so many programs. As WWW::Mechanize tries to mimic popular browsers the User-Agent string should contain at least the "Mozilla" and "MSIE" words. Another example would be "“Mozilla/4.0 (compatible with MSIE 6.0; Windows NT 5.1)”"
--- WWW/Mechanize.pm~ +++ WWW/Mechanize.pm @@ -126,7 +126,7 @@ The constructor for WWW::Mechanize overrides two of the parms to the LWP::UserAgent constructor: - agent => "WWW-Mechanize/#.##" + agent => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" cookie_jar => {} # an empty, memory-only HTTP::Cookies object You can override these overrides by passing parms to the constructor, @@ -145,7 +145,7 @@ my $class = shift; my %default_parms = ( - agent => "WWW-Mechanize/$VERSION", + agent => "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", cookie_jar => {}, );
I don't want to change the default behavior, but the agent() method now handles shorthand strings like "Windows IE 6".
[PETDANCE - Tue Jul 22 13:11:53 2003]: Show quoted text
> I don't want to change the default behavior, but the agent() method now > handles shorthand strings like "Windows IE 6".
If you don't want to change the default behavior then add a agent_alias() method and don't change the current one. What happens if I want "Windows Mozilla" as User-Agent? Please, don't overload methods.
Show quoted text
> Please, don't overload methods.
Fair enough. I'll put out 0.56 today. Who is this, anyway?
This bug is not fixed. The MSIE HTTP protocol uses this header: User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1) I don't know why are you using: "WWW-Mechanize/$VERSION" in User-Agent. All the programs I have seen using WWW::Mechanize have to setup the agent to "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" to follow the MSIE HTTP protocol. Please use the same User-Agent header as the latest MSIE does and remove the unuseful agent aliases (they only take memory).
Show quoted text
> The MSIE HTTP protocol uses this header: > User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
I don't know what this "MSIE HTTP" protocol is. The HTTP protocol lets you use any header you like. Show quoted text
> I don't know why are you using: "WWW-Mechanize/$VERSION" in User- > Agent.
Because I need something general and non-specific if the user doesn't specify one. Show quoted text
> All the programs I have seen using WWW::Mechanize have to setup the > agent to "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)" to > follow the MSIE HTTP protocol.
God bless ya. Not all programs are programs you've seen. Show quoted text
> Please use the same User-Agent header as the latest MSIE does and > remove the unuseful agent aliases (they only take memory).
No. I think you're confusing "unuseful" with "not useful to you". Memory is hardly a concern. 200 bytes of memory is trivial. Finally, I'd appreciate it if comments came from non-anonymous users.