httpx 0.10.0 → 0.11.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -3
  3. data/doc/release_notes/0_10_1.md +37 -0
  4. data/doc/release_notes/0_10_2.md +5 -0
  5. data/doc/release_notes/0_11_0.md +76 -0
  6. data/doc/release_notes/0_11_1.md +1 -0
  7. data/doc/release_notes/0_11_2.md +5 -0
  8. data/lib/httpx/adapters/datadog.rb +205 -0
  9. data/lib/httpx/adapters/faraday.rb +0 -2
  10. data/lib/httpx/adapters/webmock.rb +123 -0
  11. data/lib/httpx/chainable.rb +8 -7
  12. data/lib/httpx/connection.rb +4 -15
  13. data/lib/httpx/connection/http1.rb +14 -1
  14. data/lib/httpx/connection/http2.rb +15 -16
  15. data/lib/httpx/domain_name.rb +1 -3
  16. data/lib/httpx/errors.rb +3 -1
  17. data/lib/httpx/headers.rb +1 -0
  18. data/lib/httpx/io/ssl.rb +4 -8
  19. data/lib/httpx/io/udp.rb +4 -3
  20. data/lib/httpx/plugins/compression.rb +1 -1
  21. data/lib/httpx/plugins/cookies/set_cookie_parser.rb +1 -1
  22. data/lib/httpx/plugins/expect.rb +33 -8
  23. data/lib/httpx/plugins/multipart.rb +42 -23
  24. data/lib/httpx/plugins/multipart/encoder.rb +115 -0
  25. data/lib/httpx/plugins/multipart/mime_type_detector.rb +64 -0
  26. data/lib/httpx/plugins/multipart/part.rb +34 -0
  27. data/lib/httpx/plugins/proxy.rb +16 -2
  28. data/lib/httpx/plugins/proxy/socks4.rb +14 -16
  29. data/lib/httpx/plugins/proxy/socks5.rb +3 -2
  30. data/lib/httpx/plugins/push_promise.rb +2 -2
  31. data/lib/httpx/pool.rb +8 -14
  32. data/lib/httpx/request.rb +22 -12
  33. data/lib/httpx/resolver.rb +7 -6
  34. data/lib/httpx/resolver/https.rb +18 -23
  35. data/lib/httpx/resolver/native.rb +22 -19
  36. data/lib/httpx/resolver/resolver_mixin.rb +4 -2
  37. data/lib/httpx/resolver/system.rb +3 -3
  38. data/lib/httpx/selector.rb +9 -13
  39. data/lib/httpx/session.rb +24 -21
  40. data/lib/httpx/transcoder.rb +20 -0
  41. data/lib/httpx/transcoder/form.rb +9 -1
  42. data/lib/httpx/version.rb +1 -1
  43. data/sig/connection.rbs +84 -1
  44. data/sig/connection/http1.rbs +66 -0
  45. data/sig/connection/http2.rbs +73 -0
  46. data/sig/headers.rbs +3 -0
  47. data/sig/httpx.rbs +1 -0
  48. data/sig/options.rbs +3 -3
  49. data/sig/plugins/basic_authentication.rbs +1 -1
  50. data/sig/plugins/compression.rbs +1 -1
  51. data/sig/plugins/compression/brotli.rbs +1 -1
  52. data/sig/plugins/compression/deflate.rbs +1 -1
  53. data/sig/plugins/compression/gzip.rbs +1 -1
  54. data/sig/plugins/h2c.rbs +1 -1
  55. data/sig/plugins/multipart.rbs +29 -4
  56. data/sig/plugins/persistent.rbs +1 -1
  57. data/sig/plugins/proxy.rbs +2 -2
  58. data/sig/plugins/proxy/ssh.rbs +1 -1
  59. data/sig/plugins/rate_limiter.rbs +1 -1
  60. data/sig/pool.rbs +36 -2
  61. data/sig/request.rbs +2 -2
  62. data/sig/resolver.rbs +26 -0
  63. data/sig/resolver/https.rbs +51 -0
  64. data/sig/resolver/native.rbs +60 -0
  65. data/sig/resolver/resolver_mixin.rbs +27 -0
  66. data/sig/resolver/system.rbs +17 -0
  67. data/sig/response.rbs +2 -2
  68. data/sig/selector.rbs +20 -0
  69. data/sig/session.rbs +3 -3
  70. data/sig/transcoder.rbs +4 -2
  71. data/sig/transcoder/body.rbs +2 -0
  72. data/sig/transcoder/form.rbs +8 -2
  73. data/sig/transcoder/json.rbs +3 -1
  74. metadata +47 -48
  75. data/lib/httpx/resolver/options.rb +0 -25
  76. data/sig/missing.rbs +0 -12
  77. data/sig/test.rbs +0 -9
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.10.0"
4
+ VERSION = "0.11.2"
5
5
  end
