Re: [PATCH] lwp-request - Option to change UserAgent
Ask Bjoern Hansen (ask@valueclick.com)
Sun, 20 Jun 1999 22:33:09 -0700 (PDT)
On 20 Jun 1999, Gisle Aas wrote:
...
> > I'm often using lwp-request to debug my web.applications[tm], and it's
> > extremely useful for me to be able to specify the UserAgent on the
> > commandline, and I figured it could be useful for others also, so here's
> > the simple patch.
>
> I would prefer to use the new -H option for this:
>
> lwp-request -H 'UserAgent: foo/0.1' ...
>
> The following patch will be in 5.44.
That'll work for me then, thanks a lot Gisle.
- ask
> $ cvs diff -u -rR5_43 bin/lwp-request.PL
> Index: bin/lwp-request.PL
> ===================================================================
> RCS file: /home/cvs/aas/perl/mods/libwww-perl/bin/lwp-request.PL,v
> retrieving revision 1.37
> retrieving revision 1.38
> diff -u -u -r1.37 -r1.38
> --- lwp-request.PL 1999/03/21 21:56:18 1.37
> +++ lwp-request.PL 1999/06/01 10:40:51 1.38
> @@ -12,7 +12,7 @@
> !GROK!THIS!
>
> print OUT <<'!NO!SUBS!';
> -# $Id: lwp-request.PL,v 1.37 1999/03/21 21:56:18 gisle Exp $
> +# $Id: lwp-request.PL,v 1.38 1999/06/01 10:40:51 gisle Exp $
> #
> # Simple user agent using LWP library.
>
> @@ -190,7 +190,7 @@
> $progname =~ s,.*/,,; # use basename only
> $progname =~ s/\.\w*$//; # strip extension, if any
>
> -$VERSION = sprintf("%d.%02d", q$Revision: 1.37 $ =~ /(\d+)\.(\d+)/);
> +$VERSION = sprintf("%d.%02d", q$Revision: 1.38 $ =~ /(\d+)\.(\d+)/);
>
>
> require LWP;
> @@ -383,6 +383,7 @@
> for my $user_header (@{ $options{'H'} || [] }) {
> my ($header_name, $header_value) = split /:\s*/, $user_header, 2;
> $request->header($header_name, $header_value);
> + $ua->agent($header_value) if lc($header_name) eq "user-agent"; # Ugh!
> }
> #$request->header('Accept', '*/*');
> if ($options{'c'}) { # will always be set for request that wants content
>
>
--
ask bjoern hansen - <http://www.netcetera.dk/~ask/>
more than 14M impressions per day, <http://valueclick.com>