From 8995cf0d4bfd1a329b4923f22f432bf099e909d3 Mon Sep 17 00:00:00 2001 From: erickson Date: Mon, 12 Mar 2007 19:51:48 +0000 Subject: [PATCH] Added timeout option to the the HTTP calls. set in the config section for the added content handlers. git-svn-id: svn://svn.open-ils.org/ILS/trunk@7064 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm | 21 +++++++++++++++++++++ .../perlmods/OpenILS/WWW/AddedContent/Syndetic.pm | 8 +++----- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm b/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm index 18aec2a2b1..49beceb919 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent.pm @@ -30,13 +30,19 @@ sub import { } +my $net_timeout; sub child_init { OpenSRF::System->bootstrap_client( config_file => $bs_config ); my $sclient = OpenSRF::Utils::SettingsClient->new(); my $ac_data = $sclient->config_value("added_content"); + + return unless $ac_data; + my $ac_handler = $ac_data->{module}; + $net_timeout = $ac_data->{timeout} || 3; + return unless $ac_handler; $logger->debug("Attempting to load Added Content handler: $ac_handler"); @@ -81,5 +87,20 @@ sub handler { +# generic GET call +sub get_url { + my( $self, $url ) = @_; + $logger->info("added content getting [timeout=$net_timeout] URL = $url"); + my $agent = LWP::UserAgent->new(timeout => $net_timeout); + my $res = $agent->get($url); + die "added content request failed: " . $res->status_line ."\n" unless $res->is_success; + return $res->content; +} + + + + + + 1; diff --git a/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Syndetic.pm b/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Syndetic.pm index 6e09b264e1..80a294a9e6 100644 --- a/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Syndetic.pm +++ b/Open-ILS/src/perlmods/OpenILS/WWW/AddedContent/Syndetic.pm @@ -5,6 +5,7 @@ use OpenSRF::Utils::Logger qw/$logger/; use OpenSRF::Utils::SettingsParser; use JSON; use OpenSRF::EX qw/:try/; +use OpenILS::WWW::AddedContent; @@ -223,12 +224,9 @@ sub fetch_content { my( $self, $page, $key ) = @_; my $uname = $self->userid; my $url = $self->base_url . "?isbn=$key/$page&client=$uname&type=rw12"; - $logger->info("added content URL = $url"); - my $agent = LWP::UserAgent->new; - my $res = $agent->get($url); - die "added content request failed: " . $res->status_line ."\n" unless $res->is_success; - return $res->content; + return OpenILS::WWW::AddedContent->get_url($url); } + 1; -- 2.11.0