data/sig/connection.rbs CHANGED
@@ -1,2 +1,85 @@
1
- class HTTPX::Connection
1
+ module HTTPX
2
+ class Connection
3
+ interface _Parser
4
+
5
+ def on: (Symbol) { (*untyped) -> void } -> void
6
+ def empty?: () -> bool
7
+ def close: () -> void
8
+ def consume: () -> void
9
+ def <<: (string) -> void
10
+ end
11
+
12
+ include Loggable
13
+ include Callbacks
14
+ extend HTTPX::Registry[String, Class]
15
+
16
+ attr_reader origin: generic_uri
17
+ attr_reader state: Symbol
18
+ attr_reader pending: Array[Request]
19
+ attr_reader options: options
20
+
21
+ def addresses: () -> Array[ipaddr]?
22
+
23
+ def addresses=: (Array[ipaddr]) -> void
24
+
25
+ def match?: (generic_uri, options) -> bool
26
+
27
+ def mergeable?: (Connection) -> bool
28
+
29
+ def coalescable?: (Connection) -> bool
30
+
31
+ def create_idle: (options) -> Connection
32
+ | () -> Connection
33
+
34
+ def merge: (Connection) -> void
35
+
36
+ def purge_pending: () { (Request) -> void } -> void
37
+
38
+ def match_altsvcs?: (generic_uri) -> bool
39
+
40
+ def connecting?: () -> bool
41
+ def inflight?: () -> boolish
42
+
43
+ def interests: () -> io_interests?
44
+
45
+ def to_io: () -> _ToIO
46
+
47
+ def call: () -> void
48
+
49
+ def close: () -> void
50
+ def reset: () -> void
51
+
52
+ def send: (Request) -> void
53
+
54
+ def timeout: () -> Numeric?
55
+
56
+ private
57
+
58
+ def initialize: (String, generic_uri, options) -> untyped
59
+
60
+ def connect: () -> void
61
+
62
+ def exhausted?: () -> boolish
63
+
64
+ def consume: () -> void
65
+
66
+ def send_pending: () -> void
67
+
68
+ def parser: () -> _Parser
69
+
70
+ def build_parser: () -> _Parser
71
+ | (String) -> _Parser
72
+
73
+ def set_parser_callbacks: (_Parser) -> void
74
+
75
+ def transition: (Symbol) -> void
76
+
77
+ def handle_response: () -> void
78
+
79
+ def on_error: (StandardError) -> void
80
+
81
+ def handle_error: (StandardError) -> void
82
+
83
+ def total_timeout: () -> Timers::Timer?
84
+ end
2
85
  end
@@ -0,0 +1,66 @@
1
+ module HTTPX
2
+ class Connection::HTTP1
3
+ include Callbacks
4
+ include Loggable
5
+
6
+ attr_reader pending: Array[Request]
7
+
8
+ @options: Options
9
+ @max_concurrent_requests: Integer
10
+ @max_requests: Integer
11
+ @parser: HTTP1
12
+ @buffer: Buffer
13
+
14
+ def interests: () -> io_interests?
15
+
16
+ def reset: () -> void
17
+
18
+ def close: () -> void
19
+
20
+ def empty?: () -> bool
21
+
22
+ def exhausted?: () -> bool
23
+
24
+ def <<: (String) -> void
25
+
26
+ def send: (Request) -> void
27
+
28
+ def consume: () -> void
29
+
30
+ def handle_error: (StandardError ex) -> void
31
+
32
+ def on_headers: (Hash[String, Array[String]] headers) -> void
33
+
34
+ def on_trailers: (Array[String, String] headers) -> void
35
+
36
+ def on_data: (string chunk) -> void
37
+
38
+ def on_complete: () -> void
39
+
40
+ def dispatch: () -> void
41
+
42
+ def ping: () -> void
43
+
44
+ private
45
+
46
+ def initialize: (Buffer, options) -> untyped
47
+
48
+ def manage_connection: (Response) -> void
49
+
50
+ def disable: () -> void
51
+
52
+ def disable_pipelining: () -> void
53
+
54
+ def set_request_headers: (Request) -> void
55
+
56
+ def headline_uri: (Request) -> String
57
+
58
+ def handle: (Request request) -> void
59
+
60
+ def join_headers: (Request request) -> void
61
+
62
+ def join_body: (Request request) -> void
63
+
64
+ def capitalized: (String field) -> String
65
+ end
66
+ end
@@ -1,4 +1,77 @@
1
1
  module HTTPX
2
2
  class Connection::HTTP2
