Unverified Commit 34200455 authored by Birte Kristina Friesel's avatar Birte Kristina Friesel
Browse files

DBRIS: respect proxy settings for journey requests as well

parent a7b155b1
Loading
Loading
Loading
Loading
+1 −11
Original line number Diff line number Diff line
@@ -1300,17 +1300,7 @@ sub train_details_dbris {

	$self->render_later;

	Travel::Status::DE::DBRIS->new_p(
		journey     => $trip_id,
		cache       => $self->app->cache_iris_rt,
		lwp_options => {
			timeout => 10,
			agent   => 'dbf.finalrewind.org/2'
		},
		promise        => 'Mojo::Promise',
		user_agent     => Mojo::UserAgent->new,
		developer_mode => 1,
	)->then(
	$self->dbris->get_journey_p( id => $trip_id )->then(
		sub {
			my ($dbris) = @_;
			my $trip = $dbris->result;
+19 −1
Original line number Diff line number Diff line
@@ -29,6 +29,25 @@ sub new {

}

sub get_journey_p {
	my ( $self, %opt ) = @_;

	my $agent = $self->{user_agent};

	if ( my $proxy = $ENV{DBFAKEDISPLAY_DBRIS_PROXY} ) {
		$agent = Mojo::UserAgent->new;
		$agent->proxy->http($proxy);
		$agent->proxy->https($proxy);
	}

	return Travel::Status::DE::DBRIS->new_p(
		journey    => $opt{id},
		cache      => $self->{realtime_cache},
		promise    => 'Mojo::Promise',
		user_agent => $agent->request_timeout(10)
	);
}

# Input: TripID
# Output: Promise returning a Travel::Status::DE::DBRIS::Journey instance on success
sub get_polyline_p {
@@ -40,7 +59,6 @@ sub get_polyline_p {
	my $agent = $self->{user_agent};

	if ( my $proxy = $ENV{DBFAKEDISPLAY_DBRIS_PROXY} ) {
		say "set up proxy $proxy";
		$agent = Mojo::UserAgent->new;
		$agent->proxy->http($proxy);
		$agent->proxy->https($proxy);