File: HTTPClient.pm

package info (click to toggle)
sitescooper 3.1.2-1
  • links: PTS
  • area: main
  • in suites: sarge, woody
  • size: 3,000 kB
  • ctags: 662
  • sloc: perl: 8,677; makefile: 105
file content (83 lines) | stat: -rw-r--r-- 1,715 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#===========================================================================

package Sitescooper::HTTPClient;

require Exporter;
use Carp;
use IO::Handle;
use IO::Select;

@ISA = qw(Exporter);
@EXPORT= qw();
$VERSION = "0.1";
sub Version { $VERSION; }

use strict;

sub new {
  my ($class, $scoop) = @_; $class = ref($class) || $class;
  my $self = { };
  $self->{scoop} = $scoop;
  bless ($self, $class);
  $self;
}

sub init {
  my ($self) = @_;
  croak ("HTTPClient::init called on base class");
}

sub get_max_active_requests {
  my ($self) = @_;
  croak ("HTTPClient::get_max_active_requests called on base class");
}

sub can_preload {
  my ($self) = @_;
  0;
} 

sub start_get {
  my ($self, $url, $lastmod, $is_dynamic) = @_;
  croak ("HTTPClient::start_get called on base class");
  undef;
}

# get the filehandle we're waiting for, for purposes of select().
# return undef if the output is ready anyway, and there's no fh.
sub get_waiting_fh {
  my ($self, $state) = @_;
  croak ("HTTPClient::get_fd called on base class");
}

sub ready_to_finish {
  my ($self, $state) = @_;
  croak ("HTTPClient::ready_to_finish called on base class");
}

sub finish_get {
  my ($self, $state) = @_;
  croak ("HTTPClient::finish_get called on base class");
}

1;

#===========================================================================
# a state object that HTTPRequest methods can create and return;
# used to store their state if needed.

package Sitescooper::HTTPRequestState;

@Sitescooper::HTTPRequestState::ISA = qw(Exporter);
@Sitescooper::HTTPRequestState::EXPORT= qw();

use strict;

sub new {
  my $class = shift; $class = ref($class) || $class;
  my $self = { };
  bless ($self, $class);
  $self;
}

1;