httpx 0.10.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/doc/release_notes/0_10_1.md +39 -0
  3. data/lib/httpx/chainable.rb +7 -6
  4. data/lib/httpx/connection.rb +4 -15
  5. data/lib/httpx/connection/http1.rb +14 -1
  6. data/lib/httpx/connection/http2.rb +11 -12
  7. data/lib/httpx/errors.rb +1 -1
  8. data/lib/httpx/plugins/multipart.rb +15 -1
  9. data/lib/httpx/plugins/proxy.rb +16 -2
  10. data/lib/httpx/plugins/proxy/socks4.rb +14 -16
  11. data/lib/httpx/pool.rb +8 -14
  12. data/lib/httpx/request.rb +1 -1
  13. data/lib/httpx/resolver.rb +0 -2
  14. data/lib/httpx/resolver/https.rb +15 -22
  15. data/lib/httpx/resolver/native.rb +12 -13
  16. data/lib/httpx/resolver/resolver_mixin.rb +4 -2
  17. data/lib/httpx/resolver/system.rb +2 -2
  18. data/lib/httpx/selector.rb +8 -13
  19. data/lib/httpx/session.rb +9 -3
  20. data/lib/httpx/transcoder.rb +18 -0
  21. data/lib/httpx/transcoder/form.rb +9 -1
  22. data/lib/httpx/version.rb +1 -1
  23. data/sig/connection.rbs +84 -1
  24. data/sig/connection/http1.rbs +66 -0
  25. data/sig/connection/http2.rbs +74 -0
  26. data/sig/httpx.rbs +1 -0
  27. data/sig/options.rbs +3 -3
  28. data/sig/plugins/basic_authentication.rbs +1 -1
  29. data/sig/plugins/compression.rbs +1 -1
  30. data/sig/plugins/compression/brotli.rbs +1 -1
  31. data/sig/plugins/compression/deflate.rbs +1 -1
  32. data/sig/plugins/compression/gzip.rbs +1 -1
  33. data/sig/plugins/h2c.rbs +1 -1
  34. data/sig/plugins/multipart.rbs +4 -2
  35. data/sig/plugins/persistent.rbs +1 -1
  36. data/sig/plugins/proxy.rbs +2 -2
  37. data/sig/plugins/proxy/ssh.rbs +1 -1
  38. data/sig/plugins/rate_limiter.rbs +1 -1
  39. data/sig/pool.rbs +36 -2
  40. data/sig/request.rbs +1 -1
  41. data/sig/resolver.rbs +26 -0
  42. data/sig/resolver/https.rbs +49 -0
  43. data/sig/resolver/native.rbs +60 -0
  44. data/sig/resolver/resolver_mixin.rbs +27 -0
  45. data/sig/resolver/system.rbs +17 -0
  46. data/sig/response.rbs +1 -1
  47. data/sig/selector.rbs +20 -0
  48. data/sig/session.rbs +2 -2
  49. data/sig/transcoder.rbs +4 -2
  50. data/sig/transcoder/form.rbs +1 -1
  51. metadata +11 -4
  52. data/lib/httpx/resolver/options.rb +0 -25
  53. data/sig/test.rbs +0 -9
@@ -4,6 +4,7 @@ module HTTPX
4
4
  VERSION: String
5
5
 
6
6
  type uri = URI::HTTP | URI::HTTPS | string
7
+ type generic_uri = uri | URI::Generic
7
8
 
8
9
  type verb = :options | :get | :head | :post | :put | :delete | :trace | :connect |
9
10
  :propfind | :proppatch | :mkcol | :copy | :move | :lock | :unlock | :orderpatch |
@@ -77,9 +77,9 @@ module HTTPX
77
77
  # resolver_class resolver_options
78
78
 
79
79
  # request_class
80
- # attr_reader request_class: singleton(Request)
81
- # def request_class=: (singleton(Request)) -> void
82
- # def with_request_class: (singleton(Request)) -> instance
80
+ attr_reader request_class: singleton(Request)
81
+ def request_class=: (singleton(Request)) -> void
82
+ def with_request_class: (singleton(Request)) -> instance
83
83
 
84
84
  # io
85
85
  attr_reader io: _ToIO?
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module BasicAuthentication
4
- # def self.load_dependencies: (singleton(Session)) -> void
4
+ def self.load_dependencies: (singleton(Session)) -> void
5
5
 
6
6
  module InstanceMethods
7
7
  def basic_authentication: (string user, string password) -> instance
@@ -16,7 +16,7 @@ module HTTPX
16
16
  def initialize: (Numeric bytesize) -> untyped
