From c5e32e4576ee11b7aeff76be8102d6775840b988 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 13 Jun 2020 14:50:50 +0200 Subject: Add tests for DB backend --- lib/Travel/Status/DE/HAFAS.pm | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'lib/Travel') diff --git a/lib/Travel/Status/DE/HAFAS.pm b/lib/Travel/Status/DE/HAFAS.pm index 010b1f9..4a74692 100644 --- a/lib/Travel/Status/DE/HAFAS.pm +++ b/lib/Travel/Status/DE/HAFAS.pm @@ -145,14 +145,19 @@ sub new { my $url = ( $conf{url} // $hafas_instance{$service}{url} ) . "/${lang}n"; - $reply = $ua->post( $url, $ref->{post} ); - - if ( $reply->is_error ) { - $ref->{errstr} = $reply->status_line; - return $ref; + if ( $conf{xml} ) { + $ref->{raw_xml} = $conf{xml}; } + else { + $reply = $ua->post( $url, $ref->{post} ); + + if ( $reply->is_error ) { + $ref->{errstr} = $reply->status_line; + return $ref; + } - $ref->{raw_xml} = $reply->content; + $ref->{raw_xml} = $reply->content; + } # the interface often does not return valid XML (but it's close!) if ( substr( $ref->{raw_xml}, 0, 5 ) ne '