httpx 1.2.5 → 1.3.0

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.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/1_2_6.md +13 -0
  3. data/doc/release_notes/1_3_0.md +18 -0
  4. data/lib/httpx/adapters/datadog.rb +1 -1
  5. data/lib/httpx/adapters/faraday.rb +1 -0
  6. data/lib/httpx/adapters/webmock.rb +1 -1
  7. data/lib/httpx/connection/http1.rb +3 -2
  8. data/lib/httpx/connection/http2.rb +6 -6
  9. data/lib/httpx/connection.rb +11 -5
  10. data/lib/httpx/io/tcp.rb +1 -1
  11. data/lib/httpx/io/unix.rb +5 -3
  12. data/lib/httpx/options.rb +3 -7
  13. data/lib/httpx/parser/http1.rb +4 -0
  14. data/lib/httpx/plugins/aws_sigv4.rb +1 -1
  15. data/lib/httpx/plugins/cookies.rb +6 -6
  16. data/lib/httpx/plugins/follow_redirects.rb +44 -24
  17. data/lib/httpx/plugins/grpc.rb +3 -2
  18. data/lib/httpx/plugins/h2c.rb +1 -1
  19. data/lib/httpx/plugins/oauth.rb +1 -1
  20. data/lib/httpx/plugins/proxy/http.rb +2 -2
  21. data/lib/httpx/plugins/proxy/socks4.rb +1 -1
  22. data/lib/httpx/plugins/proxy/socks5.rb +1 -1
  23. data/lib/httpx/plugins/rate_limiter.rb +2 -0
  24. data/lib/httpx/plugins/ssrf_filter.rb +1 -1
  25. data/lib/httpx/request/body.rb +37 -41
  26. data/lib/httpx/request.rb +36 -10
  27. data/lib/httpx/resolver/https.rb +1 -1
  28. data/lib/httpx/resolver/native.rb +26 -8
  29. data/lib/httpx/resolver/resolver.rb +1 -1
  30. data/lib/httpx/response.rb +2 -2
  31. data/lib/httpx/session.rb +20 -17
  32. data/lib/httpx/timers.rb +1 -1
  33. data/lib/httpx/transcoder/multipart/encoder.rb +1 -1
  34. data/lib/httpx/version.rb +1 -1
  35. data/sig/chainable.rbs +2 -2
  36. data/sig/connection/http1.rbs +2 -2
  37. data/sig/connection/http2.rbs +17 -17
  38. data/sig/connection.rbs +7 -6
  39. data/sig/httpx.rbs +3 -3
  40. data/sig/io/ssl.rbs +1 -0
  41. data/sig/io/tcp.rbs +1 -1
  42. data/sig/io/unix.rbs +18 -1
  43. data/sig/options.rbs +5 -14
  44. data/sig/parser/http1.rbs +1 -1
  45. data/sig/plugins/callbacks.rbs +1 -1
  46. data/sig/plugins/follow_redirects.rbs +10 -5
  47. data/sig/plugins/grpc.rbs +5 -0
  48. data/sig/plugins/proxy/http.rbs +3 -0
  49. data/sig/plugins/proxy/socks4.rbs +5 -2
  50. data/sig/plugins/proxy/socks5.rbs +5 -2
  51. data/sig/plugins/push_promise.rbs +3 -3
  52. data/sig/plugins/rate_limiter.rbs +1 -1
  53. data/sig/plugins/retries.rbs +2 -0
  54. data/sig/request/body.rbs +1 -3
  55. data/sig/request.rbs +2 -1
  56. data/sig/resolver/https.rbs +1 -1
  57. data/sig/resolver/native.rbs +2 -0
  58. data/sig/resolver/resolver.rbs +1 -1
  59. data/sig/response.rbs +1 -1
  60. data/sig/session.rbs +10 -7
  61. data/sig/transcoder/multipart.rbs +11 -6
  62. data/sig/transcoder/xml.rbs +1 -0
  63. data/sig/utils.rbs +4 -0
  64. metadata +10 -6
