httpx 1.7.1 → 1.7.2

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: a9c30e22a2d406a61ef87a58fddd607bb2b1fad7b50d837d8db062d4a538a2d2
4
- data.tar.gz: 9c5e1997b9c03434071c59b2deb2b004f7b1a1077c2ccaed03b9e3a1db7aafe5
3
+ metadata.gz: c67e4695d8ef368321f14a3c113daad0e49280413e3da42272644ad84fe6f622
4
+ data.tar.gz: 62bb1ab9d91ca69c9b1fa561051ffb0ed137afb53e0b40f71cfd477a84a78773
5
5
  SHA512:
6
- metadata.gz: 87d99c4971b99f086f7811be81a8453e71bd2535120b5e560a2fc837d50e8a040e70ab1b2b191beee4b481fcea5063576d8895d318a0089183c21cb59fdd0f24
7
- data.tar.gz: 85469cf5b5822990367f1e5591798a1512de90a60226853da4b4e6b00dde8816d6218dd2aacc9b5d85f84f6cb1637dd4f7b37836863f44144f05329e4fbdf7f5
6
+ metadata.gz: 266576dae6b8ed604228b464281239b760df9682d27e9010b18ac7dbab4fb00f23115e5bcae1a0ecee6b191ee03a0eca758c37f8f0baee0e2ad9df5ca0c7eff6
7
+ data.tar.gz: e355df3c634811d0d8e08bcb10b661a4f486073e6ca808ca3af3585a4d014cd404c8d7a55e38d0d05419f205d9dc81a54fb5a17eab7e1716c38c160297963e0f
@@ -0,0 +1,6 @@
1
+ # 1.7.2
2
+
3
+ ## Bugfixes
4
+
5
+ * `:stream_bidi` plugin: when used with the `:retries` plugin, it will skip calling callbacks referencing state from the connection/stream the request was moved from.
6
+ * `:auth` plugin: fix issue causing tokens to be concatenated on non-auth errors.
@@ -69,7 +69,7 @@ module HTTPX
69
69
  private
70
70
 
71
71
  def send_request(request, *)
72
- return super if @skip_auth_header_value
72
+ return super if @skip_auth_header_value || request.authorized?
73
73
 
74
74
  @auth_header_value ||= generate_auth_token
75
75
 
@@ -92,12 +92,31 @@ module HTTPX
92
92
  end
93
93
 
94
94
  module RequestMethods
95
+ def initialize(*)
96
+ super
97
+ @auth_token_value = nil
98
+ end
99
+
100
+ def authorized?
101
+ !@auth_token_value.nil?
102
+ end
103
+
104
+ def unauthorize!
105
+ return unless (auth_value = @auth_token_value)
106
+
107
+ @headers.get("authorization").delete(auth_value)
108
+
109
+ @auth_token_value = nil
110
+ end
111
+
95
112
  def authorize(auth_value)
96
113
  if (auth_type = @options.auth_header_type)
97
114
  auth_value = "#{auth_type} #{auth_value}"
98
115
  end
99
116
 
100
117
  @headers.add("authorization", auth_value)
118
+
119
+ @auth_token_value = auth_value
101
120
  end
102
121
  end
103
122
 
@@ -119,7 +138,7 @@ module HTTPX
119
138
  return unless auth_error?(response, request.options) ||
120
139
  (@options.generate_auth_value_on_retry && @options.generate_auth_value_on_retry.call(response))
121
140
 
122
- request.headers.get("authorization").pop
141
+ request.unauthorize!
123
142
  @auth_header_value = generate_auth_token
124
143
  end
125
144
 
@@ -46,7 +46,7 @@ module HTTPX
46
46
 
47
47
  if probe_response.status == 401 && ntlm.can_authenticate?(probe_response.headers["www-authenticate"])
48
48
  request.transition(:idle)
49
- request.headers.get("authorization").pop
49
+ request.unauthorize!
50
50
  request.authorize(ntlm.authenticate(request, probe_response.headers["www-authenticate"]).encode("utf-8"))
51
51
  super(request)
52
52
  else
@@ -61,7 +61,7 @@ module HTTPX
61
61
  def handle_stream(stream, request)
62
62
  return super unless @options.stream
63
63
 
64
- request.on(:body) do
64
+ request.flush_buffer_on_body do
65
65
  next unless request.headers_sent
66
66
 
67
67
  handle(request, stream)
@@ -254,9 +254,14 @@ module HTTPX
254
254
  super
255
255
  @headers_sent = false
256
256
  @closed = false
257
+ @flush_buffer_on_body_cb = nil
257
258
  @mutex = Thread::Mutex.new
258
259
  end
259
260
 
261
+ def flush_buffer_on_body(&cb)
262
+ @flush_buffer_on_body_cb = on(:body, &cb)
263
+ end
264
+
260
265
  def closed?
261
266
  return super unless @options.stream
262
267
 
@@ -280,6 +285,11 @@ module HTTPX
280
285
  case nextstate
281
286
  when :idle
282
287
  headers_sent = false
288
+
289
+ if @flush_buffer_on_body_cb
290
+ callbacks(:body).delete(@flush_buffer_on_body_cb)
291
+ @flush_buffer_on_body_cb = nil
292
+ end
283
293
  when :waiting_for_chunk
284
294
  return unless @state == :body
285
295
  when :body
data/lib/httpx/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "1.7.1"
4
+ VERSION = "1.7.2"
5
5
  end
data/sig/plugins/auth.rbs CHANGED
@@ -29,6 +29,12 @@ module HTTPX
29
29
  end
30
30
 
31
31
  module RequestMethods
32
+ @auth_token_value: String?
33
+
34
+ def authorized?: () -> bool
35
+
36
+ def unauthorize!: () -> void
37
+
32
38
  def authorize: (String auth_value) -> void
33
39
  end
34
40
 
@@ -47,8 +47,11 @@ module HTTPX
47
47
  attr_accessor headers_sent: bool
48
48
 
49
49
  @closed: bool
50
+ @flush_buffer_on_body_cb: ^() -> void | nil
50
51
  @mutex: Thread::Mutex
51
52
 
53
+ def flush_buffer_on_body: { () -> void } -> void
54
+
52
55
  def closed?: () -> bool
53
56
  end
54
57
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
@@ -161,6 +161,7 @@ extra_rdoc_files:
161
161
  - doc/release_notes/1_6_3.md
162
162
  - doc/release_notes/1_7_0.md
163
163
  - doc/release_notes/1_7_1.md
164
+ - doc/release_notes/1_7_2.md
164
165
  files:
165
166
  - LICENSE.txt
166
167
  - README.md
@@ -294,6 +295,7 @@ files:
294
295
  - doc/release_notes/1_6_3.md
295
296
  - doc/release_notes/1_7_0.md
296
297
  - doc/release_notes/1_7_1.md
298
+ - doc/release_notes/1_7_2.md
297
299
  - lib/httpx.rb
298
300
  - lib/httpx/adapters/datadog.rb
299
301
  - lib/httpx/adapters/faraday.rb