Changeset 10615 for trunk/Padre/lib/Padre/Task/HTTPClient.pm
- Timestamp:
- 02/08/10 02:23:11 (2 years ago)
- File:
-
- 1 edited
-
trunk/Padre/lib/Padre/Task/HTTPClient.pm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Padre/lib/Padre/Task/HTTPClient.pm
r10436 r10615 4 4 use strict; 5 5 use warnings; 6 7 use Padre::Constant; 6 use Padre::Constant (); 8 7 9 8 # Use all modules which may provide services for us: 10 9 11 10 our $VERSION = '0.56'; 11 our @DRIVERS = qw{ 12 Padre::Task::HTTPClient::LWP 13 }; 12 14 13 15 =pod … … 41 43 42 44 sub new { 43 44 45 my $class = shift; 45 46 my %args = @_;47 48 return if ( !defined( $args{URL} ) ) or ( $args{URL} eq '' );46 my %args = @_; 47 unless ( defined $args{URL} and length $args{URL} ) { 48 return; 49 } 49 50 50 51 # Prepare information 51 $args{headers}->{'X-Padre'} ||= 'Padre version ' . $VERSION . ' ' . Padre::Constant::PADRE_REVISION;52 $args{method} ||= 'GET';53 54 my $self;52 require Padre::Util::SVN; 53 my $revision = Padre::Util::SVN::padre_version(); 54 $args{method} ||= 'GET'; 55 $args{headers}->{'X-Padre'} ||= "Padre version $VERSION $revision"; 55 56 56 57 # Each module will be tested and the first working one should return 57 58 # a object, all others should return nothing (undef) 58 for ('LWP') { 59 60 # require 'Padre/Task/HTTPClient/' . $_ . '.pm'; 61 eval 'require Padre::Task::HTTPClient::' . $_; 59 foreach my $driver ( @DRIVERS ) { 60 eval "require $driver;"; 62 61 next if $@; 63 $self = "Padre::Task::HTTPClient::$_"->new(%args); 64 next unless defined($self); 62 my $self = $driver->new(%args) or next; 65 63 return $self; 66 64 } 67 65 68 66 return; 69 70 67 } 71 68
Note: See TracChangeset
for help on using the changeset viewer.