3
+ include Callbacks
4
+ include Loggable
5
+
6
+ attr_reader streams: Hash[HTTP2Next::Stream, Response]
7
+ attr_reader pending: Array[Request]
8
+
9
+ @options: Options
10
+ @max_concurrent_requests: Integer
11
+ @max_requests: Integer
12
+ @drains: Hash[Request, String]
13
+ @pings: Array[String]
14
+ @buffer: Buffer
15
+
16
+ def interests: () -> io_interests
17
+
18
+ def close: () -> void
19
+
20
+ def empty?: () -> bool
21
+
22
+ def exhausted?: () -> bool
23
+
24
+ def <<: (String) -> void
25
+
26
+ def send: (Request) -> void
27
+
28
+ def consume: () -> void
29
+
30
+ def handle_error: (StandardError ex) -> void
31
+
32
+ def ping: () -> void
33
+
34
+ alias reset init_connection
35
+
36
+ private
37
+
38
+ def initialize: (Buffer, options) -> untyped
39
+
40
+ def send_pending: () -> void
41
+
42
+ def headline_uri: (Request) -> String
43
+
44
+ def set_request_headers: (Request) -> void
45
+
46
+ def handle: (Request request, HTTP2Next::Stream stream) -> void
47
+
48
+ def init_connection: () -> void
49
+
50
+ def handle_stream: (HTTP2Next::Stream stream, Request request) -> void
51
+
52
+ def join_headers: (HTTP2Next::Stream stream, Request request) -> void
53
+
54
+ def join_body: (HTTP2Next::Stream stream, Request request) -> void
55
+
56
+ def on_stream_headers: (HTTP2Next::Stream stream, Request request, Array[[String, String]] headers) -> void
57
+
58
+ def on_stream_data: (HTTP2Next::Stream stream, Request request, string data) -> void
59
+
60
+ def on_stream_close: (HTTP2Next::Stream stream, Request request, Symbol? error) -> void
61
+
62
+ def on_frame: (string bytes) -> void
63
+
64
+ def on_settings: (*untyped) -> void
65
+
66
+ def on_close: (Integer last_frame, Symbol? error, String? payload) -> void
67
+
68
+ def on_frame_sent: (HTTP2Next::frame) -> void
69
+ def on_frame_received: (HTTP2Next::frame) -> void
70
+
71
+ def on_promise: (HTTP2Next::Stream) -> void
72
+
73
+ def on_origin: (String) -> void
74
+
75
+ def on_pong: (string ping) -> void
3
76
  end
4
77
  end
data/sig/headers.rbs CHANGED
@@ -25,6 +25,9 @@ module HTTPX
25
25
  def same_headers?: (untyped headers) -> bool
26
26
 
27
27
  def to_a: () -> Array[[headers_key, String]]
28
+ def to_hash: () -> Hash[headers_key, String]
29
+ alias to_h to_hash
30
+
28
31
  def inspect: () -> String
29
32
 
30
33
  private
data/sig/httpx.rbs CHANGED
@@ -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 |
data/sig/options.rbs CHANGED
@@ -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
data/sig/plugins/h2c.rbs CHANGED
@@ -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,18 +1,43 @@
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
- def self?.encode: (untyped) -> Encoder
6
+ def self?.encode: (untyped) -> (Encoder | Transcoder::Form::Encoder)
7
+
8
+ type multipart_value = string | Pathname | File | _Reader
9
+
10
+ type record_multipart_value = multipart_value |
11
+ { content_type: String, filename: String, body: multipart_value } |
12
+ { content_type: String, body: multipart_value }
13
+
14
+ type multipart_nested_value = multipart_value | _ToAry[multipart_value] | _ToHash[string, multipart_value]
15
+
16
+ type multipart_input = Enumerable[[string, multipart_value], untyped]
7
17
 
8
18
  class Encoder
9
19
  include Transcoder::_Encoder
10
- include _ToS
11
20
  include _Reader
12
21
 
22
+ def content_type: () -> String
23
+
13
24
  private
14
25
 
15
- def initalize: (Hash[Symbol | string, HTTP::FormData::Part | string] multipart_data) -> untyped
26
+ def initialize: (Hash[Symbol | string, multipart_nested_value] multipart_data) -> untyped
27
+
28
+ def header_part: (string key, String content_type, String? filename) -> StringIO
29
+
30
+ def read_chunks: (String buffer, Integer? length) -> void
31
+
32
+ def read_from_part: (Integer? max_length) -> void
33
+ end
34
+
35
+ module Part
36
+ def self?.call: (multipart_nested_value) -> ([_Reader, String, String?] | [_Reader, String])
37
+ end
38
+
39
+ module MimeTypeDetector
40
+ def self?.call: (IO file, ?String filename) -> String?
16
41
  end
17
42
  end
18
43
  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
 
data/sig/pool.rbs CHANGED
@@ -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