mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
update excon, pass a block instead of params[:block]
This commit is contained in:
parent
1a1985db25
commit
242d7a5088
7 changed files with 58 additions and 57 deletions
2
Gemfile
2
Gemfile
|
@ -1,7 +1,7 @@
|
|||
source 'http://gemcutter.org'
|
||||
|
||||
gem 'rake'
|
||||
gem 'excon', '>= 0.0.21'
|
||||
gem 'excon', '>= 0.0.22'
|
||||
gem 'formatador', ">= 0.0.10"
|
||||
gem 'json', ">= 0"
|
||||
gem 'mime-types', ">= 0"
|
||||
|
|
88
Gemfile.lock
88
Gemfile.lock
|
@ -1,15 +1,56 @@
|
|||
---
|
||||
dependencies:
|
||||
formatador:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0.0.10"
|
||||
rake:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0"
|
||||
ruby-hmac:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0"
|
||||
mime-types:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0"
|
||||
rspec:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0"
|
||||
net-ssh:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0"
|
||||
json:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0"
|
||||
excon:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0.0.22"
|
||||
shindo:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0"
|
||||
nokogiri:
|
||||
group:
|
||||
- :default
|
||||
version: ">= 0"
|
||||
specs:
|
||||
- rake:
|
||||
version: 0.8.7
|
||||
- excon:
|
||||
version: 0.0.21
|
||||
version: 0.0.22
|
||||
- formatador:
|
||||
version: 0.0.14
|
||||
- gestalt:
|
||||
version: 0.0.6
|
||||
- json:
|
||||
version: 1.4.2
|
||||
version: 1.4.3
|
||||
- mime-types:
|
||||
version: "1.16"
|
||||
- net-ssh:
|
||||
|
@ -22,48 +63,7 @@ specs:
|
|||
version: 0.4.0
|
||||
- shindo:
|
||||
version: 0.0.18
|
||||
hash: e443f12a9a7794f2ff4fc8e8d201b12b1e8b30bb
|
||||
hash: a39d842433b002231eebfd269d32fe72b489b62f
|
||||
sources:
|
||||
- Rubygems:
|
||||
uri: http://gemcutter.org
|
||||
dependencies:
|
||||
formatador:
|
||||
version: ">= 0.0.10"
|
||||
group:
|
||||
- :default
|
||||
nokogiri:
|
||||
version: ">= 0"
|
||||
group:
|
||||
- :default
|
||||
rake:
|
||||
version: ">= 0"
|
||||
group:
|
||||
- :default
|
||||
rspec:
|
||||
version: ">= 0"
|
||||
group:
|
||||
- :default
|
||||
ruby-hmac:
|
||||
version: ">= 0"
|
||||
group:
|
||||
- :default
|
||||
mime-types:
|
||||
version: ">= 0"
|
||||
group:
|
||||
- :default
|
||||
net-ssh:
|
||||
version: ">= 0"
|
||||
group:
|
||||
- :default
|
||||
json:
|
||||
version: ">= 0"
|
||||
group:
|
||||
- :default
|
||||
excon:
|
||||
version: ">= 0.0.21"
|
||||
group:
|
||||
- :default
|
||||
shindo:
|
||||
version: ">= 0"
|
||||
group:
|
||||
- :default
|
||||
|
|
|
@ -34,14 +34,13 @@ module Fog
|
|||
headers['If-Unmodified-Since'] = options['If-Unmodified-Since'].utc.strftime("%a, %d %b %Y %H:%M:%S +0000") if options['If-Modified-Since']
|
||||
headers.merge!(options)
|
||||
request({
|
||||
:block => block,
|
||||
:expects => 200,
|
||||
:headers => headers,
|
||||
:host => "#{bucket_name}.#{@host}",
|
||||
:idempotent => true,
|
||||
:method => 'GET',
|
||||
:path => CGI.escape(object_name)
|
||||
})
|
||||
}, &block)
|
||||
end
|
||||
|
||||
def get_object_url(bucket_name, object_name, expires)
|
||||
|
|
|
@ -141,12 +141,12 @@ module Fog
|
|||
|
||||
private
|
||||
|
||||
def request(params)
|
||||
def request(params, &block)
|
||||
@connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}")
|
||||
params[:headers]['Date'] = Time.now.utc.strftime("%a, %d %b %Y %H:%M:%S +0000")
|
||||
params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
|
||||
|
||||
response = @connection.request(params)
|
||||
response = @connection.request(params, &block)
|
||||
|
||||
response
|
||||
end
|
||||
|
|
|
@ -5,13 +5,15 @@ module Fog
|
|||
@excon = Excon.new(url)
|
||||
end
|
||||
|
||||
def request(params)
|
||||
if parser = params.delete(:parser)
|
||||
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
||||
params[:block] = lambda { |chunk| body << chunk }
|
||||
def request(params, &block)
|
||||
unless block_given?
|
||||
if (parser = params.delete(:parser))
|
||||
body = Nokogiri::XML::SAX::PushParser.new(parser)
|
||||
block = lambda { |chunk| body << chunk }
|
||||
end
|
||||
end
|
||||
|
||||
response = @excon.request(params)
|
||||
response = @excon.request(params, &block)
|
||||
|
||||
if parser
|
||||
body.finish
|
||||
|
|
|
@ -112,7 +112,7 @@ module Fog
|
|||
response
|
||||
end
|
||||
|
||||
def storage_request(params, parse_json = true)
|
||||
def storage_request(params, parse_json = true, &block)
|
||||
@storage_connection = Fog::Connection.new("#{@storage_scheme}://#{@storage_host}:#{@storage_port}")
|
||||
response = @storage_connection.request({
|
||||
:body => params[:body],
|
||||
|
@ -125,7 +125,7 @@ module Fog
|
|||
:method => params[:method],
|
||||
:path => "#{@storage_path}/#{params[:path]}",
|
||||
:query => params[:query]
|
||||
})
|
||||
}, &block)
|
||||
if !response.body.empty? && parse_json
|
||||
response.body = JSON.parse(response.body)
|
||||
end
|
||||
|
|
|
@ -15,7 +15,7 @@ module Fog
|
|||
:expects => 200,
|
||||
:method => 'GET',
|
||||
:path => "#{CGI.escape(container)}/#{CGI.escape(object)}"
|
||||
}, false)
|
||||
}, false, &block)
|
||||
response
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue