faraday-net_http 2.1.0 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/faraday/adapter/net_http.rb +24 -45
- data/lib/faraday/net_http/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4efc5a5f90fde405f695b602850c1060a683bc2ae350f8244637895cf414a7b1
|
4
|
+
data.tar.gz: b24f51c181e5dfda23f6687347b012cbfd3d225f9c9a4310ea5b69c8277c2f3c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 828b85c9ec2c8d81f48749802a572af232574a124b16d245e903ecba162327a8b7107a046ea1f136105e6aa382a612efda5afb9dd49442d73b8f4884875f3a3e
|
7
|
+
data.tar.gz: d4cac854ff1631ee53acadf70efb2fa29608c4454e3b6a87b291c45152761cbe5ab99b98d929cc95256498631a456e677ac43be3b400b74a7a315bdedf0c9001
|
@@ -62,22 +62,13 @@ module Faraday
|
|
62
62
|
|
63
63
|
def call(env)
|
64
64
|
super
|
65
|
-
|
65
|
+
connection(env) do |http|
|
66
66
|
perform_request(http, env)
|
67
67
|
rescue *NET_HTTP_EXCEPTIONS => e
|
68
68
|
raise Faraday::SSLError, e if defined?(OpenSSL) && e.is_a?(OpenSSL::SSL::SSLError)
|
69
69
|
|
70
70
|
raise Faraday::ConnectionFailed, e
|
71
71
|
end
|
72
|
-
|
73
|
-
save_response(env, http_response.code.to_i,
|
74
|
-
encoded_body(http_response), nil,
|
75
|
-
http_response.message) do |response_headers|
|
76
|
-
http_response.each_header do |key, value|
|
77
|
-
response_headers[key] = value
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
72
|
@app.call env
|
82
73
|
rescue Timeout::Error, Errno::ETIMEDOUT => e
|
83
74
|
raise Faraday::TimeoutError, e
|
@@ -102,53 +93,41 @@ module Faraday
|
|
102
93
|
end
|
103
94
|
|
104
95
|
def perform_request(http, env)
|
105
|
-
if env
|
106
|
-
|
107
|
-
|
108
|
-
http_response = request_with_wrapped_block(http, env) do |chunk|
|
109
|
-
if chunk.bytesize.positive? || size.positive?
|
110
|
-
yielded = true
|
111
|
-
size += chunk.bytesize
|
112
|
-
env[:request].on_data.call(chunk, size)
|
113
|
-
end
|
96
|
+
if env.stream_response?
|
97
|
+
http_response = env.stream_response do |&on_data|
|
98
|
+
request_with_wrapped_block(http, env, &on_data)
|
114
99
|
end
|
115
|
-
env[:request].on_data.call(+'', 0) unless yielded
|
116
|
-
# Net::HTTP returns something,
|
117
|
-
# but it's not meaningful according to the docs.
|
118
100
|
http_response.body = nil
|
119
|
-
http_response
|
120
|
-
else
|
121
|
-
request_with_wrapped_block(http, env)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
def request_with_wrapped_block(http, env, &block)
|
126
|
-
if (env[:method] == :get) && !env[:body]
|
127
|
-
# prefer `get` to `request` because the former handles gzip (ruby 1.9)
|
128
|
-
request_via_get_method(http, env, &block)
|
129
101
|
else
|
130
|
-
|
102
|
+
http_response = request_with_wrapped_block(http, env)
|
131
103
|
end
|
104
|
+
env.response_body = encoded_body(http_response)
|
105
|
+
env.response.finish(env)
|
106
|
+
http_response
|
132
107
|
end
|
133
108
|
|
134
|
-
def
|
109
|
+
def request_with_wrapped_block(http, env)
|
135
110
|
# Must use Net::HTTP#start and pass it a block otherwise the server's
|
136
111
|
# TCP socket does not close correctly.
|
137
112
|
http.start do |opened_http|
|
138
|
-
opened_http.
|
113
|
+
opened_http.request create_request(env) do |response|
|
114
|
+
save_http_response(env, response)
|
115
|
+
|
116
|
+
if block_given?
|
117
|
+
response.read_body do |chunk|
|
118
|
+
yield(chunk)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
139
122
|
end
|
140
123
|
end
|
141
124
|
|
142
|
-
def
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
response.read_body(&block)
|
149
|
-
end
|
150
|
-
else
|
151
|
-
opened_http.request create_request(env)
|
125
|
+
def save_http_response(env, http_response)
|
126
|
+
save_response(
|
127
|
+
env, http_response.code.to_i, nil, nil, http_response.message, finished: false
|
128
|
+
) do |response_headers|
|
129
|
+
http_response.each_header do |key, value|
|
130
|
+
response_headers[key] = value
|
152
131
|
end
|
153
132
|
end
|
154
133
|
end
|
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:
|
4
|
+
version: 3.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: 2022-
|
11
|
+
date: 2022-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '2.5'
|
20
20
|
type: :development
|
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: '
|
26
|
+
version: '2.5'
|
27
27
|
description: Faraday adapter for Net::HTTP
|
28
28
|
email:
|
29
29
|
- janvanderpas@gmail.com
|
@@ -42,7 +42,7 @@ licenses:
|
|
42
42
|
metadata:
|
43
43
|
homepage_uri: https://github.com/lostisland/faraday-net_http
|
44
44
|
source_code_uri: https://github.com/lostisland/faraday-net_http
|
45
|
-
changelog_uri: https://github.com/lostisland/faraday-net_http/releases/tag/
|
45
|
+
changelog_uri: https://github.com/lostisland/faraday-net_http/releases/tag/v3.0.0
|
46
46
|
post_install_message:
|
47
47
|
rdoc_options: []
|
48
48
|
require_paths:
|
@@ -51,7 +51,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 2.
|
54
|
+
version: 2.6.0
|
55
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
56
|
requirements:
|
57
57
|
- - ">="
|