17
17
  end
18
18
 
19
- # def self.load_dependencies: (singleton(Session)) -> void
19
+ def self.load_dependencies: (singleton(Session)) -> void
20
20
 
21
21
  interface _CompressionOptions
22
22
  def compression_threshold_size: () -> _Integer?
@@ -2,7 +2,7 @@ module HTTPX
2
2
  module Plugins
3
3
  module Compression
4
4
  module Brotli
5
- # def self.load_dependencies: (singleton(Session)) -> void
5
+ def self.load_dependencies: (singleton(Session)) -> void
6
6
  def self.configure: (*untyped) -> void
7
7
 
8
8
  def self?.deflater: () -> _Deflater
@@ -2,7 +2,7 @@ module HTTPX
2
2
  module Plugins
3
3
  module Compression
4
4
  module Deflate
5
- # def self.load_dependencies: (singleton(Session)) -> void
5
+ def self.load_dependencies: (singleton(Session)) -> void
6
6
  def self.configure: (*untyped) -> void
7
7
 
8
8
  def self?.deflater: () -> _Deflater
@@ -2,7 +2,7 @@ module HTTPX
2
2
  module Plugins
3
3
  module Compression
4
4
  module GZIP
5
- # def self.load_dependencies: (singleton(Session)) -> void
5
+ def self.load_dependencies: (singleton(Session)) -> void
6
6
  def self.configure: (*untyped) -> void
7
7
 
8
8
  def self?.deflater: () -> _Deflater
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module H2C
4
- # def self.load_dependencies: (singleton(Session)) -> void
4
+ def self.load_dependencies: (singleton(Session)) -> void
5
5
 
6
6
  module InstanceMethods
7
7
  VALID_H2C_METHODS: Array[Symbol]
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Multipart
4
- # def self.load_dependencies: (singleton(Session)) -> void
4
+ def self.load_dependencies: (singleton(Session)) -> void
5
5
  def self.configure: (*untyped) -> void
6
6
  def self?.encode: (untyped) -> Encoder
7
7
 
@@ -12,7 +12,9 @@ module HTTPX
12
12
 
13
13
  private
14
14
 
15
- def initalize: (Hash[Symbol | string, HTTP::FormData::Part | string] multipart_data) -> untyped
15
+ def initialize: (Hash[Symbol | string, HTTP::FormData::Part | string] multipart_data) -> untyped
16
+
17
+ def multipart?: (top) -> bool
16
18
  end
17
19
  end
18
20
  end
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module Persistent
4
- # def self.load_dependencies: (singleton(Session)) -> void
4
+ def self.load_dependencies: (singleton(Session)) -> void
5
5
 
6
6
  interface _PersistentOptions
7
7
  def persistent: () -> bool?
@@ -18,10 +18,10 @@ module HTTPX
18
18
 
19
19
  private
20
20
 
21
- def initialize: (uri: uri, ?username: string, ?password: string) -> untyped
21
+ def initialize: (uri: generic_uri, ?username: string, ?password: string) -> untyped
22
22
  end
23
23
 
24
- # def self.configure: (singleton(Session)) -> void
24
+ def self.configure: (singleton(Session)) -> void
25
25
 
26
26
  type proxyParam = Parameters | Hash
27
27
 
@@ -2,7 +2,7 @@ module HTTPX
2
2
  module Plugins
3
3
  module Proxy
4
4
  module SSH
5
- # def self.load_dependencies: (singleton(Session)) -> void
5
+ def self.load_dependencies: (singleton(Session)) -> void
6
6
 
7
7
  module InstancenMethods
8
8
  private
@@ -1,7 +1,7 @@
1
1
  module HTTPX
2
2
  module Plugins
3
3
  module RateLimiter
4
- # def self.load_dependencies: (singleton(Session)) -> void
4
+ def self.load_dependencies: (singleton(Session)) -> void
5
5
 
6
6
  def self.retry_on_rate_limited_response: (_Response) -> bool
7
7
 
