diff options
author | Norbert Preining <preining@logic.at> | 2010-05-12 16:54:37 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2010-05-12 16:54:37 +0000 |
commit | 661c41a09e39a182865e0b51e34cc995a0dc96e8 (patch) | |
tree | 2f79bb1406e22fdcb2587be8ffda6c0c609d7932 /Master/tlpkg/tlperl/bin/lwp-dump | |
parent | b645030efc22e13c2498a1522083634ab91b2de1 (diff) |
move tlperl.straw to tlperl
git-svn-id: svn://tug.org/texlive/trunk@18210 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/tlperl/bin/lwp-dump')
-rwxr-xr-x | Master/tlpkg/tlperl/bin/lwp-dump | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/Master/tlpkg/tlperl/bin/lwp-dump b/Master/tlpkg/tlperl/bin/lwp-dump new file mode 100755 index 00000000000..1805eb56138 --- /dev/null +++ b/Master/tlpkg/tlperl/bin/lwp-dump @@ -0,0 +1,107 @@ +#!/usr/bin/perl -w + +use strict; +use LWP::UserAgent (); +use Getopt::Long qw(GetOptions); + +my $VERSION = "5.827"; + +GetOptions(\my %opt, + 'parse-head', + 'max-length=n', + 'keep-client-headers', + 'method=s', + 'agent=s', +) || usage(); + +my $url = shift || usage(); +@ARGV && usage(); + +sub usage { + (my $progname = $0) =~ s,.*/,,; + die <<"EOT"; +Usage: $progname [options] <url> + +Recognized options are: + --agent <str> + --keep-client-headers + --max-length <n> + --method <str> + --parse-head + +EOT +} + +my $ua = LWP::UserAgent->new( + parse_head => $opt{'parse-head'} || 0, + keep_alive => 1, + env_proxy => 1, + agent => $opt{agent} || "lwp-dump/$VERSION ", +); + +my $req = HTTP::Request->new($opt{method} || 'GET' => $url); +my $res = $ua->simple_request($req); +$res->remove_header(grep /^Client-/, $res->header_field_names) + unless $opt{'keep-client-headers'} or + ($res->header("Client-Warning") || "") eq "Internal response"; + +$res->dump(maxlength => $opt{'max-length'}); + +__END__ + +=head1 NAME + +lwp-dump - See what headers and content is returned for a URL + +=head1 SYNOPSIS + +B<lwp-dump> [ I<options> ] I<URL> + +=head1 DESCRIPTION + +The B<lwp-dump> program will get the resource indentified by the URL and then +dump the response object to STDOUT. This will display the headers returned and +the initial part of the content, escaped so that it's safe to display even +binary content. The escapes syntax used is the same as for Perl's double +quoted strings. If there is no content the string "(no content)" is shown in +its place. + +The following options are recognized: + +=over + +=item B<--agent> I<str> + +Override the user agent string passed to the server. + +=item B<--keep-client-headers> + +LWP internally generate various C<Client-*> headers that are stripped by +B<lwp-dump> in order to show the headers exactly as the server provided them. +This option will suppress this. + +=item B<--max-length> I<n> + +How much of the content to show. The default is 512. Set this +to 0 for unlimited. + +If the content is longer then the string is chopped at the +limit and the string "...\n(### more bytes not shown)" +appended. + +=item B<--method> I<str> + +Use the given method for the request instead of the default "GET". + +=item B<--parse-head> + +By default B<lwp-dump> will not try to initialize headers by looking at the +head section of HTML documents. This option enables this. This corresponds to +L<LWP::UserAgent/"parse_head">. + +=back + +=head1 SEE ALSO + +L<lwp-request>, L<LWP>, L<HTTP::Message/"dump"> + |