/[meteor]/trunk/Meteor/Koha.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 /trunk/Meteor/Koha.pm

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

revision 71 by dpavlin, Sat Mar 28 14:20:59 2009 UTC revision 77 by dpavlin, Sat Mar 28 20:53:20 2009 UTC
# Line 13  sub item { Line 13  sub item {
13          my ( $class, $client, $item ) = @_;          my ( $class, $client, $item ) = @_;
14    
15          my $html;          my $html;
16            my $status = 200;
17    
18          if ( $html = $cache->{$item} ) {          if ( $html = $cache->{$item} ) {
19    
# Line 24  sub item { Line 25  sub item {
25    
26                  my $response = $ua->get( $url );                  my $response = $ua->get( $url );
27    
28                  $html = $response->content;                  if ($response->is_success) {
                 $html =~ s{<head>.+?<h1>}{<h1>}s;  
                 $html =~ s{<div class="content_set">.+$}{}s;  
                 $html =~ s{</?img[^>]+>}{}g;  
29    
30                  $cache->{$item} = $html;                          $html = $response->content;
31                            $html =~ s{<head>.+?<h1>}{<h1>}s;
32                            $html =~ s{<div class="content_set">.+$}{}s;
33                            $html =~ s{</?img[^>]+>}{}g;
34    
35                            $cache->{$item} = $html;
36    
37                    } else {
38    
39                            $html = qq{Can't load $item } . $response->status_line;
40    #                       $status = 404;
41    
42                    }
43          }          }
44    
45          my $len = length($html);          my $len = length($html);
# Line 37  sub item { Line 47  sub item {
47          warn "# koha item $item [$len]\n";          warn "# koha item $item [$len]\n";
48    
49          $client->write(          $client->write(
50                  "HTTP/1.1 200 OK\r\n" .                  "HTTP/1.1 $status OK\r\n" .
51                  "Content-Type: text/html\r\n" .                  "Content-Type: text/html\r\n" .
52                  "Content-length: $len\r\n" .                  "Content-length: $len\r\n" .
53                  "Connection: close\r\n" .                  "Connection: close\r\n" .

Legend:
Removed from v.71  
changed lines
  Added in v.77

  ViewVC Help
Powered by ViewVC 1.1.26