diff options
| author | Alban Peignier | 2018-04-18 21:46:11 +0200 |
|---|---|---|
| committer | Alban Peignier | 2018-04-18 21:49:18 +0200 |
| commit | 35ef1a2abe0a664b259c99538bb95f04ef6408d4 (patch) | |
| tree | 4aaee79b2cd674b67308c248926e24b221a75cc9 /app/models/import | |
| parent | fe3c330cacef3d4367c9a051e3858551986b2c14 (diff) | |
| download | chouette-core-35ef1a2abe0a664b259c99538bb95f04ef6408d4.tar.bz2 | |
Manage download uri in Import::Gtfs (with or without schema or port). Refs #6368
Diffstat (limited to 'app/models/import')
| -rw-r--r-- | app/models/import/gtfs.rb | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/app/models/import/gtfs.rb b/app/models/import/gtfs.rb index f017c8ee5..a20c468c1 100644 --- a/app/models/import/gtfs.rb +++ b/app/models/import/gtfs.rb @@ -56,7 +56,7 @@ class Import::Gtfs < Import::Base attr_accessor :download_host def download_host - @download_host ||= Rails.application.config.rails_host.gsub("http://","") + @download_host ||= Rails.application.config.rails_host end def local_temp_directory @@ -79,11 +79,20 @@ class Import::Gtfs < Import::Base Rails.application.routes.url_helpers.download_workbench_import_path(workbench, id, token: token_download) end + def download_uri + @download_uri ||= + begin + host = download_host + host = "http://#{host}" unless host =~ %r{https?://} + URI.join(host, download_path) + end + end + def download_local_file local_temp_file do |file| begin - Net::HTTP.start(download_host) do |http| - http.request_get(download_path) do |response| + Net::HTTP.start(download_uri.host, download_uri.port) do |http| + http.request_get(download_uri.request_uri) do |response| response.read_body do |segment| file.write segment end |
