faraday-net_http 1.0.1 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: abc66839ab88c5fc96b602b163b00c896eaee90a533db6464dbe38aa763f857f
4
- data.tar.gz: a26950415c34a093595c44b34dcd79af3efa5d9513097444e478467e882fa787
3
+ metadata.gz: cb8f3076e586085a7873fca5fdbde1a06029ed302f415ccdc0725974e1b63d4d
4
+ data.tar.gz: e4bf9d227da702db014a8009f7a284d16d57b4f389dd16e321804e3e610746dc
5
5
  SHA512:
6
- metadata.gz: 13c56f77c7bad337f780d7651479550a1f4a639eb33612c32eb76480337de2d024e531d7b22f0a8b12f4f5f787986cff208e4e5f606ec74ee4de81fe00a8458b
7
- data.tar.gz: aa3eee27950f2fc19a9a53da24ad00c66ffaf4f31b97dc110f225ccdb99d851b15a8024e70f4b6445ab026621b6a04f87e7593d178ecf5efc0673b2ef3896088
6
+ metadata.gz: 5008e8715fcd65cc2584abeda42a2e3ee2550b380e341b566b8071fc32566a8cbdba872592358f55d713c02edbdef0bb7a1ec977904245457c29f422722263b9
7
+ data.tar.gz: cb75722d3bacd09ba573d2a2a6c2b8892c7fe9e729bc26403b549f1d9bdfe406438219e2d9a553c710ae99fd09308f4f55f198d069a91efab568ced36022ca88
data/README.md CHANGED
@@ -20,16 +20,18 @@ Or install it yourself as:
20
20
 
21
21
  ## Usage
22
22
 
23
- Configure your Faraday connection to use this adapter like this:
24
-
25
23
  ```ruby
26
- connection = Faraday.new(url, conn_options) do |conn|
27
- conn.adapter(:net_http)
24
+ conn = Faraday.new(...) do |f|
25
+ f.adapter :net_http do |http|
26
+ # yields Net::HTTP
27
+ http.idle_timeout = 100
28
+ http.verify_callback = lambda do |preverify, cert_store|
29
+ # do something here...
30
+ end
31
+ end
28
32
  end
29
33
  ```
30
34
 
31
- For more information on how to setup your Faraday connection and adapters usage, please refer to the [Faraday Website][faraday-website].
32
-
33
35
  ## Development
34
36
 
35
37
  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.
@@ -49,9 +51,8 @@ The gem is available as open source under the terms of the [license][license].
49
51
  Everyone interacting in the Faraday Net::HTTP adapter project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct][code-of-conduct].
50
52
 
51
53
  [faraday]: https://github.com/lostisland/faraday
52
- [faraday-website]: https://lostisland.github.io/faraday
53
54
  [net-http]: https://ruby-doc.org/stdlib-2.7.0/libdoc/net/http/rdoc/Net/HTTP.html
54
55
  [rubygems]: https://rubygems.org
55
56
  [repo]: https://github.com/lostisland/faraday-net_http
56
57
  [license]: https://github.com/lostisland/faraday-net_http/blob/main/LICENSE.md
57
- [code-of-conduct]: https://github.com/lostisland/faraday-net_http/blob/main/CODE_OF_CONDUCT.md
58
+ [code-of-conduct]: https://github.com/lostisland/faraday-net_http/blob/main/CODE_OF_CONDUCT.md
@@ -62,17 +62,15 @@ module Faraday
62
62
  def call(env)
63
63
  super
64
64
  http_response = connection(env) do |http|
65
- begin
66
- perform_request(http, env)
67
- rescue *NET_HTTP_EXCEPTIONS => e
68
- raise Faraday::SSLError, e if defined?(OpenSSL) && e.is_a?(OpenSSL::SSL::SSLError)
65
+ perform_request(http, env)
66
+ rescue *NET_HTTP_EXCEPTIONS => e
67
+ raise Faraday::SSLError, e if defined?(OpenSSL) && e.is_a?(OpenSSL::SSL::SSLError)
69
68
 
70
- raise Faraday::ConnectionFailed, e
71
- end
69
+ raise Faraday::ConnectionFailed, e
72
70
  end
73
71
 
74
72
  save_response(env, http_response.code.to_i,
75
- http_response.body || +'', nil,
73
+ encoded_body(http_response), nil,
76
74
  http_response.message) do |response_headers|
77
75
  http_response.each_header do |key, value|
78
76
  response_headers[key] = value
@@ -208,6 +206,18 @@ module Faraday
208
206
  end
209
207
  end
210
208
  end
209
+
210
+ def encoded_body(http_response)
211
+ body = http_response.body || +''
212
+ /\bcharset=\s*(.+?)\s*(;|$)/.match(http_response['Content-Type']) do |match|
213
+ content_charset = Encoding.find(match.captures.first)
214
+ body = body.dup if body.frozen?
215
+ body.force_encoding(content_charset)
216
+ rescue ArgumentError
217
+ nil
218
+ end
219
+ body
220
+ end
211
221
  end
212
222
  end
213
223
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Faraday
4
4
  module NetHttp
5
- VERSION = '1.0.1'
5
+ VERSION = '2.0.1'
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require_relative 'adapter/net_http'
4
- require_relative 'net_http/version'
3
+ require 'faraday/adapter/net_http'
4
+ require 'faraday/net_http/version'
5
5
 
6
6
  module Faraday
7
7
  module NetHttp
metadata CHANGED
@@ -1,153 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-net_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan van der Pas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-01-12 00:00:00.000000000 Z
11
+ date: 2022-01-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '2.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '2.0'
41
- - !ruby/object:Gem::Dependency
42
- name: rake
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '13.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '13.0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: '3.0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '3.0'
69
- - !ruby/object:Gem::Dependency
70
- name: simplecov
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: 0.19.0
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - "~>"
81
- - !ruby/object:Gem::Version
82
- version: 0.19.0
83
- - !ruby/object:Gem::Dependency
84
- name: multipart-parser
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.1.1
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.1.1
97
- - !ruby/object:Gem::Dependency
98
- name: webmock
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '3.4'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '3.4'
111
- - !ruby/object:Gem::Dependency
112
- name: rubocop
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.91.1
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.91.1
125
- - !ruby/object:Gem::Dependency
126
- name: rubocop-packaging
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '0.5'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0.5'
139
- - !ruby/object:Gem::Dependency
140
- name: rubocop-performance
141
- requirement: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: '1.0'
146
- type: :development
147
- prerelease: false
148
- version_requirements: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
24
+ - - ">="
151
25
  - !ruby/object:Gem::Version
152
26
  version: '1.0'
153
27
  description: Faraday adapter for Net::HTTP
@@ -168,7 +42,7 @@ licenses:
168
42
  metadata:
169
43
  homepage_uri: https://github.com/lostisland/faraday-net_http
170
44
  source_code_uri: https://github.com/lostisland/faraday-net_http
171
- changelog_uri: https://github.com/lostisland/faraday-net_http
45
+ changelog_uri: https://github.com/lostisland/faraday-net_http/releases/tag/v2.0.1
172
46
  post_install_message:
173
47
  rdoc_options: []
174
48
  require_paths:
@@ -184,7 +58,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
58
  - !ruby/object:Gem::Version
185
59
  version: '0'
186
60
  requirements: []
187
- rubygems_version: 3.1.4
61
+ rubygems_version: 3.1.6
188
62
  signing_key:
189
63
  specification_version: 4
190
64
  summary: Faraday adapter for Net::HTTP