faraday-net_http 0.0.6 → 2.0.0.alpha.pre.2

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: 6e961bbdeefeaa1bc3a8faa0433fde49e9c3f2ee0eb4e27523abcbd0e7dcedde
4
- data.tar.gz: 2380be8e9ad3d94c14c03c929922cb6827d12e6d392ae445707a98c84a383290
3
+ metadata.gz: 50f1e65c56e527b724b107dbf1f4580f4de9e7d102d4617ed3c5bceecd4a1b07
4
+ data.tar.gz: f6ad202b18f54eaa665b3407bc0297c41e6ba41259220b21e186493c45019c16
5
5
  SHA512:
6
- metadata.gz: 6deb98d5ba3ae81d9748fda3a0cc342f5a41b25490fca35fb3f33ffbde10783eca848b26c950ae41091c891d0f1316f87fb90452c49c37f359491b18442cdcff
7
- data.tar.gz: 3bafd4c7fc07d5205e161a68d832f832e66c84ab04f1611863124b987c14ecec260be91db143de705c8c56c029a066063ee937494a73f505b3a3c05813703195
6
+ metadata.gz: 00e25dfdbdafe00431648975d8a31ba2ea53e4c74d688e937a0a4e87524a6987370fd99a81a22eb2548e587d138822e0984f698315c223a4baeb5f0aed8b0815
7
+ data.tar.gz: f470b1b56a0a40a590cf492c85f53e089c64ec95ff55f52a1c579b18fa304ba3c80dbf01c0e2d403a341f416cf7eb5dba953cf37c07f33a3db58a0d66d9bf088
@@ -48,30 +48,29 @@ module Faraday
48
48
  end
49
49
 
50
50
  def net_http_connection(env)
51
- klass = if (proxy = env[:request][:proxy])
52
- Net::HTTP::Proxy(proxy[:uri].hostname, proxy[:uri].port,
53
- proxy[:user], proxy[:password])
54
- else
55
- Net::HTTP
56
- end
51
+ proxy = env[:request][:proxy]
57
52
  port = env[:url].port || (env[:url].scheme == 'https' ? 443 : 80)
58
- klass.new(env[:url].hostname, port)
53
+ if proxy
54
+ Net::HTTP.new(env[:url].hostname, port,
55
+ proxy[:uri].hostname, proxy[:uri].port,
56
+ proxy[:user], proxy[:password])
57
+ else
58
+ Net::HTTP.new(env[:url].hostname, port, nil)
59
+ end
59
60
  end
60
61
 
61
62
  def call(env)
62
63
  super
63
64
  http_response = connection(env) do |http|
64
- begin
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)
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)
68
68
 
69
- raise Faraday::ConnectionFailed, e
70
- end
69
+ raise Faraday::ConnectionFailed, e
71
70
  end
72
71
 
73
72
  save_response(env, http_response.code.to_i,
74
- http_response.body || +'', nil,
73
+ encoded_body(http_response), nil,
75
74
  http_response.message) do |response_headers|
76
75
  http_response.each_header do |key, value|
77
76
  response_headers[key] = value
@@ -207,6 +206,18 @@ module Faraday
207
206
  end
208
207
  end
209
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
210
221
  end
211
222
  end
212
223
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Faraday
4
4
  module NetHttp
5
- VERSION = '0.0.6'
5
+ VERSION = '2.0.0.alpha-2'
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,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday-net_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 2.0.0.alpha.pre.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan van der Pas
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-29 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -16,140 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
20
- type: :development
19
+ version: 2.0.0.alpha.pre.2
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: '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
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '1.0'
26
+ version: 2.0.0.alpha.pre.2
153
27
  description: Faraday adapter for Net::HTTP
154
28
  email:
155
29
  - janvanderpas@gmail.com
@@ -168,8 +42,8 @@ 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
172
- post_install_message:
45
+ changelog_uri: https://github.com/lostisland/faraday-net_http/releases/tag/v2.0.0.alpha.pre.2
46
+ post_install_message:
173
47
  rdoc_options: []
174
48
  require_paths:
175
49
  - lib
@@ -180,12 +54,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
180
54
  version: 2.4.0
181
55
  required_rubygems_version: !ruby/object:Gem::Requirement
182
56
  requirements:
183
- - - ">="
57
+ - - ">"
184
58
  - !ruby/object:Gem::Version
185
- version: '0'
59
+ version: 1.3.1
186
60
  requirements: []
187
- rubygems_version: 3.1.4
188
- signing_key:
61
+ rubygems_version: 3.1.6
62
+ signing_key:
189
63
  specification_version: 4
190
64
  summary: Faraday adapter for Net::HTTP
191
65
  test_files: []