SVN: toys/rsget.pl/RSGet/Curl.pm
sparky
sparky at pld-linux.org
Sat Jun 26 15:17:47 CEST 2010
Author: sparky
Date: Sat Jun 26 15:17:46 2010
New Revision: 11584
Modified:
toys/rsget.pl/RSGet/Curl.pm
Log:
- separated set_outif() because code was taking to much space in new()
Modified: toys/rsget.pl/RSGet/Curl.pm
==============================================================================
--- toys/rsget.pl/RSGet/Curl.pm (original)
+++ toys/rsget.pl/RSGet/Curl.pm Sat Jun 26 15:17:46 2010
@@ -67,6 +67,42 @@
my %active_curl;
+{
+ my %proxytype = (
+ http => 0, # CURLPROXY_HTTP
+ http10 => 1, # CURLPROXY_HTTP_1_0
+ socks4 => 4, # CURLPROXY_SOCKS4
+ socks4a => 6, # CURLPROXY_SOCKS4a
+ socks5 => 5, # CURLPROXY_SOCKS5
+ socks => 5, # CURLPROXY_SOCKS5
+ socks5host => 7, # CURLPROXY_SOCKS5_HOSTNAME
+ );
+
+ sub set_outif
+ {
+ my $curl = shift;
+ my $outif = shift;
+ foreach my $if ( split /;+/, $outif ) {
+ if ( $if =~ /^([a-z0-9]+)=(\S+)(:(\d+))?$/ ) {
+ my ($tn, $host, $port) = ($1, $2, $4);
+ if ( my $type = $proxytype{ $tn } ) {
+ $curl->setopt( CURLOPT_PROXYTYPE, $type );
+ $curl->setopt( CURLOPT_PROXY, $host );
+ $curl->setopt( CURLOPT_PROXYPORT, $port )
+ if $port;
+ } else {
+ warn "Unrecognized proxy type '$tn' in '$outif'\n";
+ }
+ } elsif ( $if =~ /^\S+$/ ) {
+ $curl->setopt( CURLOPT_INTERFACE, $if );
+ } else {
+ warn "Unrecognized interface string '$if' in '$outif'\n";
+ }
+ }
+ }
+}
+
+
sub new
{
my $uri = shift;
@@ -89,34 +125,7 @@
$curl->setopt( CURLOPT_PRIVATE, $id );
- if ( $get_obj->{_outif} ) {
- foreach my $if ( split /;+/, $get_obj->{_outif} ) {
- if ( $if =~ /^([a-z0-9]+)=(\S+)(:(\d+))?$/ ) {
- my ($tn, $host, $port) = ($1, $2, $4);
- my %proxytype = (
- http => 0, #CURLPROXY_HTTP,
- http10 => 1, #CURLPROXY_HTTP_1_0,
- socks4 => 4, #CURLPROXY_SOCKS4,
- socks4a => 6, #CURLPROXY_SOCKS4a,
- socks5 => 5, #CURLPROXY_SOCKS5,
- socks => 5, #CURLPROXY_SOCKS5,
- socks5host => 7, #CURLPROXY_SOCKS5_HOSTNAME,
- );
- if ( my $type = $proxytype{ $tn } ) {
- $curl->setopt( CURLOPT_PROXYTYPE, $type );
- $curl->setopt( CURLOPT_PROXY, $host );
- $curl->setopt( CURLOPT_PROXYPORT, $port )
- if $port;
- } else {
- warn "Unrecognized proxy type '$tn' in '$get_obj->{_outif}'\n";
- }
- } elsif ( $if =~ /^\S+$/ ) {
- $curl->setopt( CURLOPT_INTERFACE, $if );
- } else {
- warn "Unrecognized interface string '$if' in '$get_obj->{_outif}'\n";
- }
- }
- }
+ set_outif( $curl, $get_obj->{_outif} ) if $get_obj->{_outif};
if ( defined $get_obj->{_cookie} ) {
$curl->setopt( CURLOPT_COOKIEJAR, $get_obj->{_cookie} );
More information about the pld-cvs-commit
mailing list