SVN: toys/rsget.pl/RSGet: Curl.pm Get.pm

sparky sparky at pld-linux.org
Sun Oct 4 15:32:04 CEST 2009


Author: sparky
Date: Sun Oct  4 15:32:03 2009
New Revision: 10674

Modified:
   toys/rsget.pl/RSGet/Curl.pm
   toys/rsget.pl/RSGet/Get.pm
Log:
- added keep_referer option


Modified: toys/rsget.pl/RSGet/Curl.pm
==============================================================================
--- toys/rsget.pl/RSGet/Curl.pm	(original)
+++ toys/rsget.pl/RSGet/Curl.pm	Sun Oct  4 15:32:03 2009
@@ -90,7 +90,7 @@
 				map { uri_escape( $_ ) . "=" . uri_escape( $post->{$_} ) }
 				sort keys %$post;
 		}
-		warn "POST( $uri ): $post\n" if verbose( 3 );
+		$get_obj->log( "POST( $uri ): $post\n" ) if verbose( 3 );
 		$curl->setopt( CURLOPT_POSTFIELDS, $post );
 		$curl->setopt( CURLOPT_POSTFIELDSIZE, length $post );
 	}
@@ -124,6 +124,9 @@
 		$curl->setopt( CURLOPT_WRITEFUNCTION, \&body_scalar );
 		$curl->setopt( CURLOPT_WRITEDATA, \$supercurl->{body} );
 	}
+	if ( $opts{keep_referer} or $opts{keep_ref} ) {
+		$supercurl->{keep_referer} = 1;
+	}
 
 	$active_curl{ $id } = $supercurl;
 	$curl_multi->add_handle( $curl );
@@ -176,6 +179,7 @@
 		$supercurl->{size_total} = $f_len;
 	}
 
+	dump_to_file( $supercurl->{head}, "head" ) if verbose( 5 );
 	my $fname;
 	if ( $supercurl->{force_name} ) {
 		$fname = $supercurl->{force_name};
@@ -345,7 +349,7 @@
 		$get_obj->{body} = $supercurl->{body};
 	}
 
-	$get_obj->get_finish( $eurl );
+	$get_obj->get_finish( $eurl, $supercurl->{keep_referer} || 0 );
 }
 
 sub need_run

Modified: toys/rsget.pl/RSGet/Get.pm
==============================================================================
--- toys/rsget.pl/RSGet/Get.pm	(original)
+++ toys/rsget.pl/RSGet/Get.pm	Sun Oct  4 15:32:03 2009
@@ -176,7 +176,9 @@
 sub get_finish
 {
 	my $self = shift;
-	$self->{_referer} = shift;
+	my $ref = shift;
+	my $keep_ref = shift;
+	$self->{_referer} = $ref unless $keep_ref;
 
 	my $func = $self->{after_curl};
 	$_ = $self->{body};


More information about the pld-cvs-commit mailing list