data/sig/parser/http1.rbs CHANGED
@@ -29,7 +29,7 @@ module HTTPX
29
29
  @_has_trailers: bool
30
30
  @upgrade: bool
31
31
 
32
- def <<: (String chunk) -> void
32
+ def <<: (string chunk) -> void
33
33
 
34
34
  def reset!: () -> void
35
35
 
@@ -7,7 +7,7 @@ module HTTPX
7
7
  module InstanceMethods
8
8
  include HTTPX::Callbacks
9
9
 
10
- type socket = TCPSocket | SSLSocket | UNIXSocket
10
+ type socket = TCPSocket | OpenSSL::SSL::SSLSocket | UNIXSocket
11
11
 
12
12
  def on_connection_opened: () { (http_uri origin, socket sock) -> void } -> self
13
13
 
@@ -5,6 +5,9 @@ module HTTPX
5
5
  module FollowRedirects
6
6
  MAX_REDIRECTS: Integer
7
7
  REDIRECT_STATUS: Range[Integer]
8
+ REQUEST_BODY_HEADERS: Array[String]
9
+
10
+ type redirect_request = Request & RequestMethods
8
11
 
9
12
  interface _FollowRedirectsOptions
10
13
  def max_redirects: () -> Integer?
@@ -13,7 +16,7 @@ module HTTPX
13
16
 
14
17
  def allow_auth_to_other_origins: () -> bool?
15
18
 
16
- def redirect_on: (http_uri) -> bool?
19
+ def redirect_on: () -> (^(http_uri) -> boolish | nil)
17
20
  end
18
21
 
19
22
  def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
@@ -21,17 +24,19 @@ module HTTPX
21
24
  module InstanceMethods
22
25
  def max_redirects: (_ToI) -> instance
23
26
 
24
- def redirect_request_headers: (http_uri original_uri, http_uri redirect_uri, Headers headers, Options & _FollowRedirectsOptions options) -> Headers
27
+ def handle_after_redirect_request: (http_uri original_uri, http_uri redirect_uri, Request request, Options & _FollowRedirectsOptions options) -> void
25
28
 
26
- def __get_location_from_response: (Response) -> (URI::HTTP | URI::HTTPS)
29
+ def __get_location_from_response: (Response) -> http_uri
27
30
  end
28
31
 
29
32
  module RequestMethods
30
33
  attr_accessor root_request: instance?
31
34
 
32
- def redirect_request: () -> instance
35
+ @redirect_request: redirect_request
36
+
37
+ def redirect_request: () -> redirect_request
33
38
 
34
- def redirect_request=: (Request) -> void
39
+ def redirect_request=: (redirect_request req) -> void
35
40
 
36
41
  def max_redirects: () -> Integer
37
42
  end
data/sig/plugins/grpc.rbs CHANGED
@@ -7,6 +7,11 @@ module HTTPX
7
7
 
8
8
  module Plugins
9
9
  module GRPC
10
+ DEADLINE: Integer
11
+ MARSHAL_METHOD: Symbol
12
+ UNMARSHAL_METHOD: Symbol
13
+ HEADERS: Hash[String, String]
14
+
10
15
  type compression_option = bool | String
11
16
  type rpc_def = [String, untyped, untyped, Hash[Symbol, untyped]]
12
17
 
@@ -16,6 +16,9 @@ module HTTPX
16
16
  def __http_on_connect: (top, Response) -> void
17
17
  end
18
18
 
19
+ class ConnectRequest < Request
20
+ def initialize: (generic_uri uri, Options options) -> void
21
+ end
19
22
  end
20
23
  end
21
24
 
@@ -13,7 +13,10 @@ module HTTPX
13
13
  end
14
14
 
15
15
  class SocksParser
16
- include Callbacks
16
+ include HTTPX::Callbacks
17
+
18
+ @buffer: Buffer
19
+ @options: Options
17
20
 
18
21
  def close: () -> void
19
22
  def consume: (*untyped) -> void
