faraday-net_http 1.0.0 → 2.0.0

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: e6e5d7596613c3f2bcfde1d254ab83f9a01e23b8180d852bb08c4311a183f92f
4
- data.tar.gz: e4fa72a0f4b435d2d4d7a8594c235593c5d4797bbb33e27c47fd9c58d3e3b095
3
+ metadata.gz: 7365d1f9a008eb354cbbcce1b0e3240650af808e0bbf560cf2899ccf7f2e563e
4
+ data.tar.gz: b76c90f94af3cbb6c805c8f52a40b52493c870e47d301d49c85d62ade92c292f
5
5
  SHA512:
6
- metadata.gz: 0de17541184794c11df1c0cd37c220a1b36dbfcfc7fdfec88dcd860f354dd7916b146c8a0b18e3bc4ae770bd4ca78e3d5ff1ef623d30c2e2e2af68c118c3d496
7
- data.tar.gz: 7403a56c1f396f290f76302d1ea665c371fab0c298bd4324ff779dc55567b10953bbf9a9c5872fbe51a15b3f7cd9fc9095447bf20d2f1b9068ef4ec5baefcf6e
6
+ metadata.gz: bee9f6377442d7415517b240862fe120ef5dd9b372113d2205ac19b0c22b8ea0bf3fec4af2ba1466c9fcfe4168851bfd9078829c0076c6de842e24ade6fdafd9
7
+ data.tar.gz: 6070ef641164d592931e43ffb2f83d9fa83e1f30b41f0950c0439d90eecaad25ae0ee2ea7f7440faf7a440e9eb742e5e74d969681255050ea889fa8658def52e
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.0'
5
+ VERSION = '2.0.0'
6
6
  end
7
7
  end
@@ -1,10 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'faraday'
4
- require 'faraday/adapter'
5
-
6
- require_relative 'adapter/net_http'
7
- require_relative 'net_http/version'
4
+ require 'faraday/adapter/net_http'
5
+ require 'faraday/net_http/version'
8
6
 
9
7
  module Faraday
10
8
  module NetHttp
metadata CHANGED
@@ -1,155 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-net_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
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: 2020-12-29 00:00:00.000000000 Z
11
+ date: 2022-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.0'
27
- - !ruby/object:Gem::Dependency
28
- name: bundler
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - "~>"
32
18
  - !ruby/object:Gem::Version
33
19
  version: '2.0'
34
- type: :development
20
+ type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - "~>"
39
25
  - !ruby/object:Gem::Version
40
26
  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
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '1.0'
153
27
  description: Faraday adapter for Net::HTTP
154
28
  email:
155
29
  - janvanderpas@gmail.com
@@ -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.0
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