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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 193a22f95b5e48159faf27f4bd060abae29fe5c22dcddc3c462177a57aff7a2c
4
- data.tar.gz: 3574cb0a3392127275872186db0ef4cbef139573710a093d61c420544f359a7e
3
+ metadata.gz: 373c83e6252fb0439bfe307cacc18514741c9b8eaa1b9d055e1da59015c7a8f3
4
+ data.tar.gz: bc20567c842a6b6bd7d450fc6edd5ee1eb509940ffddab643a0c6a3b8ad48522
5
5
  SHA512:
6
- metadata.gz: 8a72a33280f1d2bbe0a439e00bfdbcbcc70fef690e5d6cceb7f5f2a13bfec3db45e407733251bd03b47a02f138a96f059cefb1f35462a9dd049cc062c2b16c4e
7
- data.tar.gz: cac069c954943fc756b81700c32e9a33eb76b4d27bd9e2ce29f83a9322c787012731b9f43298da64ea5a9f5df751405df209637fe9b069c4a49631a41abe9568
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.
@@ -0,0 +1,5 @@
1
+ # 0.22.1
2
+
3
+ ## Chore
4
+
5
+ Checking response class before calling `.status`, as this was being called in some places on error responses, thereby triggering the deprecation warning.
@@ -242,7 +242,8 @@ module Faraday
242
242
  Errno::EHOSTUNREACH,
243
243
  Errno::EINVAL,
244
244
  Errno::ENETUNREACH,
245
- Errno::EPIPE => e
245
+ Errno::EPIPE,
246
+ ::HTTPX::ConnectionError => e
246
247
  raise CONNECTION_FAILED_ERROR, e
247
248
  end
248
249
 
@@ -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
- sentry_span.set_data(:status, res.status)
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
 
@@ -526,8 +526,14 @@ module HTTPX
526
526
  Errno::EHOSTUNREACH,
527
527
  Errno::EINVAL,
528
528
  Errno::ENETUNREACH,
529
- Errno::EPIPE,
530
- TLSError => e
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
@@ -5,6 +5,8 @@ module HTTPX
5
5
 
6
6
  class UnsupportedSchemeError < Error; end
7
7
 
8
+ class ConnectionError < Error; end
9
+
8
10
  class TimeoutError < Error
9
11
  attr_reader :timeout
10
12
 
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 => e
78
- raise e if @ip_index <= 0
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"])
@@ -50,7 +50,8 @@ module HTTPX
50
50
  end
51
51
 
52
52
  def response=(response)
53
- if response && response.status == 100 &&
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.status == 407 &&
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
 
@@ -23,6 +23,8 @@ module HTTPX
23
23
  end
24
24
 
25
25
  def retry_on_rate_limited_response(response)
26
+ return false unless response.is_a?(Response)
27
+
26
28
  status = response.status
27
29
 
28
30
  RATE_LIMIT_CODES.include?(status)
@@ -23,6 +23,7 @@ module HTTPX
23
23
  Parser::Error,
24
24
  TLSError,
25
25
  TimeoutError,
26
+ ConnectionError,
26
27
  Connection::HTTP2::GoawayError,
27
28
  ].freeze
28
29
  DEFAULT_JITTER = ->(interval) { interval * (0.5 * (1 + rand)) }
@@ -95,8 +95,6 @@ module HTTPX
95
95
  #
96
96
  module Stream
97
97
  module InstanceMethods
98
- private
99
-
100
98
  def request(*args, stream: false, **options)
101
99
  return super(*args, **options) unless stream
102
100
 
@@ -35,7 +35,9 @@ module HTTPX
35
35
  response = super
36
36
 
37
37
  if response
38
- return response unless response.respond_to?(:headers) && response.headers.key?("upgrade")
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
 
@@ -32,6 +32,8 @@ module HTTPX
32
32
  "</D:lockinfo>"
33
33
  response = request(:lock, path, headers: headers, xml: xml)
34
34
 
35
+ return response unless response.is_a?(Response)
36
+
35
37
  return response unless blk && response.status == 200
36
38
 
37
39
  lock_token = response.headers["lock-token"]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "0.22.0"
4
+ VERSION = "0.22.2"
5
5
  end
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.0
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-21 00:00:00.000000000 Z
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