diff options
author | Birte Kristina Friesel <derf@finalrewind.org> | 2025-02-09 14:21:18 +0100 |
---|---|---|
committer | Birte Kristina Friesel <derf@finalrewind.org> | 2025-02-09 14:21:18 +0100 |
commit | e5dca31c89f64bfa137b9b6f0009cc6af0c186f2 (patch) | |
tree | 84f88d2a87f986f82564c44b4f7c434e8c73fbc0 /lib/Travel/Status | |
parent | 4234fb84ceb3fe660857361058d73a8d98d94d8e (diff) |
HAFAS: post_with_cache_p: Use proxy if required and specified for service
Diffstat (limited to 'lib/Travel/Status')
-rw-r--r-- | lib/Travel/Status/DE/HAFAS.pm | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm index bc274d7..da2d1c2 100644 --- a/lib/Travel/Status/DE/HAFAS.pm +++ b/lib/Travel/Status/DE/HAFAS.pm @@ -472,7 +472,20 @@ sub post_with_cache_p { say ' cache miss'; } - $self->{ua}->post_p( $url, $self->{post} )->then( + my $headers = {}; + my $service_desc = $hafas_instance->{ $self->{active_service} }; + + if ( $service_desc->{ua_string} ) { + $headers->{'User-Agent'} = $service_desc->{ua_string}; + } + if ( my $geoip_service = $service_desc->{geoip_lock} ) { + if ( my $proxy = $ENV{"HAFAS_PROXY_${geoip_service}"} ) { + $self->{ua}->proxy->http($proxy); + $self->{ua}->proxy->https($proxy); + } + } + + $self->{ua}->post_p( $url, $headers, $self->{post} )->then( sub { my ($tx) = @_; if ( my $err = $tx->error ) { |