1
1
package Padre::Task::HTTPClient;
5
use Params::Util qw{_CODE _INSTANCE};
8
use Padre::Task::LWP ();
10
our $VERSION = '0.42';
11
our @ISA = 'Padre::Task::LWP';
7
# Use all modules which may provide services for us:
17
Padre::Task::HTTPClient - Generic http client background processing task
15
Padre::Task::HTTPClient - HTTP client for Padre
23
Sending and receiving data via HTTP.
19
Padre::Task::HTTPClient provies a common API for HTTP access to Padre.
21
As we don't want a specific HTTP client module dependency to a
22
network-independent application like Padre, this module searches
23
for installed HTTP client modules and uses one of them.
25
If none of the "child" modules could be loaded (no HTTP support at all
26
on this computer), it fails and returns nothing (scalar undef).
32
my $http = Padre::Task::HTTPClient->new();
34
The C<new> constructor lets you create a new B<Padre::Task::HTTPClient> object.
36
Returns a new B<Padre::Task::HTTPClient> or dies on error.
27
# TODO this should probably run later,
28
# not when the plugin is enabled
32
# Prepare the information to send
38
if ( $0 =~ /padre$/ ) {
41
my $revision = Padre::Util::svn_directory_revision($dir);
42
if ( -d "$dir.svn" ) {
43
$data{svn} = $revision;
46
return if ( !defined( $args{URL} ) ) or ( $args{URL} eq '' );
49
$args{headers}->{'X-Padre'} ||= 'Padre version ' . $VERSION . ' ' . Padre::Util::revision();
50
$args{method} ||= 'GET';
54
# Each module will be tested and the first working one should return
55
# a object, all others should return nothing (undef)
57
require 'Padre/Task/HTTPClient/' . $_ . '.pm';
58
$self = "Padre::Task::HTTPClient::$_"->new(%args);
59
next unless defined($self);
47
# Generate the request URL
48
my $url = URI->new('http://peride.org/popularity');
49
$url->query_form( \%data, ';' );
51
# Hand off to the parent constructor
52
return $class->SUPER::new( request => HTTP::Request->new( GET => $url->as_string ) );
71
#Returns the last-access time of the file.
73
#This is usually not possible for non-local files, in these cases, undef
78
## Fallback if the module has no such function:
61
This class inherits from C<Padre::Task> and its instances can be scheduled
62
using C<Padre::TaskManager>.
64
The transfer of the objects to and from the worker threads is implemented
69
Steffen Mueller C<smueller@cpan.org>
71
=head1 COPYRIGHT AND LICENSE
73
Copyright 2008-2009 The Padre development team as listed in Padre.pm.
75
This program is free software; you can redistribute it and/or
76
modify it under the same terms as Perl 5 itself.
80
85
# Copyright 2008-2009 The Padre development team as listed in Padre.pm.
82
87
# This program is free software; you can redistribute it and/or