Permalink
Browse files

temp file

  • Loading branch information...
xiaomo
xiaomo committed Apr 20, 2012
1 parent f9fa706 commit 8c1a6410590a99ec067d60090145d801e268df29
Showing with 10 additions and 11 deletions.
  1. +10 −11 URL/Tracker.pm
View
@@ -7,36 +7,35 @@ use vars qw/$AUTOLOAD/;
use Smart::Comments;
use Carp qw/carp croak/;
BEGIN { unshift @INC, '..' }
use URL::Request;
sub new {
my $class = shift;
my $param = shift || {};
my $self = {
map { uc($_) => $param->{$_} } keys %$param
REQUEST => URL::Request->new($param);
};
bless $self, $class;
}
sub AUTOLOAD {
my $self = shift;
$AUTOLOAD =~ s/.*:://;
$self->{uc($AUTOLOAD)} = shift if scalar @_;
return $self->{uc($AUTOLOAD)};
$self->{REQUEST}->{uc($AUTOLOAD)} = shift if scalar @_;
return $self->{REQUEST}->{uc($AUTOLOAD)};
}
sub fetch {
my $self = shift;
croak "haven't set the url to fetch!"
if not defined $self->{URL};
print $self->{METHOD};
print $self->{URL};
print $self->{REQUEST}->{METHOD};
print $self->{REQUEST}->{URL};
use LWP::UserAgent;
use HTTP::Request;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(
$self->{METHOD},
$self->{URL},
);
my $req = $self->{REQUEST}->get_req();
my $res = $ua->request($req);
if ($res->is_success) {
use Data::Dumper;

0 comments on commit 8c1a641

Please sign in to comment.