httpx 1.3.1 → 1.3.3

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: 0162427fe818aafee88a35a12a821cf4f1016701f4513835c91556a7e8579e9e
4
- data.tar.gz: f559d77efcdbf0e557c28c9a012cb67f45a95de8f8c2fac521800679ea30dc31
3
+ metadata.gz: 8829f986611d6b07d5c8b14ed0a51152e7f9303d01d1ec9469263f78843ce339
4
+ data.tar.gz: 8e55596dd065b9b3d352a0ad3173577556ea5bfb7963ea85287bb58d9018160b
5
5
  SHA512:
6
- metadata.gz: 1dd2fa825bdaef26137e8c5d993dcb426eab7897adc8570a343863e7842f3732948bdc827c58e1e361bb35b2c1d549b02d89051a592a836a51f39afb95a77263
7
- data.tar.gz: 8a64f6fc512fd8fa60d7feeffff6447d3c8a4081fe6494873b4a527f425dad090ca84b810a2a91477b051a4dfeb0bbb12e0563ef37c20e8d5daab05f2a208138
6
+ metadata.gz: b46a5f9f27b7571051fc95ef5d11d03cdaaa822cd08684ad1b1cf2605aacabc42ea1762f152303932bdd1e1f41c89447017ffcfaee8f995f04fdd908cbe69444
7
+ data.tar.gz: 57c5407473eb1fa8bbe7e4f3e3fef3288e8a8074776378a130894e72931833acf7bd30cd235f904fcd96cda810a3ec7118a3de9a66b28124ffd18de6b2fc1c42
@@ -0,0 +1,6 @@
1
+ # 1.3.2
2
+
3
+ ## Bugfixes
4
+
5
+ * Prevent `NoMethodError` in an edge case when the `:proxy` plugin is autoloaded via env vars and webmock adapter are used in tandem, and a real request fails.
6
+ * raise invalid uri error if passed request uri does not contain the host part (ex: `"https:/get"`)
@@ -0,0 +1,5 @@
1
+ # 1.3.2
2
+
3
+ ## Bugfixes
4
+
5
+ * fixing a regression introduced in 1.3.2 associated with the webmock adapter, which expects matchable request bodies to be strings
@@ -20,7 +20,7 @@ module WebMock
20
20
  WebMock::RequestSignature.new(
21
21
  request.verb.downcase.to_sym,
22
22
  uri.to_s,
23
- body: request.body.each.to_a.join,
23
+ body: request.body.to_s,
24
24
  headers: request.headers.to_h
25
25
  )
26
26
  end
@@ -166,6 +166,8 @@ module HTTPX
166
166
  response = super
167
167
 
168
168
  if response.is_a?(ErrorResponse) && proxy_error?(request, response)
169
+ return response unless @_proxy_uris
170
+
169
171
  @_proxy_uris.shift
170
172
 
171
173
  # return last error response if no more proxies to try
data/lib/httpx/request.rb CHANGED
@@ -83,7 +83,7 @@ module HTTPX
83
83
 
84
84
  @options = @body.options
85
85
 
86
- if @uri.relative?
86
+ if @uri.relative? || @uri.host.nil?
87
87
  origin = @options.origin
88
88
  raise(Error, "invalid URI: #{@uri}") unless origin
89
89
 
@@ -3,7 +3,7 @@
3
3
  require_relative "session"
4
4
  module HTTPX
5
5
  class Session
6
- def initialize(options = EMPTY_HASH, &blk)
6
+ def initialize(options = EMPTY, &blk)
7
7
  @options = self.class.default_options.merge(options)
8
8
  @responses = {}
9
9
  @persistent = @options.persistent
@@ -13,6 +13,8 @@ module HTTPX::Transcoder
13
13
 
14
14
  def_delegator :@raw, :to_s
15
15
 
16
+ def_delegator :@raw, :==
17
+
16
18
  def initialize(body)
17
19
  @raw = body
18
20
  end
@@ -20,6 +20,8 @@ module HTTPX
20
20
 
21
21
  def_delegator :@raw, :bytesize
22
22
 
23
+ def_delegator :@raw, :==
24
+
23
25
  def initialize(form)
24
26
  @raw = form.each_with_object("".b) do |(key, val), buf|
25
27
  HTTPX::Transcoder.normalize_keys(key, val) do |k, v|
@@ -15,6 +15,8 @@ module HTTPX::Transcoder
15
15
 
16
16
  def_delegator :@raw, :bytesize
17
17
 
18
+ def_delegator :@raw, :==
19
+
18
20
  def initialize(json)
19
21
  @raw = JSON.json_dump(json)
20
22
  @charset = @raw.encoding.name.downcase
@@ -18,6 +18,12 @@ module HTTPX
18
18
  "multipart/form-data; boundary=#{@boundary}"
19
19
  end
20
20
 
21
+ def to_s
22
+ read
23
+ ensure
24
+ rewind
25
+ end
26
+
21
27
  def read(length = nil, outbuf = nil)
