httpx 0.22.0 → 0.22.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/doc/release_notes/0_22_1.md +11 -0
- data/doc/release_notes/0_22_2.md +5 -0
- data/lib/httpx/adapters/faraday.rb +2 -1
- data/lib/httpx/adapters/sentry.rb +5 -1
- data/lib/httpx/connection.rb +8 -2
- data/lib/httpx/errors.rb +2 -0
- data/lib/httpx/io/tcp.rb +7 -2
- data/lib/httpx/plugins/digest_authentication.rb +2 -0
- data/lib/httpx/plugins/expect.rb +3 -2
- data/lib/httpx/plugins/follow_redirects.rb +7 -0
- data/lib/httpx/plugins/ntlm_authentication.rb +2 -0
- data/lib/httpx/plugins/proxy/http.rb +4 -2
- data/lib/httpx/plugins/rate_limiter.rb +2 -0
- data/lib/httpx/plugins/retries.rb +1 -0
- data/lib/httpx/plugins/stream.rb +0 -2
- data/lib/httpx/plugins/upgrade.rb +3 -1
- data/lib/httpx/plugins/webdav.rb +2 -0
- data/lib/httpx/request.rb +1 -1
- data/lib/httpx/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 373c83e6252fb0439bfe307cacc18514741c9b8eaa1b9d055e1da59015c7a8f3
|
4
|
+
data.tar.gz: bc20567c842a6b6bd7d450fc6edd5ee1eb509940ffddab643a0c6a3b8ad48522
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff4fd33b7614c410fb30b4916ad430fbf2091d43d6bec5dfa3784564a4824491baa89f33e491db6a4a76c5cf8f4e9e07e2d5192a1214ee0f8283e345b3b1387e
|
7
|
+
data.tar.gz: 4da51a3015ef7a7f32f8e24b7e14324acda8c6a735cd3038e0a7a224376c60775ed533ee936ba58ad51639adcc16906a8ef8b637d9ef84733ac4546ed4ddd7de
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# 0.22.1
|
2
|
+
|
3
|
+
## Bugfixes
|
4
|
+
|
5
|
+
* `:retries` plugin: fix `HTTPX::Response#response to point to last possible response in the redirection chain.
|
6
|
+
* `:stream` plugin: Make `HTTPX::Session#request` public (as it is inn the main class) .
|
7
|
+
* return 100 responses if the request didn't specifically ask for "100-continue" negotiation (via the "expect" header).
|
8
|
+
|
9
|
+
## Improvements
|
10
|
+
|
11
|
+
Wrap low-level socket errors in a `HTTPX::ConnectionError` exception.
|
@@ -63,7 +63,11 @@ module HTTPX::Plugins
|
|
63
63
|
|
64
64
|
request_info = extract_request_info(req)
|
65
65
|
sentry_span.set_description("#{request_info[:method]} #{request_info[:url]}")
|
66
|
-
|
66
|
+
if res.is_a?(HTTPX::ErrorResponse)
|
67
|
+
sentry_span.set_data(:error, res.message)
|
68
|
+
else
|
69
|
+
sentry_span.set_data(:status, res.status)
|
70
|
+
end
|
67
71
|
sentry_span.set_timestamp(::Sentry.utc_now.to_f)
|
68
72
|
end
|
69
73
|
|
data/lib/httpx/connection.rb
CHANGED
@@ -526,8 +526,14 @@ module HTTPX
|
|
526
526
|
Errno::EHOSTUNREACH,
|
527
527
|
Errno::EINVAL,
|
528
528
|
Errno::ENETUNREACH,
|
529
|
-
Errno::EPIPE
|
530
|
-
|
529
|
+
Errno::EPIPE => e
|
530
|
+
# connect errors, exit gracefully
|
531
|
+
error = ConnectionError.new(e.message)
|
532
|
+
error.set_backtrace(e.backtrace)
|
533
|
+
handle_error(error)
|
534
|
+
@state = :closed
|
535
|
+
emit(:close)
|
536
|
+
rescue TLSError => e
|
531
537
|
# connect errors, exit gracefully
|
532
538
|
handle_error(e)
|
533
539
|
@state = :closed
|
data/lib/httpx/errors.rb
CHANGED
data/lib/httpx/io/tcp.rb
CHANGED
@@ -74,8 +74,13 @@ module HTTPX
|
|
74
74
|
try_connect
|
75
75
|
rescue Errno::ECONNREFUSED,
|
76
76
|
Errno::EADDRNOTAVAIL,
|
77
|
-
Errno::EHOSTUNREACH
|
78
|
-
|
77
|
+
Errno::EHOSTUNREACH,
|
78
|
+
SocketError => e
|
79
|
+
if @ip_index <= 0
|
80
|
+
error = ConnectionError.new(e.message)
|
81
|
+
error.set_backtrace(e.backtrace)
|
82
|
+
raise error
|
83
|
+
end
|
79
84
|
|
80
85
|
log { "failed connecting to #{@ip} (#{e.message}), trying next..." }
|
81
86
|
@ip_index -= 1
|
@@ -46,6 +46,8 @@ module HTTPX
|
|
46
46
|
|
47
47
|
probe_response = wrap { super(request).first }
|
48
48
|
|
49
|
+
return probe_response unless probe_response.is_a?(Response)
|
50
|
+
|
49
51
|
if probe_response.status == 401 && digest.can_authenticate?(probe_response.headers["www-authenticate"])
|
50
52
|
request.transition(:idle)
|
51
53
|
request.headers["authorization"] = digest.authenticate(request, probe_response.headers["www-authenticate"])
|
data/lib/httpx/plugins/expect.rb
CHANGED
@@ -50,7 +50,8 @@ module HTTPX
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def response=(response)
|
53
|
-
if response
|
53
|
+
if response.is_a?(Response) &&
|
54
|
+
response.status == 100 &&
|
54
55
|
!@headers.key?("expect") &&
|
55
56
|
(@state == :body || @state == :done)
|
56
57
|
|
@@ -92,7 +93,7 @@ module HTTPX
|
|
92
93
|
response = @responses.delete(request)
|
93
94
|
return unless response
|
94
95
|
|
95
|
-
if response.status == 417 && request.headers.key?("expect")
|
96
|
+
if response.is_a?(Response) && response.status == 417 && request.headers.key?("expect")
|
96
97
|
response.close
|
97
98
|
request.headers.delete("expect")
|
98
99
|
request.transition(:idle)
|
@@ -44,6 +44,7 @@ module HTTPX
|
|
44
44
|
|
45
45
|
max_redirects = redirect_request.max_redirects
|
46
46
|
|
47
|
+
return response unless response.is_a?(Response)
|
47
48
|
return response unless REDIRECT_STATUS.include?(response.status) && response.headers.key?("location")
|
48
49
|
return response unless max_redirects.positive?
|
49
50
|
|
@@ -121,6 +122,12 @@ module HTTPX
|
|
121
122
|
@redirect_request || self
|
122
123
|
end
|
123
124
|
|
125
|
+
def response
|
126
|
+
return super unless @redirect_request
|
127
|
+
|
128
|
+
@redirect_request.response
|
129
|
+
end
|
130
|
+
|
124
131
|
def max_redirects
|
125
132
|
@options.max_redirects || MAX_REDIRECTS
|
126
133
|
end
|
@@ -39,6 +39,8 @@ module HTTPX
|
|
39
39
|
request.headers["authorization"] = ntlm.negotiate
|
40
40
|
probe_response = wrap { super(request).first }
|
41
41
|
|
42
|
+
return probe_response unless probe_response.is_a?(Response)
|
43
|
+
|
42
44
|
if probe_response.status == 401 && ntlm.can_authenticate?(probe_response.headers["www-authenticate"])
|
43
45
|
request.transition(:idle)
|
44
46
|
request.headers["authorization"] = ntlm.authenticate(request, probe_response.headers["www-authenticate"])
|
@@ -23,6 +23,7 @@ module HTTPX
|
|
23
23
|
response = super
|
24
24
|
|
25
25
|
if response &&
|
26
|
+
response.is_a?(Response) &&
|
26
27
|
response.status == 407 &&
|
27
28
|
!request.headers.key?("proxy-authorization") &&
|
28
29
|
response.headers.key?("proxy-authenticate")
|
@@ -113,13 +114,14 @@ module HTTPX
|
|
113
114
|
|
114
115
|
def __http_on_connect(request, response)
|
115
116
|
@inflight -= 1
|
116
|
-
if response.status == 200
|
117
|
+
if response.is_a?(Response) && response.status == 200
|
117
118
|
req = @pending.first
|
118
119
|
request_uri = req.uri
|
119
120
|
@io = ProxySSL.new(@io, request_uri, @options)
|
120
121
|
transition(:connected)
|
121
122
|
throw(:called)
|
122
|
-
elsif response.
|
123
|
+
elsif response.is_a?(Response) &&
|
124
|
+
response.status == 407 &&
|
123
125
|
!request.headers.key?("proxy-authorization") &&
|
124
126
|
@options.proxy.can_authenticate?(response.headers["proxy-authenticate"])
|
125
127
|
|
data/lib/httpx/plugins/stream.rb
CHANGED
@@ -35,7 +35,9 @@ module HTTPX
|
|
35
35
|
response = super
|
36
36
|
|
37
37
|
if response
|
38
|
-
return response unless response.
|
38
|
+
return response unless response.is_a?(Response)
|
39
|
+
|
40
|
+
return response unless response.headers.key?("upgrade")
|
39
41
|
|
40
42
|
upgrade_protocol = response.headers["upgrade"].split(/ *, */).first
|
41
43
|
|
data/lib/httpx/plugins/webdav.rb
CHANGED
data/lib/httpx/request.rb
CHANGED
@@ -86,7 +86,7 @@ module HTTPX
|
|
86
86
|
def response=(response)
|
87
87
|
return unless response
|
88
88
|
|
89
|
-
if response.is_a?(Response) && response.status == 100
|
89
|
+
if response.is_a?(Response) && response.status == 100 && @headers.key?("expect")
|
90
90
|
@informational_status = response.status
|
91
91
|
return
|
92
92
|
end
|
data/lib/httpx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.22.
|
4
|
+
version: 0.22.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|
@@ -89,6 +89,8 @@ extra_rdoc_files:
|
|
89
89
|
- doc/release_notes/0_21_0.md
|
90
90
|
- doc/release_notes/0_21_1.md
|
91
91
|
- doc/release_notes/0_22_0.md
|
92
|
+
- doc/release_notes/0_22_1.md
|
93
|
+
- doc/release_notes/0_22_2.md
|
92
94
|
- doc/release_notes/0_2_0.md
|
93
95
|
- doc/release_notes/0_2_1.md
|
94
96
|
- doc/release_notes/0_3_0.md
|
@@ -170,6 +172,8 @@ files:
|
|
170
172
|
- doc/release_notes/0_21_0.md
|
171
173
|
- doc/release_notes/0_21_1.md
|
172
174
|
- doc/release_notes/0_22_0.md
|
175
|
+
- doc/release_notes/0_22_1.md
|
176
|
+
- doc/release_notes/0_22_2.md
|
173
177
|
- doc/release_notes/0_2_0.md
|
174
178
|
- doc/release_notes/0_2_1.md
|
175
179
|
- doc/release_notes/0_3_0.md
|