3 eval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}'
4 if 0; # not running under some shell
8 use Getopt::Long qw(GetOptions);
10 my $VERSION = "5.827";
15 'keep-client-headers',
20 my $url = shift || usage();
24 (my $progname = $0) =~ s,.*/,,;
26 Usage: $progname [options] <url>
28 Recognized options are:
38 my $ua = LWP::UserAgent->new(
39 parse_head => $opt{'parse-head'} || 0,
42 agent => $opt{agent} || "lwp-dump/$VERSION ",
45 my $req = HTTP::Request->new($opt{method} || 'GET' => $url);
46 my $res = $ua->simple_request($req);
47 $res->remove_header(grep /^Client-/, $res->header_field_names)
48 unless $opt{'keep-client-headers'} or
49 ($res->header("Client-Warning") || "") eq "Internal response";
51 $res->dump(maxlength => $opt{'max-length'});
57 lwp-dump - See what headers and content is returned for a URL
61 B<lwp-dump> [ I<options> ] I<URL>
65 The B<lwp-dump> program will get the resource indentified by the URL and then
66 dump the response object to STDOUT. This will display the headers returned and
67 the initial part of the content, escaped so that it's safe to display even
68 binary content. The escapes syntax used is the same as for Perl's double
69 quoted strings. If there is no content the string "(no content)" is shown in
72 The following options are recognized:
76 =item B<--agent> I<str>
78 Override the user agent string passed to the server.
80 =item B<--keep-client-headers>
82 LWP internally generate various C<Client-*> headers that are stripped by
83 B<lwp-dump> in order to show the headers exactly as the server provided them.
84 This option will suppress this.
86 =item B<--max-length> I<n>
88 How much of the content to show. The default is 512. Set this
91 If the content is longer then the string is chopped at the
92 limit and the string "...\n(### more bytes not shown)"
95 =item B<--method> I<str>
97 Use the given method for the request instead of the default "GET".
101 By default B<lwp-dump> will not try to initialize headers by looking at the
102 head section of HTML documents. This option enables this. This corresponds to
103 L<LWP::UserAgent/"parse_head">.
109 L<lwp-request>, L<LWP>, L<HTTP::Message/"dump">