SVN: toys/rsget.pl/RSGet/Get.pm
sparky
sparky at pld-linux.org
Tue Feb 23 03:29:42 CET 2010
Author: sparky
Date: Tue Feb 23 03:29:42 2010
New Revision: 11159
Modified:
toys/rsget.pl/RSGet/Get.pm
Log:
- better debug dumper
Modified: toys/rsget.pl/RSGet/Get.pm
==============================================================================
--- toys/rsget.pl/RSGet/Get.pm (original)
+++ toys/rsget.pl/RSGet/Get.pm Tue Feb 23 03:29:42 2010
@@ -316,21 +316,34 @@
sub dump
{
my $self = shift;
- my $ct = $self->{content_type};
+ my ( $body, $ext );
+ my $ct = $self->{content_type} || "undef";
+ if ( @_ >= 2 ) {
+ $body = shift;
+ $ct = $ext = shift;
+ } else {
+ $body = $self->{body};
+ if ( $ct =~ /javascript/ ) {
+ $ext = "js";
+ } elsif ( $ct =~ /(ht|x)ml/ ) {
+ $ext = "html";
+ } elsif ( $ct =~ m{image/(\S+)} ) {
+ $ext = $1;
+ } else {
+ $ext = "txt";
+ }
+ }
- my $ext = "txt";
- if ( $ct =~ /javascript/ ) {
- $ext = "js";
- } elsif ( $ct =~ /(ht|x)ml/ ) {
- $ext = "html";
- } elsif ( $ct =~ m{image/(.*)} ) {
- $ext = $1;
+ unless ( defined $body ) {
+ $self->log( "body not defined, not dumping ($ct, $ext)" );
+ return;
}
+
my $file = sprintf "dump.$self->{_id}.%.4d.$ext",
++$self->{_last_dump};
open my $f_out, '>', $file;
- print $f_out $self->{body};
+ print $f_out $body;
close $f_out;
$self->log( "dumped to file: $file ($ct)" );
More information about the pld-cvs-commit
mailing list