core: download metadata with JSON accept header

This commit is contained in:
Mitchell Hashimoto 2014-02-07 10:30:25 -08:00
parent 2dac667544
commit d4c753c48d
2 changed files with 9 additions and 1 deletions

View File

@ -134,7 +134,7 @@ module Vagrant
metadata = nil
begin
metadata_path = download(url, env, ui: false)
metadata_path = download(url, env, json: true, ui: false)
File.open(metadata_path) do |f|
metadata = BoxMetadata.new(f)
@ -391,6 +391,7 @@ module Vagrant
downloader_options[:continue] = true
downloader_options[:insecure] = env[:box_download_insecure]
downloader_options[:client_cert] = env[:box_client_cert]
downloader_options[:headers] = ["Accept: application/json"] if opts[:json]
downloader_options[:ui] = env[:ui] if opts[:ui]
Util::Downloader.new(url, temp_path, downloader_options)

View File

@ -26,6 +26,7 @@ module Vagrant
options ||= {}
@ca_cert = options[:ca_cert]
@continue = options[:continue]
@headers = options[:headers]
@insecure = options[:insecure]
@ui = options[:ui]
@client_cert = options[:client_cert]
@ -180,6 +181,12 @@ module Vagrant
options << "--insecure" if @insecure
options << "--cert" << @client_cert if @client_cert
if @headers
Array(@headers).each do |header|
options << "-H" << header
end
end
# Specify some options for the subprocess
subprocess_options = {}