@@ -22,7 +25,7 @@ module HTTPX
22
25
 
23
26
  private
24
27
 
25
- def initialize: (Buffer buffer, Options) -> untyped
28
+ def initialize: (Buffer buffer, Options options) -> untyped
26
29
  end
27
30
 
28
31
  module Packet
@@ -15,7 +15,10 @@ module HTTPX
15
15
  end
16
16
 
17
17
  class SocksParser
18
- include Callbacks
18
+ include HTTPX::Callbacks
19
+
20
+ @buffer: Buffer
21
+ @options: Options
19
22
 
20
23
  def close: () -> void
21
24
  def consume: (*untyped) -> void
@@ -24,7 +27,7 @@ module HTTPX
24
27
 
25
28
  private
26
29
 
27
- def initialize: (Buffer buffer, Options) -> untyped
30
+ def initialize: (Buffer buffer, Options options) -> untyped
28
31
  end
29
32
 
30
33
  module Packet
@@ -9,9 +9,9 @@ module HTTPX
9
9
  module InstanceMethods
10
10
  private
11
11
 
12
- def promise_headers: () -> Hash[HTTP2Next::Stream, Request]
13
- def __on_promise_request: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
14
- def __on_promise_response: (Connection::HTTP2, HTTP2Next::Stream, headers_input) -> void
12
+ def promise_headers: () -> Hash[::HTTP2::Stream, Request]
13
+ def __on_promise_request: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
14
+ def __on_promise_response: (Connection::HTTP2, ::HTTP2::Stream, headers_input) -> void
15
15
  end
16
16
  end
17
17
 
@@ -5,7 +5,7 @@ module HTTPX
5
5
 
6
6
  def self.retry_on_rate_limited_response: (_Response) -> bool
7
7
 
8
- def self.retry_after_rate_limit: (untyped, _Response) -> Numeric?
8
+ def self.retry_after_rate_limit: (untyped, response) -> Numeric?
9
9
  end
10
10
  end
11
11
  end
@@ -29,6 +29,8 @@ module HTTPX
29
29
 
30
30
  private
31
31
 
32
+ def fetch_response: (retriesRequest request, Array[Connection] connections, retriesOptions options) -> (retriesResponse | ErrorResponse)?
33
+
32
34
  def __repeatable_request?: (retriesRequest request, retriesOptions options) -> boolish
33
35
 
34
36
  def __retryable_error?: (_Exception error) -> bool
data/sig/request/body.rbs CHANGED
@@ -4,7 +4,7 @@ module HTTPX
4
4
  @body: body_encoder?
5
5
  @unbounded_body: bool
6
6
 
7
- def initialize: (Headers headers, Options options) -> void
7
+ def initialize: (Headers headers, Options options, ?body: bodyIO, ?form: Transcoder::urlencoded_input?, ?json: _ToJson?, **untyped) -> void
8
8
 
9
9
  def each: () { (String) -> void } -> void
10
10
  | () -> Enumerable[String]
@@ -25,8 +25,6 @@ module HTTPX
25
25
 
26
26
  private
27
27
 
28
- def initialize_body: (Options options) -> void
29
-
30
28
  def self.initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
31
29
  end
32
30
 
data/sig/request.rbs CHANGED
@@ -19,12 +19,13 @@ module HTTPX
19
19
 
20
20
  attr_writer persistent: bool
21
21
 
22
+ @query_params: Hash[interned, untyped]?
22
23
  @trailers: Headers?
23
24
  @informational_status: Integer?
24
25
  @query: String?
25
26
  @drainer: Enumerator[String, void]?
26
27
 
27
- def initialize: (Symbol | String, generic_uri, ?options) -> untyped
28
+ def initialize: (Symbol | String verb, generic_uri uri, Options options, ?request_params params) -> untyped
28
29
 
29
30
  def interests: () -> (:r | :w)
30
31
 
@@ -11,7 +11,7 @@ module HTTPX
11
11
  @options: Options
12
12
  @requests: Hash[Request, String]
