Skip to content
Snippets Groups Projects
Commit 12888c2c authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

StopFinder: Re-use HAFAS.pm User Agent if possible

parent 01da3afd
No related branches found
No related tags found
No related merge requests found
...@@ -118,6 +118,7 @@ sub new { ...@@ -118,6 +118,7 @@ sub new {
exclusive_mots => $conf{exclusive_mots}, exclusive_mots => $conf{exclusive_mots},
excluded_mots => $conf{excluded_mots}, excluded_mots => $conf{excluded_mots},
station => $conf{station}, station => $conf{station},
ua => $ua,
post => { post => {
input => $conf{station}, input => $conf{station},
date => $date, date => $date,
...@@ -253,6 +254,7 @@ sub similar_stops { ...@@ -253,6 +254,7 @@ sub similar_stops {
my $sf = Travel::Status::DE::HAFAS::StopFinder->new( my $sf = Travel::Status::DE::HAFAS::StopFinder->new(
url => $hafas_instance{$service}{stopfinder}, url => $hafas_instance{$service}{stopfinder},
input => $self->{station}, input => $self->{station},
ua => $self->{ua},
); );
if ( my $err = $sf->errstr ) { if ( my $err = $sf->errstr ) {
$self->{errstr} = $err; $self->{errstr} = $err;
...@@ -345,7 +347,7 @@ sub get_services { ...@@ -345,7 +347,7 @@ sub get_services {
sub get_service { sub get_service {
my ($service) = @_; my ($service) = @_;
if ( defined $service and exists $hafas_instance{$service}) { if ( defined $service and exists $hafas_instance{$service} ) {
return %{ $hafas_instance{$service} }; return %{ $hafas_instance{$service} };
} }
return; return;
...@@ -354,7 +356,7 @@ sub get_service { ...@@ -354,7 +356,7 @@ sub get_service {
sub get_active_service { sub get_active_service {
my ($self) = @_; my ($self) = @_;
if (defined $self->{active_service}) { if ( defined $self->{active_service} ) {
return %{ $hafas_instance{ $self->{active_service} } }; return %{ $hafas_instance{ $self->{active_service} } };
} }
return; return;
......
...@@ -17,12 +17,13 @@ sub new { ...@@ -17,12 +17,13 @@ sub new {
my ( $obj, %conf ) = @_; my ( $obj, %conf ) = @_;
my $lang = $conf{language} // 'd'; my $lang = $conf{language} // 'd';
my $ua = $conf{ua};
my %lwp_options = %{ $conf{lwp_options} // { timeout => 10 } }; if ( not $ua ) {
my %lwp_options = %{ $conf{lwp_options} // { timeout => 10 } };
my $ua = LWP::UserAgent->new(%lwp_options); $ua = LWP::UserAgent->new(%lwp_options);
$ua->env_proxy;
$ua->env_proxy; }
my $reply; my $reply;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment