faraday 0.15.0 → 0.15.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -3
- data/lib/faraday.rb +1 -1
- data/lib/faraday/adapter/excon.rb +3 -0
- data/lib/faraday/adapter/net_http.rb +11 -3
- data/lib/faraday/adapter/net_http_persistent.rb +17 -14
- data/lib/faraday/adapter/patron.rb +2 -7
- data/lib/faraday/options.rb +2 -1
- data/lib/faraday/response/logger.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: db0b54b940edbbba0e72c6a5d393b101f6852c4d4c9d4b31106382a983c31045
|
4
|
+
data.tar.gz: 594b4833954d6049878ccc1e1006d4b4295da70b01809f2abbd977368215812e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 347f4c8f7e15467652370480e1131ec28ee9eeb964bc5eb8982781da79718a74bd3fe2421d57107e2245fc218b1cb0351c0df569f18b2f2fe0d1625408b8fa82
|
7
|
+
data.tar.gz: 5014a90947f8987b70facb531f9dd83f4df923ee9d14cb3b8d5250cce0fe51e0eaba6b4a1ca9b5a35db15d5b181a964b9aaeaddcfc0f4f3feec9b669a48817c5
|
data/README.md
CHANGED
@@ -54,7 +54,7 @@ Since the default middleware stack uses url\_encoded middleware and default adap
|
|
54
54
|
```ruby
|
55
55
|
conn = Faraday.new(:url => 'http://sushi.com') do |faraday|
|
56
56
|
faraday.request :url_encoded # form-encode POST params
|
57
|
-
faraday.response :logger # log requests to
|
57
|
+
faraday.response :logger # log requests to $stdout
|
58
58
|
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
59
59
|
end
|
60
60
|
|
@@ -79,7 +79,7 @@ response.body
|
|
79
79
|
|
80
80
|
conn.get '/nigiri', { :name => 'Maguro' } # GET http://sushi.com/nigiri?name=Maguro
|
81
81
|
|
82
|
-
conn.get do |req| # GET http://sushi.com/search?page=2&limit=100
|
82
|
+
conn.get do |req| # GET http://sushi.com/search?page=2&limit=100
|
83
83
|
req.url '/search', :page => 2
|
84
84
|
req.params['limit'] = 100
|
85
85
|
end
|
@@ -118,7 +118,7 @@ conn.get do |req|
|
|
118
118
|
req.options.context = {
|
119
119
|
foo: 'foo',
|
120
120
|
bar: 'bar'
|
121
|
-
}
|
121
|
+
}
|
122
122
|
end
|
123
123
|
```
|
124
124
|
|
data/lib/faraday.rb
CHANGED
@@ -15,6 +15,9 @@ module Faraday
|
|
15
15
|
opts[:client_key] = ssl[:client_key] if ssl[:client_key]
|
16
16
|
opts[:certificate] = ssl[:certificate] if ssl[:certificate]
|
17
17
|
opts[:private_key] = ssl[:private_key] if ssl[:private_key]
|
18
|
+
opts[:ssl_version] = ssl[:version] if ssl[:version]
|
19
|
+
opts[:ssl_min_version] = ssl[:min_version] if ssl[:min_version]
|
20
|
+
opts[:ssl_max_version] = ssl[:max_version] if ssl[:max_version]
|
18
21
|
|
19
22
|
# https://github.com/geemus/excon/issues/106
|
20
23
|
# https://github.com/jruby/jruby-ossl/issues/19
|
@@ -28,6 +28,11 @@ module Faraday
|
|
28
28
|
NET_HTTP_EXCEPTIONS << OpenSSL::SSL::SSLError if defined?(OpenSSL)
|
29
29
|
NET_HTTP_EXCEPTIONS << Net::OpenTimeout if defined?(Net::OpenTimeout)
|
30
30
|
|
31
|
+
def initialize(app = nil, opts = {}, &block)
|
32
|
+
@cert_store = nil
|
33
|
+
super(app, opts, &block)
|
34
|
+
end
|
35
|
+
|
31
36
|
def call(env)
|
32
37
|
super
|
33
38
|
with_net_http_connection(env) do |http|
|
@@ -106,6 +111,8 @@ module Faraday
|
|
106
111
|
http.ca_path = ssl[:ca_path] if ssl[:ca_path]
|
107
112
|
http.verify_depth = ssl[:verify_depth] if ssl[:verify_depth]
|
108
113
|
http.ssl_version = ssl[:version] if ssl[:version]
|
114
|
+
http.min_version = ssl[:min_version] if ssl[:min_version]
|
115
|
+
http.max_version = ssl[:max_version] if ssl[:max_version]
|
109
116
|
end
|
110
117
|
|
111
118
|
def configure_request(http, req)
|
@@ -117,10 +124,11 @@ module Faraday
|
|
117
124
|
|
118
125
|
def ssl_cert_store(ssl)
|
119
126
|
return ssl[:cert_store] if ssl[:cert_store]
|
127
|
+
return @cert_store if @cert_store
|
120
128
|
# Use the default cert store by default, i.e. system ca certs
|
121
|
-
cert_store = OpenSSL::X509::Store.new
|
122
|
-
cert_store.set_default_paths
|
123
|
-
cert_store
|
129
|
+
@cert_store = OpenSSL::X509::Store.new
|
130
|
+
@cert_store.set_default_paths
|
131
|
+
@cert_store
|
124
132
|
end
|
125
133
|
|
126
134
|
def ssl_verify_mode(ssl)
|
@@ -6,15 +6,16 @@ module Faraday
|
|
6
6
|
private
|
7
7
|
|
8
8
|
def net_http_connection(env)
|
9
|
-
|
10
|
-
|
11
|
-
cached_connection env[:url], proxy_uri do
|
9
|
+
@cached_connection ||=
|
12
10
|
if Net::HTTP::Persistent.instance_method(:initialize).parameters.first == [:key, :name]
|
13
|
-
Net::HTTP::Persistent.new(name: 'Faraday'
|
11
|
+
Net::HTTP::Persistent.new(name: 'Faraday')
|
14
12
|
else
|
15
|
-
Net::HTTP::Persistent.new('Faraday'
|
13
|
+
Net::HTTP::Persistent.new('Faraday')
|
16
14
|
end
|
17
|
-
|
15
|
+
|
16
|
+
proxy_uri = proxy_uri(env)
|
17
|
+
@cached_connection.proxy = proxy_uri if @cached_connection.proxy_uri != proxy_uri
|
18
|
+
@cached_connection
|
18
19
|
end
|
19
20
|
|
20
21
|
def proxy_uri(env)
|
@@ -46,17 +47,19 @@ module Faraday
|
|
46
47
|
end
|
47
48
|
|
48
49
|
def configure_ssl(http, ssl)
|
49
|
-
http
|
50
|
-
http
|
50
|
+
http_set(http, :verify_mode, ssl_verify_mode(ssl))
|
51
|
+
http_set(http, :cert_store, ssl_cert_store(ssl))
|
51
52
|
|
52
|
-
http
|
53
|
-
http
|
54
|
-
http
|
55
|
-
http
|
53
|
+
http_set(http, :certificate, ssl[:client_cert]) if ssl[:client_cert]
|
54
|
+
http_set(http, :private_key, ssl[:client_key]) if ssl[:client_key]
|
55
|
+
http_set(http, :ca_file, ssl[:ca_file]) if ssl[:ca_file]
|
56
|
+
http_set(http, :ssl_version, ssl[:version]) if ssl[:version]
|
56
57
|
end
|
57
58
|
|
58
|
-
def
|
59
|
-
(
|
59
|
+
def http_set(http, attr, value)
|
60
|
+
if http.send(attr) != value
|
61
|
+
http.send("#{attr}=", value)
|
62
|
+
end
|
60
63
|
end
|
61
64
|
end
|
62
65
|
end
|
@@ -8,7 +8,8 @@ module Faraday
|
|
8
8
|
# TODO: support streaming requests
|
9
9
|
env[:body] = env[:body].read if env[:body].respond_to? :read
|
10
10
|
|
11
|
-
session =
|
11
|
+
session = ::Patron::Session.new
|
12
|
+
@config_block.call(session) if @config_block
|
12
13
|
configure_ssl(session, env[:ssl]) if env[:url].scheme == 'https' and env[:ssl]
|
13
14
|
|
14
15
|
if req = env[:request]
|
@@ -65,12 +66,6 @@ module Faraday
|
|
65
66
|
end
|
66
67
|
end
|
67
68
|
|
68
|
-
def create_session
|
69
|
-
session = ::Patron::Session.new
|
70
|
-
@config_block.call(session) if @config_block
|
71
|
-
session
|
72
|
-
end
|
73
|
-
|
74
69
|
def configure_ssl(session, ssl)
|
75
70
|
if ssl.fetch(:verify, true)
|
76
71
|
session.cacert = ssl[:ca_file]
|
data/lib/faraday/options.rb
CHANGED
@@ -214,7 +214,8 @@ module Faraday
|
|
214
214
|
end
|
215
215
|
|
216
216
|
class SSLOptions < Options.new(:verify, :ca_file, :ca_path, :verify_mode,
|
217
|
-
:cert_store, :client_cert, :client_key, :certificate, :private_key, :verify_depth,
|
217
|
+
:cert_store, :client_cert, :client_key, :certificate, :private_key, :verify_depth,
|
218
|
+
:version, :min_version, :max_version)
|
218
219
|
|
219
220
|
def verify?
|
220
221
|
verify != false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.15.
|
4
|
+
version: 0.15.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rick Olson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-05-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: multipart-post
|