SVN: toys/rsget.pl/RSGet/Curl.pm
sparky
sparky at pld-linux.org
Sat Jun 26 15:45:10 CEST 2010
Author: sparky
Date: Sat Jun 26 15:45:08 2010
New Revision: 11585
Modified:
toys/rsget.pl/RSGet/Curl.pm
Log:
- added headonly option to new() - download will return http headers
instead of the body
Modified: toys/rsget.pl/RSGet/Curl.pm
==============================================================================
--- toys/rsget.pl/RSGet/Curl.pm (original)
+++ toys/rsget.pl/RSGet/Curl.pm Sat Jun 26 15:45:08 2010
@@ -164,7 +164,10 @@
$get_obj->log( "GET( $uri )\n" ) if verbose( 4 );
}
- if ( $opts{save} ) {
+ if ( $opts{headonly} ) {
+ $curl->setopt( CURLOPT_NOBODY, 1 );
+ $supercurl->{headonly} = 1;
+ } elsif ( $opts{save} ) {
$curl->setopt( CURLOPT_WRITEFUNCTION, \&body_file );
$curl->setopt( CURLOPT_WRITEDATA, $supercurl );
@@ -195,6 +198,7 @@
$curl->setopt( CURLOPT_WRITEFUNCTION, \&body_scalar );
$curl->setopt( CURLOPT_WRITEDATA, \$supercurl->{body} );
}
+
if ( $opts{keep_referer} or $opts{keep_ref} ) {
$supercurl->{keep_referer} = 1;
}
@@ -496,7 +500,7 @@
bignum( $supercurl->{size_got} ),
bignum( $supercurl->{size_total} );
} else {
- $get_obj->{body} = $supercurl->{body};
+ $get_obj->{body} = $supercurl->{ $supercurl->{headonly} ? "head" : "body" };
}
$get_obj->get_finish( $eurl, $supercurl->{keep_referer} || 0 );
More information about the pld-cvs-commit
mailing list