diff options
author | Daniel Friesel <derf@finalrewind.org> | 2020-06-13 14:50:50 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2020-06-13 14:50:50 +0200 |
commit | c5e32e4576ee11b7aeff76be8102d6775840b988 (patch) | |
tree | e30af3a98b21912c2759fed56b955c43d82ce63e /lib/Travel | |
parent | a44bc293f453d12675335e8ef8745058ef3713f5 (diff) |
Add tests for DB backend
Diffstat (limited to 'lib/Travel')
-rw-r--r-- | lib/Travel/Status/DE/HAFAS.pm | 17 |
1 files changed, 11 insertions, 6 deletions
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 '<?xml' ) { |