httpx 0.22.0 → 0.22.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 193a22f95b5e48159faf27f4bd060abae29fe5c22dcddc3c462177a57aff7a2c
4
- data.tar.gz: 3574cb0a3392127275872186db0ef4cbef139573710a093d61c420544f359a7e
3
+ metadata.gz: c5485fee0a9dde3dee5e6c0dad232f00296adfe502ec5b3e7d86e910e4325a53
4
+ data.tar.gz: 4b31eb7319c64d6522055e1bfc3f436433b2289cff8fcbac1a82fe2c2b356156
5
5
  SHA512:
6
- metadata.gz: 8a72a33280f1d2bbe0a439e00bfdbcbcc70fef690e5d6cceb7f5f2a13bfec3db45e407733251bd03b47a02f138a96f059cefb1f35462a9dd049cc062c2b16c4e
7
- data.tar.gz: cac069c954943fc756b81700c32e9a33eb76b4d27bd9e2ce29f83a9322c787012731b9f43298da64ea5a9f5df751405df209637fe9b069c4a49631a41abe9568
6
+ metadata.gz: 51ffd6a54a0b04486be732678a3a69673651777dd746950f95122493a8d580c91bf40cdbb82b6555ad01d2ccbf2bc153470ea0218a427ff7654106141c6bb4a4
7
+ data.tar.gz: b3e51d51a66cc01db0870200bdf0a4427e0c749f518153bb39aa7cd18fe53d0dd4c3cb90d56c9c6e676e36aacd8edc51f005ec5e3f31e821e1ef500c81427602
@@ -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.
@@ -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
 
@@ -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
@@ -121,6 +121,12 @@ module HTTPX
121
121
  @redirect_request || self
122
122
  end
123
123
 
124
+ def response
125
+ return super unless @redirect_request
126
+
127
+ @redirect_request.response
128
+ end
129
+
124
130
  def max_redirects
125
131
  @options.max_redirects || MAX_REDIRECTS
126
132
  end
@@ -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
 
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.1"
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.1
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,7 @@ 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
92
93
  - doc/release_notes/0_2_0.md
93
94
  - doc/release_notes/0_2_1.md
94
95
  - doc/release_notes/0_3_0.md
@@ -170,6 +171,7 @@ files:
170
171
  - doc/release_notes/0_21_0.md
171
172
  - doc/release_notes/0_21_1.md
172
173
  - doc/release_notes/0_22_0.md
174
+ - doc/release_notes/0_22_1.md
173
175
  - doc/release_notes/0_2_0.md
174
176
  - doc/release_notes/0_2_1.md
175
177
  - doc/release_notes/0_3_0.md