From 6b74ad103d553f0f9a17b308dde628098daa33d4 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 31 Dec 2010 01:40:30 -0600 Subject: [PATCH] Box adding via HTTP follows redirects [closes GH-163] --- CHANGELOG.md | 1 + lib/vagrant/downloaders/http.rb | 8 ++++++++ templates/locales/en.yml | 1 + 3 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index d324c85ae..4fff29d84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## 0.7.0.beta2 (unreleased) - Use numeric uid/gid in mounting shared folders to increase portability. [GH-252] + - HTTP downloading follows redirects. [GH-163] ## 0.7.0.beta (December 24, 2010) diff --git a/lib/vagrant/downloaders/http.rb b/lib/vagrant/downloaders/http.rb index 38974664f..1463de34e 100644 --- a/lib/vagrant/downloaders/http.rb +++ b/lib/vagrant/downloaders/http.rb @@ -26,6 +26,14 @@ module Vagrant http.start do |h| h.request_get(uri.request_uri) do |response| + if response.is_a?(Net::HTTPRedirection) + # Follow the HTTP redirect. + # TODO: Error on some redirect limit + env.ui.info I18n.t("vagrant.downloaders.http.follow_redirect", :url => response["Location"]) + download!(response["Location"], destination_file) + return + end + total = response.content_length progress = 0 segment_count = 0 diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 05dbfc333..d5a10fd0a 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -403,6 +403,7 @@ en: file: file_missing: "The specified path to a file doesn't exist." http: + follow_redirect: "Download following redirect: %{url}" socket_error: |- An error occurred while trying to download the specified box. This most often happens if there is no internet connection or the address is