swift-storage 0.0.11 → 0.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 77665fc3b1c075760f657ba0c9e192191c2d7f5c
4
- data.tar.gz: 52089eaac7b7ca0f42b9c2bc1cdf0bd61e8daca6
3
+ metadata.gz: 07d3d130ca97b74bc12b9976b8f7c2e79ccc3ffd
4
+ data.tar.gz: 924eaadbcdd6710d323ed33019c6d00e2f0d735d
5
5
  SHA512:
6
- metadata.gz: 735a05bc0ca64009df31ec04dc41702d3b17eb030dfdbb8fd2d23824e9e93423c0f9e528252f39b251b246f0e959affc91411cdd548be820c0bc189b2cb600e2
7
- data.tar.gz: a6076078bd7adbed2dbf0bb82fb32428ac356715241859c21b63bfcb64fd2a2422152c615046351729fb40b993ef1b414739b416a5c2634572f0e82789e6137c
6
+ metadata.gz: 763a569994c1e698e78801a7f45b2b80f48e7cb9ec2f0b0a42acbf691289ff3c8c7c28b1912a710778f5bbf7a2d799635403a14168ed5f0af07d6e7e36908af4
7
+ data.tar.gz: 2157970a98acc0e5cb4d8de0a15d960e5d148fb63dca931153e078812ab002b47b06dc6914c6d011f085569da1ec69c2398fa853e15b2dd2390dd2c5941288a4
@@ -3,10 +3,17 @@
3
3
  This file is written in reverse chronological order, newer releases will
4
4
  appear at the top.
5
5
 
6
+ ## 0.0.12
7
+
8
+ * Net::Http `ssl_verify` can be set to `false` (default is `true`)
9
+ * Create a new Net::Http session for each request
10
+ [#13](https://github.com/PredicSis/swift-ruby/pull/2)
11
+ @ArmandPredicSis
12
+
6
13
  ## 0.0.11
7
14
 
8
15
  * Some refactoring
9
- [#11](https://github.com/PredicSis/swift-ruby/pull/1)
16
+ [#12](https://github.com/PredicSis/swift-ruby/pull/1)
10
17
  @ArmandPredicSis
11
18
 
12
19
  ## 0.0.10
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in swift-ruby.gemspec
4
3
  gemspec
@@ -1,10 +1,12 @@
1
1
  module SwiftStorage
2
2
  class Configuration
3
- attr_accessor :auth_version, :tenant, :username, :password, :endpoint, :temp_url_key,
4
- :auth_method, :authtenant_type, :retries
3
+ attr_accessor :auth_version, :ssl_verify,
4
+ :tenant, :username, :password, :endpoint, :temp_url_key,
5
+ :auth_method, :authtenant_type, :retries
5
6
 
6
7
  def initialize
7
8
  @auth_version = ENV['SWIFT_STORAGE_AUTH_VERSION'] || '1.0'
9
+ @ssl_verify = true
8
10
  @tenant = ENV['SWIFT_STORAGE_TENANT']
9
11
  @username = ENV['SWIFT_STORAGE_USERNAME']
10
12
  @password = ENV['SWIFT_STORAGE_PASSWORD']
@@ -11,6 +11,7 @@ class SwiftStorage::Service
11
11
 
12
12
  attr_reader :tenant,
13
13
  :endpoint,
14
+ :ssl_verify,
14
15
  :storage_url,
15
16
  :auth_token,
16
17
  :auth_at,
@@ -27,8 +28,10 @@ class SwiftStorage::Service
27
28
  username: configuration.username,
28
29
  password: configuration.password,
29
30
  endpoint: configuration.endpoint,
31
+ ssl_verify: configuration.ssl_verify,
30
32
  temp_url_key: configuration.temp_url_key,
31
33
  retries: configuration.retries)
34
+ @ssl_verify = ssl_verify
32
35
  @temp_url_key = temp_url_key
33
36
  @retries = retries
34
37
 
@@ -136,16 +139,6 @@ class SwiftStorage::Service
136
139
  path = uri.query ? uri.path + '?' + uri.query : uri.path
137
140
  uri.path = ''
138
141
  uri.query = nil
139
- key = uri.to_s
140
-
141
- if sessions[key].nil?
142
- s = sessions[key] = Net::HTTP.new(uri.host, uri.port)
143
- s.use_ssl = uri.scheme == 'https'
144
- #s.set_debug_output($stderr)
145
- s.keep_alive_timeout = 30
146
- s.start
147
- end
148
- s = sessions[key]
149
142
 
150
143
  case method
151
144
  when :get
@@ -169,10 +162,6 @@ class SwiftStorage::Service
169
162
  raise ArgumentError, "Method #{method} not supported"
170
163
  end
171
164
 
172
- if json_data
173
- req.body = JSON.generate(json_data)
174
- end
175
-
176
165
  if input_stream
177
166
  if String === input_stream
178
167
  input_stream = StringIO.new(input_stream)
@@ -189,15 +178,24 @@ class SwiftStorage::Service
189
178
  end
190
179
  end
191
180
 
192
- response = s.request(req, &output_proc)
193
- check_response!(response)
194
- response
181
+ response = Net::HTTP.start(uri.host, uri.port) do |http|
182
+ http.use_ssl = uri.scheme == 'https'
183
+ http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless ssl_verify
184
+ http.request(req, &output_proc)
185
+ end
186
+
187
+ case response
188
+ when Net::HTTPSuccess, Net::HTTPRedirection
189
+ return response
190
+ else
191
+ raise_error!(response)
192
+ end
195
193
  rescue AuthError => e
196
194
  # If token is at least 60 second old, we try to get a new one
197
195
  raise e unless @auth_at && (Time.now - @auth_at).to_i > 60
198
196
  authenticate!
199
197
  retry
200
- rescue ServerError, Errno::EPIPE, Timeout::Error, Errno::EINVAL, EOFError
198
+ rescue Errno::EPIPE, Timeout::Error, Errno::EINVAL, EOFError
201
199
  # Server closed the connection, retry
202
200
  sleep 5
203
201
  retry unless (tries -= 1) <= 0
@@ -208,10 +206,8 @@ class SwiftStorage::Service
208
206
 
209
207
  attr_reader :sessions, :username, :password
210
208
 
211
- def check_response!(response)
209
+ def raise_error!(response)
212
210
  case response.code
213
- when /^2/
214
- return true
215
211
  when '401'
216
212
  raise AuthError, response.body
217
213
  when '403'
@@ -1,3 +1,3 @@
1
1
  module SwiftStorage
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.16"
3
3
  end
@@ -18,7 +18,6 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
21
  spec.add_development_dependency "rake", "~> 10.0"
23
22
  spec.add_development_dependency "rspec", "~> 3.1.0"
24
23
  spec.add_development_dependency "guard", "~> 2.8.2"
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swift-storage
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Goy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-22 00:00:00.000000000 Z
11
+ date: 2016-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.7'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.7'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -180,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
166
  version: '0'
181
167
  requirements: []
182
168
  rubyforge_project:
183
- rubygems_version: 2.4.7
169
+ rubygems_version: 2.4.5.1
184
170
  signing_key:
185
171
  specification_version: 4
186
172
  summary: Swift storage client.