Ignore:
Timestamp:
02/08/10 02:23:11 (2 years ago)
Author:
adamk
Message:

Added support for --reset to flush and reset the configuration to defaults, because the Swarm plugin is instantly segfaulting Padre at startup and I didn't want to have to keep resetting the configuration by hand all the time.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Padre/lib/Padre/Task/HTTPClient.pm

    r10436 r10615  
    44use strict; 
    55use warnings; 
    6  
    7 use Padre::Constant; 
     6use Padre::Constant (); 
    87 
    98# Use all modules which may provide services for us: 
    109 
    1110our $VERSION = '0.56'; 
     11our @DRIVERS = qw{ 
     12    Padre::Task::HTTPClient::LWP 
     13}; 
    1214 
    1315=pod 
     
    4143 
    4244sub new { 
    43  
    4445    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    } 
    4950 
    5051    # 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"; 
    5556 
    5657    # Each module will be tested and the first working one should return 
    5758    # 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;"; 
    6261        next if $@; 
    63         $self = "Padre::Task::HTTPClient::$_"->new(%args); 
    64         next unless defined($self); 
     62        my $self = $driver->new(%args) or next; 
    6563        return $self; 
    6664    } 
    6765 
    6866    return; 
    69  
    7067} 
    7168 
Note: See TracChangeset for help on using the changeset viewer.