13
13
  @connections: Array[Connection]
14
- @uri: URI::Generic
14
+ @uri: http_uri
15
15
  @uri_addresses: Array[String]?
16
16
  @resolver: Resolv::DNS
17
17
  @resolver_connection: Connection
@@ -59,6 +59,8 @@ module HTTPX
59
59
 
60
60
  def build_socket: () -> (UDP | TCP)
61
61
 
62
+ def downgrade_socket: () -> void
63
+
62
64
  def transition: (Symbol nextstate) -> void
63
65
 
64
66
  def handle_error: (NativeResolveError | StandardError) -> void
@@ -26,7 +26,7 @@ module HTTPX
26
26
 
27
27
  def emit_resolved_connection: (Connection connection, Array[IPAddr] addresses, bool early_resolve) -> void
28
28
 
29
- def initialize: (ip_family? family, options options) -> void
29
+ def initialize: (ip_family? family, Options options) -> void
30
30
 
31
31
  def early_resolve: (Connection connection, ?hostname: String) -> void
32
32
 
data/sig/response.rbs CHANGED
@@ -91,7 +91,7 @@ module HTTPX
91
91
 
92
92
  private
93
93
 
94
- def initialize: (Request, Exception, options) -> untyped
94
+ def initialize: (Request, Exception) -> untyped
95
95
  end
96
96
 
97
97
  type response = Response | ErrorResponse
data/sig/session.rbs CHANGED
@@ -15,7 +15,7 @@ module HTTPX
15
15
 
16
16
  def close: (*untyped) -> void
17
17
 
18
- def build_request: (verb, generic_uri, ?options) -> Request
18
+ def build_request: (verb verb, generic_uri uri, ?request_params params, ?Options options) -> Request
19
19
 
20
20
  def initialize: (?options) { (self) -> void } -> void
21
21
  | (?options) -> void
@@ -23,8 +23,11 @@ module HTTPX
23
23
  private
24
24
 
25
25
  def pool: -> Pool
26
+
26
27
  def on_response: (Request, response) -> void
28
+
27
29
  def on_promise: (untyped, untyped) -> void
30
+
28
31
  def fetch_response: (Request request, Array[Connection] connections, untyped options) -> response?
29
32
 
30
33
  def find_connection: (Request request, Array[Connection] connections, Options options) -> Connection
@@ -37,13 +40,13 @@ module HTTPX
37
40
 
38
41
  def build_altsvc_connection: (Connection existing_connection, Array[Connection] connections, URI::Generic alt_origin, String origin, Hash[String, String] alt_params, Options options) -> (Connection & AltSvc::ConnectionMixin)?
39
42
 
