/[Grep]/lib/Grep/Action/Fetch.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /lib/Grep/Action/Fetch.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 19 by dpavlin, Sun Feb 18 12:51:26 2007 UTC revision 21 by dpavlin, Sun Feb 18 15:07:03 2007 UTC
# Line 11  package Grep::Action::Fetch; Line 11  package Grep::Action::Fetch;
11  use base qw/Grep::Action Jifty::Action/;  use base qw/Grep::Action Jifty::Action/;
12    
13  use XML::Feed;  use XML::Feed;
14    use LWP::UserAgent;
15    
16  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
17    
# Line 71  sub take_action { Line 72  sub take_action {
72                  Jifty->log->info("Fetching ", $feed->title, " at $uri");                  Jifty->log->info("Fetching ", $feed->title, " at $uri");
73          }          }
74    
75          my $xml_feed = XML::Feed->parse( URI->new($uri) )          my $ua = LWP::UserAgent->new;
76            $ua->default_header( 'Cookie' => $feed->cookie );
77            my $r = $ua->get( $uri );
78            die "Can't fetch $uri: " . $r->status_line unless ( $r->is_success );
79    
80            my $content = $r->content;
81    
82            die "No content returned from $uri" unless length( $content ) > 1;
83    
84            my $xml_feed = XML::Feed->parse( \$content )
85                  or die $feed->title, " returned ", XML::Feed->errstr, " for $uri\n";                  or die $feed->title, " returned ", XML::Feed->errstr, " for $uri\n";
86    
87          warn "fetching ", $xml_feed->title, "\n";          warn "getting entries from ", $xml_feed->title, "\n";
88    
89          my @items;          my @items;
90    
# Line 113  sub take_action { Line 123  sub take_action {
123    
124          } else {          } else {
125    
126                  $self->result->message( 'No results found' );                  $self->result->error( 'No results found' );
   
                 # with default sticky_on_failure, this will keep form data  
                 $self->result->failure( 1 );  
   
127                  return 0;                  return 0;
128    
129          }          }
130  }  }
131    

Legend:
Removed from v.19  
changed lines
  Added in v.21

  ViewVC Help
Powered by ViewVC 1.1.26