excon 0.41.0 → 0.42.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of excon might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8ebf3518cde85fc3af71ea0cf17a505b2a94be1
4
- data.tar.gz: be825cbf92ebc6383d2adcda8f536dd9e1c08575
3
+ metadata.gz: 647d29332f06eae2559b7cbf7696a8322d8d3e8f
4
+ data.tar.gz: a3dd6cf5992cdfd72afc431acececc4780460ea9
5
5
  SHA512:
6
- metadata.gz: db487e313f577d715204046da7676e155061e5c954690217f318bf98238ae462d7a6b41b5edc4f587804c5bf4a42c7826d9fbef9ca9d3beecdff88ddc12fc0cb
7
- data.tar.gz: 11f213779b3e188003abf391fe4d7304dd2a28481a6bf090c5e7b9fb6b57e3dfbbc8ab3a4162be385d67cb07cf49b1bb58f7e8f8f3c58a568fb635de9c9d3f33
6
+ metadata.gz: bd5e6a0818a8b9a1021a8ac38b971d13002d08c4e036cd436441931bf666fbcb16bec89b34fb2e7b527e1be3543ee63b35d1ad87f89386398f8d9e2ceb506dbc
7
+ data.tar.gz: c112ccbc1b761d1a68f144c13095dff7d42f07f63cb085b2afb97d81abb84be7866a4b3916929d9d15a80aab14ddbb8c4e22c17a4f874f7e1f29803cb70d34d4
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- excon (0.41.0)
4
+ excon (0.42.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
data/README.md CHANGED
@@ -258,11 +258,11 @@ Or by enabling mock mode for a request.
258
258
  connection.request(:method => :get, :path => 'example', :mock => true)
259
259
  ```
260
260
 
261
- Add stubs by providing the request_attributes to match and response attributes to return. Response params can be specified as either a hash or block which will yield with response_params.
261
+ Add stubs by providing the request attributes to match and response attributes to return. Response params can be specified as either a hash or block which will yield with the request params.
262
262
 
263
263
  ```ruby
264
264
  Excon.stub({}, {:body => 'body', :status => 200})
265
- Excon.stub({}, lambda {|request_params| :body => request_params[:body], :status => 200})
265
+ Excon.stub({}, lambda {|request_params| {:body => request_params[:body], :status => 200}})
266
266
  ```
267
267
 
268
268
  Omitted attributes are assumed to match, so this stub will match *any* request and return an Excon::Response with a body of 'body' and status of 200. You can add whatever stubs you might like this way and they will be checked against in the order they were added, if none of them match then excon will raise an `Excon::Errors::StubNotFound` error to let you know.
@@ -377,7 +377,6 @@ Either of these should allow you to work around the socket error and continue wi
377
377
 
378
378
  ## Getting Help
379
379
 
380
- * [General Documentation](http://excon.io).
381
380
  * Ask specific questions on [Stack Overflow](http://stackoverflow.com/questions/tagged/excon).
382
381
  * Report bugs and discuss potential features in [Github issues](https://github.com/excon/excon/issues).
383
382
 
@@ -1,3 +1,16 @@
1
+ 0.42.0 12/02/2014
2
+ =================
3
+
4
+ fix stubbing section of README
5
+ follow redirect for all request methods
6
+ remove unhelpful link for excon.io
7
+ rescue/ignore illegal seek on rewind
8
+ add ssl_cert_store option
9
+ allow non-RSA ssl keys
10
+ attempt to rewind request_block when idempotent
11
+ add configurable thread safety for socket pool
12
+
13
+
1
14
  0.41.0 11/05/2014
2
15
  =================
3
16
 
@@ -13,8 +13,8 @@ Gem::Specification.new do |s|
13
13
  ## If your rubyforge_project name is different, then edit it and comment out
14
14
  ## the sub! line in the Rakefile
15
15
  s.name = 'excon'
16
- s.version = '0.41.0'
17
- s.date = '2014-11-05'
16
+ s.version = '0.42.0'
17
+ s.date = '2014-12-02'
18
18
  s.rubyforge_project = 'excon'
19
19
 
20
20
  ## Make sure your summary is short. The description may be as long
@@ -158,8 +158,8 @@ module Excon
158
158
  if body.respond_to?(:binmode)
159
159
  body.binmode
160
160
  end
161
- if body.respond_to?(:pos=)
162
- body.pos = 0
161
+ if body.respond_to?(:rewind)
162
+ body.rewind rescue nil
163
163
  end
164
164
  while chunk = body.read(datum[:chunk_size])
165
165
  socket.write(chunk)
@@ -384,7 +384,11 @@ module Excon
384
384
  end
385
385
 
386
386
  def sockets
387
- Thread.current[:_excon_sockets] ||= {}
387
+ if @data[:thread_safe_sockets]
388
+ Thread.current[:_excon_sockets] ||= {}
389
+ else
390
+ @_excon_sockets ||= {}
391
+ end
388
392
  end
389
393
 
390
394
  def setup_proxy
@@ -1,6 +1,6 @@
1
1
  module Excon
2
2
 
3
- VERSION = '0.41.0'
3
+ VERSION = '0.42.0'
4
4
 
5
5
  CR_NL = "\r\n"
6
6
 
@@ -82,11 +82,13 @@ module Excon
82
82
  :socket,
83
83
  :ssl_ca_file,
84
84
  :ssl_ca_path,
85
+ :ssl_cert_store,
85
86
  :ssl_verify_callback,
86
87
  :ssl_verify_peer,
87
88
  :ssl_verify_peer_host,
88
89
  :ssl_version,
89
90
  :tcp_nodelay,
91
+ :thread_safe_sockets,
90
92
  :uri_parser,
91
93
  :user
92
94
  ]
@@ -104,34 +106,35 @@ module Excon
104
106
  end
105
107
  # these come last as they rely on the above
106
108
  DEFAULTS = {
107
- :chunk_size => CHUNK_SIZE || DEFAULT_CHUNK_SIZE,
108
- :ciphers => 'HIGH:!SSLv2:!aNULL:!eNULL:!3DES',
109
- :connect_timeout => 60,
110
- :debug_request => false,
111
- :debug_response => false,
112
- :headers => {
109
+ :chunk_size => CHUNK_SIZE || DEFAULT_CHUNK_SIZE,
110
+ :ciphers => 'HIGH:!SSLv2:!aNULL:!eNULL:!3DES',
111
+ :connect_timeout => 60,
112
+ :debug_request => false,
113
+ :debug_response => false,
114
+ :headers => {
113
115
  'User-Agent' => USER_AGENT
114
116
  },
115
- :idempotent => false,
116
- :instrumentor_name => 'excon',
117
- :middlewares => [
117
+ :idempotent => false,
118
+ :instrumentor_name => 'excon',
119
+ :middlewares => [
118
120
  Excon::Middleware::ResponseParser,
119
121
  Excon::Middleware::Expects,
120
122
  Excon::Middleware::Idempotent,
121
123
  Excon::Middleware::Instrumentor,
122
124
  Excon::Middleware::Mock
123
125
  ],
124
- :mock => false,
125
- :nonblock => true,
126
- :omit_default_port => false,
127
- :persistent => false,
128
- :read_timeout => 60,
129
- :retry_limit => DEFAULT_RETRY_LIMIT,
130
- :ssl_verify_peer => true,
131
- :tcp_nodelay => false,
132
- :uri_parser => URI,
133
- :versions => VERSIONS,
134
- :write_timeout => 60
126
+ :mock => false,
127
+ :nonblock => true,
128
+ :omit_default_port => false,
129
+ :persistent => false,
130
+ :read_timeout => 60,
131
+ :retry_limit => DEFAULT_RETRY_LIMIT,
132
+ :ssl_verify_peer => true,
133
+ :tcp_nodelay => false,
134
+ :thread_safe_sockets => true,
135
+ :uri_parser => URI,
136
+ :versions => VERSIONS,
137
+ :write_timeout => 60
135
138
  }
136
139
 
137
140
  end
@@ -4,8 +4,12 @@ module Excon
4
4
  def error_call(datum)
5
5
  if datum[:idempotent]
6
6
  if datum.has_key?(:request_block)
7
- Excon.display_warning('Excon requests with a :request_block can not be :idempotent.')
8
- datum[:idempotent] = false
7
+ if datum[:request_block].respond_to?(:rewind)
8
+ datum[:request_block].rewind
9
+ else
10
+ Excon.display_warning('Excon requests with a :request_block must implement #rewind in order to be :idempotent.')
11
+ datum[:idempotent] = false
12
+ end
9
13
  end
10
14
  if datum.has_key?(:pipeline)
11
15
  Excon.display_warning("Excon requests can not be :idempotent when pipelining.")
@@ -2,9 +2,9 @@ module Excon
2
2
  module Middleware
3
3
  class RedirectFollower < Excon::Middleware::Base
4
4
  def response_call(datum)
5
- if datum.has_key?(:response) && [:get, :head].include?(datum[:method].to_s.downcase.to_sym)
5
+ if datum.has_key?(:response)
6
6
  case datum[:response][:status]
7
- when 301, 302, 303, 307
7
+ when 301, 302, 303, 307, 308
8
8
  uri_parser = datum[:uri_parser] || Excon.defaults[:uri_parser]
9
9
  _, location = datum[:response][:headers].detect do |key, value|
10
10
  key.casecmp('Location') == 0
@@ -12,11 +12,12 @@ module Excon
12
12
  uri = uri_parser.parse(location)
13
13
 
14
14
  # delete old/redirect response
15
- datum.delete(:response)
15
+ response = datum.delete(:response)
16
16
 
17
17
  params = datum.dup
18
18
  params.delete(:stack)
19
19
  params.delete(:connection)
20
+ params[:method] = :get if [301, 302, 303].include? response[:status]
20
21
  params[:headers] = datum[:headers].dup
21
22
  params[:headers].delete('Authorization')
22
23
  params[:headers].delete('Proxy-Connection')
@@ -35,9 +35,12 @@ module Excon
35
35
  if ca_path = ENV['SSL_CERT_DIR'] || @data[:ssl_ca_path]
36
36
  ssl_context.ca_path = ca_path
37
37
  end
38
+ if cert_store = @data[:ssl_cert_store]
39
+ ssl_context.cert_store = cert_store
40
+ end
38
41
 
39
42
  # no defaults, fallback to bundled
40
- unless ca_file || ca_path
43
+ unless ca_file || ca_path || cert_store
41
44
  ssl_context.cert_store = OpenSSL::X509::Store.new
42
45
  ssl_context.cert_store.set_default_paths
43
46
 
@@ -67,10 +70,18 @@ module Excon
67
70
 
68
71
  if certificate_path && private_key_path
69
72
  ssl_context.cert = OpenSSL::X509::Certificate.new(File.read(certificate_path))
70
- ssl_context.key = OpenSSL::PKey::RSA.new(File.read(private_key_path), private_key_pass)
73
+ if OpenSSL::PKey.respond_to? :read
74
+ ssl_context.key = OpenSSL::PKey.read(File.read(private_key_path), private_key_pass)
75
+ else
76
+ ssl_context.key = OpenSSL::PKey::RSA.new(File.read(private_key_path), private_key_pass)
77
+ end
71
78
  elsif @data.has_key?(:certificate) && @data.has_key?(:private_key)
72
79
  ssl_context.cert = OpenSSL::X509::Certificate.new(@data[:certificate])
73
- ssl_context.key = OpenSSL::PKey::RSA.new(@data[:private_key], private_key_pass)
80
+ if OpenSSL::PKey.respond_to? :read
81
+ ssl_context.key = OpenSSL::PKey.read(@data[:private_key], private_key_pass)
82
+ else
83
+ ssl_context.key = OpenSSL::PKey::RSA.new(@data[:private_key], private_key_pass)
84
+ end
74
85
  end
75
86
 
76
87
  if @data[:proxy]
@@ -144,6 +144,25 @@ Shindo.tests('Excon ssl verify peer (ssl)') do
144
144
  end
145
145
  end
146
146
 
147
+ Shindo.tests('Excon ssl verify peer (ssl cert store)') do
148
+ with_rackup('ssl.ru') do
149
+ connection = nil
150
+ test do
151
+ ssl_ca_cert = File.read(File.join(File.dirname(__FILE__), 'data', '127.0.0.1.cert.crt'))
152
+ ssl_cert_store = OpenSSL::X509::Store.new
153
+ ssl_cert_store.add_cert OpenSSL::X509::Certificate.new ssl_ca_cert
154
+ connection = Excon.new('https://127.0.0.1:9443', :ssl_verify_peer => true, :ssl_cert_store => ssl_cert_store )
155
+ true
156
+ end
157
+
158
+ tests('response.status').returns(200) do
159
+ response = connection.request(:method => :get, :path => '/content-length/100')
160
+
161
+ response.status
162
+ end
163
+ end
164
+ end
165
+
147
166
  Shindo.tests('Excon basics (ssl file)',['focus']) do
148
167
  with_rackup('ssl_verify_peer.ru') do
149
168
 
@@ -1,4 +1,17 @@
1
1
  Shindo.tests('Excon thread safety') do
2
+
3
+ tests('thread_safe_sockets configuration') do
4
+ tests('thread_safe_sockets default').returns(true) do
5
+ connection = Excon.new('http://foo.com')
6
+ connection.data[:thread_safe_sockets]
7
+ end
8
+
9
+ tests('with thread_safe_sockets set false').returns(false) do
10
+ connection = Excon.new('http://foo.com', :thread_safe_sockets => false)
11
+ connection.data[:thread_safe_sockets]
12
+ end
13
+ end
14
+
2
15
  with_rackup('thread_safety.ru') do
3
16
  connection = Excon.new('http://127.0.0.1:9292')
4
17
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: excon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.41.0
4
+ version: 0.42.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - dpiddy (Dan Peterson)
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-11-05 00:00:00.000000000 Z
13
+ date: 2014-12-02 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport