diff --git a/Gemfile b/Gemfile index cec3a013b..bfcf6fe0c 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'http://gemcutter.org' gem 'rake' -gem 'excon', '>= 0.1.0' +gem 'excon', '>= 0.1.1' gem 'formatador', ">= 0.0.10" gem 'json', ">= 0" gem 'mime-types', ">= 0" diff --git a/Gemfile.lock b/Gemfile.lock index ad507b13d..be4710c04 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -31,7 +31,7 @@ dependencies: excon: group: - :default - version: ">= 0.1.0" + version: ">= 0.1.1" builder: group: - :default @@ -50,7 +50,7 @@ specs: - builder: version: 2.1.2 - excon: - version: 0.1.0 + version: 0.1.1 - formatador: version: 0.0.14 - gestalt: @@ -69,7 +69,7 @@ specs: version: 0.4.0 - shindo: version: 0.1.6 -hash: 8e1636212741876b9021efe871e1f6cd8969ab94 +hash: 566a73651b09dfc6a62475d86d7f75545ce12990 sources: - Rubygems: uri: http://gemcutter.org diff --git a/fog.gemspec b/fog.gemspec index 03ca5ad67..b5234e21e 100644 --- a/fog.gemspec +++ b/fog.gemspec @@ -42,7 +42,7 @@ Gem::Specification.new do |s| ## List your runtime dependencies here. Runtime dependencies are those ## that are needed for an end user to actually USE your code. - s.add_dependency('excon', '>=0.1.0') + s.add_dependency('excon', '>=0.1.1') s.add_dependency('formatador', '>=0.0.10') s.add_dependency('json') s.add_dependency('mime-types') diff --git a/lib/fog/aws/ec2.rb b/lib/fog/aws/ec2.rb index 03fe02e9f..706c8a3d6 100644 --- a/lib/fog/aws/ec2.rb +++ b/lib/fog/aws/ec2.rb @@ -160,13 +160,16 @@ module Fog end @port = options[:port] || 443 @scheme = options[:scheme] || 'https' + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) + end + + def reload + @connection.reset end private def request(params) - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") - idempotent = params.delete(:idempotent) parser = params.delete(:parser) diff --git a/lib/fog/aws/elb.rb b/lib/fog/aws/elb.rb index d48d178e7..f9f67b29c 100644 --- a/lib/fog/aws/elb.rb +++ b/lib/fog/aws/elb.rb @@ -63,13 +63,16 @@ module Fog end @port = options[:port] || 443 @scheme = options[:scheme] || 'https' + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) + end + + def reload + @connection.reset end private def request(params) - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") - idempotent = params.delete(:idempotent) parser = params.delete(:parser) diff --git a/lib/fog/aws/s3.rb b/lib/fog/aws/s3.rb index 18ad38cde..4716405da 100644 --- a/lib/fog/aws/s3.rb +++ b/lib/fog/aws/s3.rb @@ -135,11 +135,11 @@ module Fog end @port = options[:port] || 443 @scheme = options[:scheme] || 'https' - reload + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent] || true) end def reload - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") + @connection.reset end private diff --git a/lib/fog/aws/simpledb.rb b/lib/fog/aws/simpledb.rb index 92ed83f0e..adc647f83 100644 --- a/lib/fog/aws/simpledb.rb +++ b/lib/fog/aws/simpledb.rb @@ -68,6 +68,7 @@ module Fog @nil_string = options[:nil_string]|| 'nil' @port = options[:port] || 443 @scheme = options[:scheme] || 'https' + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) end private @@ -117,8 +118,11 @@ module Fog encoded_attributes end + def reload + @connection.reset + end + def request(params) - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") idempotent = params.delete(:idempotent) parser = params.delete(:parser) diff --git a/lib/fog/bluebox.rb b/lib/fog/bluebox.rb index 17484798b..b7585a617 100644 --- a/lib/fog/bluebox.rb +++ b/lib/fog/bluebox.rb @@ -53,10 +53,14 @@ module Fog @host = options[:bluebox_host] || "boxpanel.blueboxgrp.com" @port = options[:bluebox_port] || 443 @scheme = options[:bluebox_scheme] || 'https' + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) + end + + def reload + @connection.reset end def request(params) - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") params[:headers] ||= {} params[:headers].merge!({ 'Authorization' => "Basic #{Base64.encode64([@bluebox_customer_id, @bluebox_api_key].join(':')).delete("\r\n")}" diff --git a/lib/fog/connection.rb b/lib/fog/connection.rb index c4adbc8a9..9a4d819c5 100644 --- a/lib/fog/connection.rb +++ b/lib/fog/connection.rb @@ -1,11 +1,15 @@ module Fog class Connection - def initialize(url) + def initialize(url, persistent=false) @excon = Excon.new(url) + @persistent = persistent end def request(params, &block) + unless @persistent + reset + end unless block_given? if (parser = params.delete(:parser)) body = Nokogiri::XML::SAX::PushParser.new(parser) @@ -23,5 +27,9 @@ module Fog response end + def reset + @excon.reset + end + end end diff --git a/lib/fog/rackspace/files.rb b/lib/fog/rackspace/files.rb index 428c683fd..838944fe0 100644 --- a/lib/fog/rackspace/files.rb +++ b/lib/fog/rackspace/files.rb @@ -78,20 +78,27 @@ module Fog def initialize(options={}) credentials = Fog::Rackspace.authenticate(options) @auth_token = credentials['X-Auth-Token'] + cdn_uri = URI.parse(credentials['X-CDN-Management-Url']) @cdn_host = cdn_uri.host @cdn_path = cdn_uri.path @cdn_port = cdn_uri.port @cdn_scheme = cdn_uri.scheme + @cdn_connection = Fog::Connection.new("#{@cdn_scheme}://#{@cdn_host}:#{@cdn_port}", options[:persistent]) + storage_uri = URI.parse(credentials['X-Storage-Url']) @storage_host = storage_uri.host @storage_path = storage_uri.path @storage_port = storage_uri.port @storage_scheme = storage_uri.scheme + @storage_connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}", options[:persistent]) + end + + def reload + @connection.reset end def cdn_request(params) - @cdn_connection = Fog::Connection.new("#{@cdn_scheme}://#{@cdn_host}:#{@cdn_port}") response = @cdn_connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', @@ -107,7 +114,6 @@ module Fog end def storage_request(params, parse_json = true, &block) - @storage_connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}") response = @storage_connection.request(params.merge!({ :headers => { 'Content-Type' => 'application/json', diff --git a/lib/fog/rackspace/servers.rb b/lib/fog/rackspace/servers.rb index 67a3bcc29..fc98084d6 100644 --- a/lib/fog/rackspace/servers.rb +++ b/lib/fog/rackspace/servers.rb @@ -73,10 +73,14 @@ module Fog @path = uri.path @port = uri.port @scheme = uri.scheme + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) + end + + def reload + @connection.reset end def request(params) - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") begin response = @connection.request(params.merge!({ :headers => { diff --git a/lib/fog/slicehost.rb b/lib/fog/slicehost.rb index 6b3e8dcd4..0afad97b3 100644 --- a/lib/fog/slicehost.rb +++ b/lib/fog/slicehost.rb @@ -54,10 +54,14 @@ module Fog @host = options[:host] || "api.slicehost.com" @port = options[:port] || 443 @scheme = options[:scheme] || 'https' + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) + end + + def reload + @connection.reset end def request(params) - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") params[:headers] ||= {} params[:headers].merge!({ 'Authorization' => "Basic #{Base64.encode64(@slicehost_password).delete("\r\n")}" diff --git a/lib/fog/terremark/ecloud.rb b/lib/fog/terremark/ecloud.rb index b7b08392a..bcbb6c589 100644 --- a/lib/fog/terremark/ecloud.rb +++ b/lib/fog/terremark/ecloud.rb @@ -42,6 +42,7 @@ module Fog @path = options[:path] || Fog::Terremark::Ecloud::Defaults::PATH @port = options[:port] || Fog::Terremark::Ecloud::Defaults::PORT @scheme = options[:scheme] || Fog::Terremark::Ecloud::Defaults::SCHEME + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) end end diff --git a/lib/fog/terremark/shared.rb b/lib/fog/terremark/shared.rb index 555ba312f..88f3e33c0 100644 --- a/lib/fog/terremark/shared.rb +++ b/lib/fog/terremark/shared.rb @@ -51,8 +51,11 @@ module Fog response.headers['Set-Cookie'] end + def reload + @connection.reset + end + def request(params) - @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}") unless @cookie @cookie = auth_token end diff --git a/lib/fog/terremark/vcloud.rb b/lib/fog/terremark/vcloud.rb index aa03f3d87..9c5069766 100644 --- a/lib/fog/terremark/vcloud.rb +++ b/lib/fog/terremark/vcloud.rb @@ -42,6 +42,7 @@ module Fog @path = options[:path] || Fog::Terremark::Vcloud::Defaults::PATH @port = options[:port] || Fog::Terremark::Vcloud::Defaults::PORT @scheme = options[:scheme] || Fog::Terremark::Vcloud::Defaults::SCHEME + @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", options[:persistent]) end def default_vdc_id