Some additions to libwww perl for consideration
Chris Leach (leachcj@vegemite.mel.az.bp.com)
Thu, 26 Feb 1998 14:30:31 +1100
Hello,
Here is a small patch to add an option to write the returned contents
to a file. I added this because I was GETtin a binary through a proxy
requiring proxy authenication.
*** lwp-request.PL.orig Mon Jan 5 06:04:59 1998
--- lwp-request.PL Thu Feb 26 14:11:40 1998
***************
*** 25,33 ****
=head1 SYNOPSIS
! lwp-request [-aeEdvhx] [-m method] [-b <base URL>] [-t <timeout>]
[-i <if-modified-since>] [-c <content-type>] [-C <credentials>]
! [-p <proxy-url>] [-o <format>] <url>...
=head1 DESCRIPTION
--- 25,33 ----
=head1 SYNOPSIS
! lwp-request [-afeEdvhx] [-m method] [-b <base URL>] [-t <timeout>]
[-i <if-modified-since>] [-c <content-type>] [-C <credentials>]
! [-p <proxy-url>] [-o <format>] [-O <outfile>] <url>...
=head1 DESCRIPTION
***************
*** 160,165 ****
--- 160,169 ----
Set text(ascii) mode for content input and output. If this option is not
used, content input and output is done in binary mode.
+ =item -O <outfile>
+
+ write contents to outfile
+
=back
Because this program is implemented using the LWP library, it will
***************
*** 262,267 ****
--- 266,272 ----
$opt_a = undef; # content i/o in text(ascii) mode
$opt_m = undef; # set method
$opt_f = undef; # make request even if method is not in %allowed_methods
+ $opt_O = undef; # write contents to file
$opt_b = undef; # base url
$opt_t = undef; # timeout
$opt_i = undef; # if-modified-since
***************
*** 284,290 ****
$opt_o = undef; # output format
! unless (getopts("axhvuUsSedPp:b:t:i:c:C:m:fo:")) {
usage();
}
--- 289,295 ----
$opt_o = undef; # output format
! unless (getopts("axhvuUsSedPp:b:t:i:c:C:m:fo:O:")) {
usage();
}
***************
*** 465,472 ****
die "Illegal -o option value ($opt_o)\n";
}
} else {
! binmode STDOUT unless $opt_a;
! print $response->content;
}
}
} else {
--- 470,483 ----
die "Illegal -o option value ($opt_o)\n";
}
} else {
! if (defined $opt_O) {
! open(FH, ">$opf_O") or die "$opt_O: $!";
! binmode FH unless $opt_a;
! print FH $response->content;
! } else {
! binmode STDOUT unless $opt_a;
! print STDOUT $response->content;
! }
}
}
} else {