@@ -1,2 +1,36 @@
1
- class HTTPX::Pool
2
- end
1
+ module HTTPX
2
+ class Pool
3
+ def empty?: () -> void
4
+
5
+ def next_tick: () -> void
6
+
7
+ def close: (Array[Connection]) -> void
8
+ | () -> void
9
+
10
+ def init_connection: (Connection, Options) -> void
11
+
12
+ def find_connection: (generic_uri, Options) -> Connection?
13
+
14
+ private
15
+
16
+ def initialize: () -> untyped
17
+
18
+ def resolve_connection: (Connection) -> void
19
+
20
+ def on_resolver_connection: (Connection) -> void
21
+
22
+ def on_resolver_error: (Connection, StandardError) -> void
23
+
24
+ def on_resolver_close: (resolver) -> void
25
+
26
+ def register_connection: (Connection) -> void
27
+
28
+ def unregister_connection: (Connection) -> void
29
+
30
+ def coalesce_connections: (Connection, Connection) -> void
31
+
32
+ def next_timeout: () -> Numeric?
33
+
34
+ def find_resolver_for: (Connection) -> resolver
35
+ end
36
+ end
@@ -45,7 +45,7 @@ module HTTPX
45
45
  | () -> Enumerable[String]
46
46
 
47
47
  def empty?: () -> bool
48
- def bytesize: () -> Integer
48
+ def bytesize: () -> Numeric
49
49
  def stream: (Transcoder::_Encoder) -> bodyIO
50
50
  def unbounded_body?: () -> bool
51
51
  def chunked?: () -> bool
@@ -0,0 +1,26 @@
1
+ module HTTPX
2
+ type ipaddr = IPAddr | String
3
+
4
+ type resolver = Resolver::System | Resolver::Native | Resolver::HTTPS
5
+
6
+ module Resolver
7
+ type dns_resource = singleton(Resolv::DNS::Resource)
8
+
9
+ type dns_result = { "name" => String, "TTL" => Numeric, "alias" => String }
10
+ | { "name" => String, "TTL" => Numeric, "data" => String }
11
+
12
+ def self?.cached_lookup: (String hostname) -> Array[String]?
13
+
14
+ def self?.cached_lookup_set: (String hostname, Array[dns_result] addresses) -> void
15
+
16
+ def self?.uncache: (String hostname) -> void
17
+
18
+ def self?.lookup: (String hostname, Numeric ttl) -> Array[String]?
19
+
20
+ def self?.generate_id: () -> Integer
21
+
22
+ def self?.encode_dns_query: (String hostname, ?type: dns_resource) -> String
23
+
24
+ def self?.decode_dns_answer: (String) -> Array[dns_result]
25
+ end
26
+ end
@@ -0,0 +1,49 @@
1
+ module HTTPX
2
+ module Resolver
3
+ class HTTPS
4
+ include ResolverMixin
5
+ include _ToIO
6
+
7
+ @options: Options
8
+ @resolver_options: Hash[Symbol, untyped]
9
+ @_record_types: Hash[String, Hash["A" | "AAAA", dns_resource]]
10
+ @queries: Hash[String, Connection]
11
+ @requests: Hash[Request, Connection]
12
+ @connections: Array[Connection]
13
+ @uri: URI::HTTPS
14
+ @uri_addresses: Array[String]?
15
+
16
+ def <<: (Connection) -> void
17
+
18
+ def timeout: () -> Numeric?
19
+
20
+ def closed?: () -> bool
21
+
22
+ def empty?: () -> bool
23
+
24
+ def close: () -> void
25
+
26
+ def call: () -> void
27
+
28
+ def interests: () -> io_interests?
29
+
30
+ private
31
+
32
+ def initialize: (options) -> untyped
33
+
34
+ def pool: () -> Pool
35
+
36
+ def resolver_connection: () -> Connection
37
+
38
+ def resolve: (Connection, String hostname) -> void
39
+ | (Connection) -> void
40
+ | () -> void
41
+
42
+ def response: (Response) -> void
43
+
44
+ def build_request: (String hostname, "A" | "AAAA") -> Request
45
+
46
+ def decode_response_body: (Response) -> Array[dns_result]
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,60 @@
1
+ module HTTPX
2
+ module Resolver
3
+ class Native
4
+ include ResolverMixin
5
+ include _ToIO
6
+
7
+ @options: Options
8
+ @ns_index: Integer
9
+ @resolver_options: Hash[Symbol, untyped]
10
+ @nameserver: String
11
+ @_timeouts: Array[Numeric]
12
+ @timeouts: Hash[String, Array[Numeric]]
13
+ @_record_types: Hash[String, Hash["A" | "AAAA", dns_resource]]
14
+ @connections: Array[Connection]
15
+ @queries: Hash[String, Connection]
16
+ @read_buffer: String
17
+ @write_buffer: Buffer
18
+ @state: :idle | :closed
19
+
20
+ def closed?: () -> bool
21
+
22
+ def empty?: () -> bool
23
+
24
+ def close: () -> void
25
+
26
+ def call: () -> void
27
+
28
+ def interests: () -> io_interests
29
+
30
+ def <<: (Connection) -> void
31
+
32
+ def timeout: () -> Numeric?
33
+
34
+ private
35
+
36
+ def initialize: (options) -> untyped
37
+
38
+ def consume: () -> void
39
+
40
+ def do_retry: () -> void
41
+
42
+ def dread: (Integer) -> void
43
+ | () -> void
44
+
45
+ def dwrite: () -> void
46
+
47
+ def parse: (String) -> void
48
+
49
+ def resolve: (Connection, String hostname) -> void
50
+ | (Connection) -> void
51
+ | () -> void
52
+
53
+ def build_socket: () -> void
54
+
55
+ def transition: (Symbol nextstate) -> void
56
+
57
+ def handle_error: (StandardError) -> void
58
+ end
59
+ end
60
+ end
@@ -0,0 +1,27 @@
1
+ module HTTPX
2
+ module Resolver
3
+ module ResolverMixin
4
+ include Callbacks
5
+ include Loggable
6
+
7
+ def uncache: (Connection) -> void
8
+
9
+ private
10
+
11
+ def emit_addresses: (Connection, Array[ipaddr]) -> void
12
+
13
+ def early_resolve: (Connection, ?hostname: String) -> void
14
+
15
+ def ip_resolve: (String hostname) -> Array[ipaddr]?
16
+
17
+ def system_resolve: (String hostname) -> Array[ipaddr]?
18
+
19
+ def emit_resolve_error: (Connection, String hostname, StandardError) -> void
20
+ | (Connection, String hostname) -> void
21
+ | (Connection) -> void
22
+
23
+ def resolve_error: (String hostname, StandardError?) -> void
24
+ | (String hostname) -> void
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,17 @@
1
+ module HTTPX
2
+ module Resolver
3
+ class System
4
+ include ResolverMixin
5
+
6
+ def closed?: () -> true
7
+
8
+ def empty?: () -> true
9
+
10
+ def <<: (Connection) -> void
11
+
12
+ private
13
+
14
+ def initialize: (options) -> untyped
15
+ end
16
+ end
17
+ end
@@ -41,7 +41,7 @@ module HTTPX
41
41
  def each: () { (String) -> void } -> void
