faraday-excon 2.0.0 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +12 -4
- data/lib/faraday/adapter/excon.rb +27 -9
- data/lib/faraday/excon/version.rb +1 -1
- metadata +26 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23faaabde9dd0295b342f883abf13b0ff8ffd8ace6f9e1d288dcb181082aa0b7
|
4
|
+
data.tar.gz: 5ac3b89d1d55411f972f0d10f5c53d5c24fc612010083768aa9d137d2b79fb85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2e4059411905358fc26a4e79688b3ff2d20ccad73b84f0e650172dda17c86582918d4e0ab348386122b25403a30b278cff134ba8863948aaee92903c640fb18
|
7
|
+
data.tar.gz: ee24c87fc472d04bf595c2b12bc4c34d2a14dbc533b416e0174fe884f150359aa6e04a6bd995b594e279f54eb247eebfbb498fa6dc62acceaaec03cd18736af9
|
data/README.md
CHANGED
@@ -29,6 +29,14 @@ conn = Faraday.new(...) do |f|
|
|
29
29
|
end
|
30
30
|
```
|
31
31
|
|
32
|
+
Passing connection options:
|
33
|
+
```ruby
|
34
|
+
conn = Faraday.new(...) do |f|
|
35
|
+
# Will keep the connection memoized within the adapter, and rely that flag to excon
|
36
|
+
f.adapter :excon, persistent: true
|
37
|
+
end
|
38
|
+
```
|
39
|
+
|
32
40
|
## Development
|
33
41
|
|
34
42
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -47,10 +55,10 @@ The gem is available as open source under the terms of the [license][license].
|
|
47
55
|
|
48
56
|
Everyone interacting in the Faraday Excon adapter project's codebase, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct][code-of-conduct].
|
49
57
|
|
50
|
-
[faraday]: https://github.com/
|
58
|
+
[faraday]: https://github.com/excon/faraday
|
51
59
|
[faraday-website]: https://lostisland.github.io/faraday
|
52
60
|
[excon]: https://github.com/excon/excon
|
53
61
|
[rubygems]: https://rubygems.org
|
54
|
-
[repo]: https://github.com/
|
55
|
-
[license]: https://github.com/
|
56
|
-
[code-of-conduct]: https://github.com/
|
62
|
+
[repo]: https://github.com/excon/faraday-excon
|
63
|
+
[license]: https://github.com/excon/faraday-excon/blob/main/LICENSE.md
|
64
|
+
[code-of-conduct]: https://github.com/excon/faraday-excon/blob/main/CODE_OF_CONDUCT.md
|
@@ -5,14 +5,27 @@ module Faraday
|
|
5
5
|
# Excon adapter.
|
6
6
|
class Excon < Faraday::Adapter
|
7
7
|
def build_connection(env)
|
8
|
+
if @connection_options[:persistent] && defined?(@connection)
|
9
|
+
return @connection
|
10
|
+
end
|
11
|
+
|
8
12
|
opts = opts_from_env(env)
|
9
|
-
|
13
|
+
|
14
|
+
# remove path & query when creating connection
|
15
|
+
# because if it is persistent, it can re-use the conn
|
16
|
+
url = env[:url].dup
|
17
|
+
url.path = ''
|
18
|
+
url.query = nil
|
19
|
+
|
20
|
+
@connection = ::Excon.new(url.to_s, opts.merge(@connection_options))
|
10
21
|
end
|
11
22
|
|
12
23
|
def call(env)
|
13
24
|
super
|
14
25
|
|
15
26
|
req_opts = {
|
27
|
+
path: env[:url].path,
|
28
|
+
query: env[:url].query,
|
16
29
|
method: env[:method].to_s.upcase,
|
17
30
|
headers: env[:request_headers],
|
18
31
|
body: read_body(env)
|
@@ -26,11 +39,22 @@ module Faraday
|
|
26
39
|
end
|
27
40
|
end
|
28
41
|
|
29
|
-
resp =
|
42
|
+
resp = connect_and_request(env, req_opts)
|
30
43
|
save_response(env, resp.status.to_i, resp.body, resp.headers,
|
31
44
|
resp.reason_phrase)
|
32
45
|
|
33
46
|
@app.call(env)
|
47
|
+
end
|
48
|
+
|
49
|
+
# TODO: support streaming requests
|
50
|
+
def read_body(env)
|
51
|
+
env[:body].respond_to?(:read) ? env[:body].read : env[:body]
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def connect_and_request(env, req_opts)
|
57
|
+
connection(env) { |http| http.request(req_opts) }
|
34
58
|
rescue ::Excon::Errors::SocketError => e
|
35
59
|
raise Faraday::TimeoutError, e if e.message.match?(/\btimeout\b/)
|
36
60
|
|
@@ -41,13 +65,6 @@ module Faraday
|
|
41
65
|
raise Faraday::TimeoutError, e
|
42
66
|
end
|
43
67
|
|
44
|
-
# TODO: support streaming requests
|
45
|
-
def read_body(env)
|
46
|
-
env[:body].respond_to?(:read) ? env[:body].read : env[:body]
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
68
|
def opts_from_env(env)
|
52
69
|
opts = {}
|
53
70
|
amend_opts_with_ssl!(opts, env[:ssl]) if needs_ssl_settings?(env)
|
@@ -65,6 +82,7 @@ module Faraday
|
|
65
82
|
end
|
66
83
|
|
67
84
|
OPTS_KEYS = [
|
85
|
+
%i[ciphers ciphers],
|
68
86
|
%i[client_cert client_cert],
|
69
87
|
%i[client_key client_key],
|
70
88
|
%i[certificate certificate],
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: faraday-excon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- "@
|
8
|
-
autorequire:
|
7
|
+
- "@geemus"
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -16,31 +16,37 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.109.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.
|
26
|
+
version: 0.109.0
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: faraday
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.11.0
|
34
|
+
- - "<"
|
32
35
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
36
|
+
version: '3'
|
34
37
|
type: :runtime
|
35
38
|
prerelease: false
|
36
39
|
version_requirements: !ruby/object:Gem::Requirement
|
37
40
|
requirements:
|
38
|
-
- - "
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 2.11.0
|
44
|
+
- - "<"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
46
|
+
version: '3'
|
41
47
|
description: Faraday adapter for Excon
|
42
48
|
email:
|
43
|
-
-
|
49
|
+
- geemus@gmail.com
|
44
50
|
executables: []
|
45
51
|
extensions: []
|
46
52
|
extra_rdoc_files: []
|
@@ -50,14 +56,15 @@ files:
|
|
50
56
|
- lib/faraday/adapter/excon.rb
|
51
57
|
- lib/faraday/excon.rb
|
52
58
|
- lib/faraday/excon/version.rb
|
53
|
-
homepage: https://github.com/
|
59
|
+
homepage: https://github.com/excon/faraday-excon
|
54
60
|
licenses:
|
55
61
|
- MIT
|
56
62
|
metadata:
|
57
|
-
homepage_uri: https://github.com/
|
58
|
-
|
59
|
-
|
60
|
-
|
63
|
+
homepage_uri: https://github.com/excon/faraday-excon
|
64
|
+
rubygems_mfa_required: 'true'
|
65
|
+
source_code_uri: https://github.com/excon/faraday-excon
|
66
|
+
changelog_uri: https://github.com/excon/faraday-excon/releases/tag/v2.2.0
|
67
|
+
post_install_message:
|
61
68
|
rdoc_options: []
|
62
69
|
require_paths:
|
63
70
|
- lib
|
@@ -65,15 +72,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
65
72
|
requirements:
|
66
73
|
- - ">="
|
67
74
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
75
|
+
version: 3.0.0
|
69
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
77
|
requirements:
|
71
78
|
- - ">="
|
72
79
|
- !ruby/object:Gem::Version
|
73
80
|
version: '0'
|
74
81
|
requirements: []
|
75
|
-
rubygems_version: 3.
|
76
|
-
signing_key:
|
82
|
+
rubygems_version: 3.5.18
|
83
|
+
signing_key:
|
77
84
|
specification_version: 4
|
78
85
|
summary: Faraday adapter for Excon
|
79
86
|
test_files: []
|