22
28
  data = String(outbuf).clear.force_encoding(Encoding::BINARY) if outbuf
23
29
  data ||= "".b
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.3.1"
4
+ VERSION = "1.3.3"
5
5
  end
@@ -28,6 +28,8 @@ module HTTPX
28
28
 
29
29
  def content_type: () -> String
30
30
 
31
+ def to_s: () -> String
32
+
31
33
  def read: (?int? length, ?string? buffer) -> String?
32
34
 
33
35
  def rewind: () -> void
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: 1.3.1
4
+ version: 1.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-20 00:00:00.000000000 Z
11
+ date: 2024-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2
@@ -146,6 +146,8 @@ extra_rdoc_files:
146
146
  - doc/release_notes/1_2_6.md
147
147
  - doc/release_notes/1_3_0.md
148
148
  - doc/release_notes/1_3_1.md
149
+ - doc/release_notes/1_3_2.md
150
+ - doc/release_notes/1_3_3.md
149
151
  files:
150
152
  - LICENSE.txt
151
153
  - README.md
@@ -263,6 +265,8 @@ files:
263
265
  - doc/release_notes/1_2_6.md
264
266
  - doc/release_notes/1_3_0.md
265
267
  - doc/release_notes/1_3_1.md
268
+ - doc/release_notes/1_3_2.md
269
+ - doc/release_notes/1_3_3.md
266
270
  - lib/httpx.rb
267
271
  - lib/httpx/adapters/datadog.rb
268
272
  - lib/httpx/adapters/faraday.rb
@@ -335,7 +339,6 @@ files:
335
339
  - lib/httpx/plugins/webdav.rb
336
340
  - lib/httpx/pmatch_extensions.rb
337
341
  - lib/httpx/pool.rb
338
- - lib/httpx/pool/synch_pool.rb
339
342
  - lib/httpx/punycode.rb
340
343
  - lib/httpx/request.rb
341
344
  - lib/httpx/request/body.rb
@@ -480,7 +483,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
480
483
  - !ruby/object:Gem::Version
481
484
  version: '0'
482
485
  requirements: []
483
- rubygems_version: 3.4.10
486
+ rubygems_version: 3.5.3
484
487
  signing_key:
485
488
  specification_version: 4
486
489
  summary: HTTPX, to the future, and beyond
@@ -1,93 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "thread"
4
-
5
- module HTTPX
6
- class SynchPool < Pool
7
- def initialize(options)
8
- super
9
-
10
- @connections = ConnectionStore.new(options)
11
- end
12
-
13
- # TODO: #wrap
14
- def find_or_new_connection(uri, options, &blk)
15
- @connections.find_or_new(uri, options) do |new_conn|
16
- catch(:coalesced) do
17
- init_connection(new_conn, options)
18
- blk.call(new_conn) if blk
19
- new_conn
20
- end
21
- end
22
- find_connection(uri, options) || new_connection(uri, options, &blk)
23
- end
24
-
25
- class ConnectionManager
26
- include Enumerable
27
-
28
- def initialize(limit = 3)
29
- @connections = []
30
- @used = 0
31
- @limit = limit
32
- end
33
-
34
- def each(*args, &blk)
35
- @connections.each(*args, &blk)
36
- end
37
-
38
- def find_or_new(uri, options, &blk)
39
- raise "over limit" if @used >= @limit
40
-
41
- @used += 1
42
- conn = @connections.find do |connection|
43
- connection.match?(uri, options)
44
- end
45
-
46
- if conn
47
- @connections.delete(conn)
48
- else
49
- conn = options.connection_class.new(uri, options)
50
- blk[conn]
51
- end
52
-
53
- conn
54
- end
55
- end
56
-
57
- class ConnectionStore
58
- include Enumerable
59
-
60
- def initialize(options)
61
- @connections = Hash.new { |hs, k| hs[k] ||= ConnectionManager.new }
62
- @conn_mtx = Thread::Mutex.new
63
- @conn_waiter = ConditionVariable.new
64
- @timeout = Float(options.fetch(:pool_timeout, 5))
65
- end
66
-
67
- def each(&block)
68
- return enum_for(__meth__) unless block
69
-
70
- @conn_mtx.synchronize do
71
- @connections.each_value do |conns|
72
- conns.each(&block)
73
- end
74
- end
75
- end
76
-
77
- def find_or_new(uri, options, &blk)
78
- @connections[uri.origin].find_or_new(uri, options, &blk)
79
- end
80
-
81
- # def <<(conn)
82
- # @conn_mtx.synchronize do
83
- # origin, conns = @connections.find { |_orig, _| conn.origins.include?(origin) }
84
- # (conns || @connections[conn.origin.to_s]) << conn
85
- # end
86
- # end
87
-
88
- def empty?
89
- @conn_mtx.synchronize { super }
90
- end
91
- end
92
- end
93
- end