42
42
  | () -> Enumerable[String]
43
43
 
44
- def bytesize: () -> Integer
44
+ def bytesize: () -> Numeric
45
45
  def empty?: () -> bool
46
46
  def copy_to: (_ToPath | _Writer destination) -> void
47
47
  def close: () -> void
@@ -0,0 +1,20 @@
1
+ module HTTPX
2
+ class Selector
3
+ READABLE: :r | :rw
4
+ WRITABLE: :w | :rw
5
+
6
+ def register: (_ToIO) -> void
7
+ def deregister: (_ToIO) -> void
8
+
9
+ def select: (Numeric?) { (_ToIO) -> void } -> void
10
+
11
+ private
12
+
13
+ def initialize: () -> untyped
14
+
15
+ def select_many: (Numeric?) { (_ToIO) -> void } -> void
16
+ def select_one: (Numeric?) { (_ToIO) -> void } -> void
17
+ end
18
+
19
+ type io_interests = :r | :w | :rw
20
+ end
@@ -16,8 +16,8 @@ module HTTPX
16
16
 
17
17
  def build_request: (String | verb, uri, ?options) -> Request
18
18
 
19
- # def self.plugin: | (Symbol | Module, ?options) { (Class) -> void } -> singleton(Session)
20
- # | (Symbol | Module, ?options) -> singleton(Session)
19
+ def self.plugin: (Symbol | Module, ?options) { (Class) -> void } -> singleton(Session)
20
+ | (Symbol | Module, ?options) -> singleton(Session)
21
21
 
22
22
 
23
23
 
@@ -4,9 +4,11 @@ module HTTPX
4
4
  module Transcoder
5
5
  extend HTTPX::Registry[String, Class]
6
6
 
7
+ def self.normalize_keys: (string | Symbol, top) { (string, top) -> void } -> void
8
+ | (string | Symbol, top) { (string) -> void } -> void
9
+
7
10
  interface _Encoder
8
- def bytesize: () -> Integer
9
- def content_type: () -> String
11
+ def bytesize: () -> Numeric
10
12
  end
11
13
 
12
14
  interface _Decoder
@@ -10,7 +10,7 @@ module HTTPX::Transcoder
10
10
 
11
11
  private
12
12
 
13
- def initalize: (urlencoded_input form) -> untyped
13
+ def initialize: (urlencoded_input form) -> untyped
14
14
  end
15
15
  end
16
16
  end