40
- def build_requests: (verb, uri, options) -> Array[Request]
41
- | (Array[[verb, uri, options]], options) -> Array[Request]
42
- | (Array[[verb, uri]], options) -> Array[Request]
43
- | (verb, _Each[[uri, options]], Options) -> Array[Request]
44
- | (verb, _Each[uri], options) -> Array[Request]
43
+ def build_requests: (verb, uri, request_params) -> Array[Request]
44
+ | (Array[[verb, uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
45
+ | (Array[[verb, uri]], request_params) -> Array[Request]
46
+ | (verb, _Each[[uri, request_params]], Hash[Symbol, untyped]) -> Array[Request]
47
+ | (verb, _Each[uri], request_params) -> Array[Request]
45
48
 
46
- def init_connection: (URI::HTTP | URI::HTTP uri, Options options) -> Connection
49
+ def init_connection: (http_uri uri, Options options) -> Connection
47
50
 
48
51
  def send_requests: (*Request) -> Array[response]
49
52
 
@@ -21,8 +21,8 @@ module HTTPX
21
21
  @part_index: Integer
22
22
  @buffer: String
23
23
 
24
- @form: Enumerable[[Symbol | string, multipart_nested_value]]
25
- @parts: Array[_Reader]
24
+ @form: Enumerable[[Symbol | string, Object & multipart_nested_value]]
25
+ @parts: Array[Object & _Reader]
26
26
 
27
27
  def bytesize: () -> Integer
28
28
 
@@ -40,13 +40,18 @@ module HTTPX
40
40
 
41
41
  def header_part: (string key, String content_type, String? filename) -> StringIO
42
42
 
43
- def read_chunks: (String buffer, ?Integer? length) -> void
43
+ def read_chunks: (String buffer, ?int? length) -> void
44
44
 
45
- def read_from_part: (?Integer? max_length) -> String?
45
+ def read_from_part: (?int? max_length) -> String?
46
46
  end
47
47
 
48
48
  class Decoder
49
+ CRLF: String
49
50
  BOUNDARY_RE: Regexp
51
+ MULTIPART_CONTENT_TYPE: Regexp
52
+ MULTIPART_CONTENT_DISPOSITION: Regexp
53
+ MULTIPART_CONTENT_ID: Regexp
54
+ WINDOW_SIZE: Integer
50
55
 
51
56
  @state: :idle | :part_header | :part_body | :parse_boundary | :done
52
57
  @buffer: String
@@ -75,8 +80,8 @@ module HTTPX
75
80
  end
76
81
 
77
82
  module Part
78
- def self?.call: [U] (_MultipartInput multipart_input) -> [U, String, String]
79
- | (multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
83
+ def self?.call: [U] (Object & _MultipartInput multipart_input) -> [U, String, String]
84
+ | (Object & multipart_nested_value input) -> ([StringIO, String, String?] | [File, String, String])
80
85
  end
81
86
 
82
87
  module MimeTypeDetector
@@ -1,5 +1,6 @@
1
1
  module HTTPX::Transcoder
2
2
  module Xml
3
+ MIME_TYPES: Regexp
3
4
 
4
5
  def self?.encode: (untyped xml) -> Encoder
5
6
  def self?.decode: (HTTPX::Response response) -> _Decoder
data/sig/utils.rbs CHANGED
@@ -1,5 +1,9 @@
1
1
  module HTTPX
2
2
  module Utils
3
+ TOKEN: Regexp
4
+ VALUE: Regexp
5
+ FILENAME_REGEX: Regexp
6
+ FILENAME_EXTENSION_REGEX: Regexp
3
7
  URIParser: URI::RFC2396_Parser
4
8
 
5
9
  def self?.parse_retry_after: (String) -> Numeric
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: httpx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.3.0
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-05-14 00:00:00.000000000 Z
11
+ date: 2024-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: http-2-next
14
+ name: http-2
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 1.0.3
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 1.0.3
26
+ version: 1.0.0
27
27
  description: A client library for making HTTP requests from Ruby.
28
28
  email:
29
29
  - cardoso_tiago@hotmail.com
@@ -143,6 +143,8 @@ extra_rdoc_files:
143
143
  - doc/release_notes/1_2_3.md
144
144
  - doc/release_notes/1_2_4.md
145
145
  - doc/release_notes/1_2_5.md
146
+ - doc/release_notes/1_2_6.md
147
+ - doc/release_notes/1_3_0.md
146
148
  files:
147
149
  - LICENSE.txt
148
150
  - README.md
@@ -257,6 +259,8 @@ files:
257
259
  - doc/release_notes/1_2_3.md
258
260
  - doc/release_notes/1_2_4.md
259
261
  - doc/release_notes/1_2_5.md
262
+ - doc/release_notes/1_2_6.md
263
+ - doc/release_notes/1_3_0.md
260
264
  - lib/httpx.rb
261
265
  - lib/httpx/adapters/datadog.rb
262
266
  - lib/httpx/adapters/faraday.rb
@@ -473,7 +477,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
473
477
  - !ruby/object:Gem::Version
474
478
  version: '0'
475
479
  requirements: []
476
- rubygems_version: 3.4.10
480
+ rubygems_version: 3.5.3
477
481
  signing_key:
478
482
  specification_version: 4
479
483
  summary: HTTPX, to the future, and beyond