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/sig/request.rbs CHANGED
@@ -37,7 +37,7 @@ module HTTPX
37
37
 
38
38
  def transition: (Symbol) -> void
39
39
 
40
- def expects?: () -> bool
40
+ def expects?: () -> boolish
41
41
 
42
42
  class Body
43
43
  def initialize: (Headers, Options) -> untyped
@@ -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
data/sig/resolver.rbs ADDED
@@ -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,51 @@
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 on_response: (Request, response) -> void
43
+
44
+ def response: (Response) -> void
45
+
46
+ def build_request: (String hostname, "A" | "AAAA") -> Request
47
+
48
+ def decode_response_body: (Response) -> Array[dns_result]
49
+ end
50
+ end
51
+ 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
data/sig/response.rbs CHANGED
@@ -27,7 +27,7 @@ module HTTPX
27
27
 
28
28
  private
29
29
 
30
- def initialize: (Request, _ToS, String, headers) -> untyped
30
+ def initialize: (Request, _ToS, String, headers?) -> untyped
31
31
  def no_data?: () -> bool
32
32
 
33
33
  class Body
@@ -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
data/sig/selector.rbs ADDED
@@ -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
data/sig/session.rbs CHANGED
@@ -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
 
@@ -29,7 +29,7 @@ module HTTPX
29
29
  | (?options?) -> untyped
30
30
 
31
31
  def pool: -> Pool
32
- # def on_response: (Request, response) -> void
32
+ def on_response: (Request, response) -> void
33
33
  def on_promise: (untyped, untyped) -> void
34
34
  def fetch_response: (Request, *untyped) -> response?
35
35
  def set_connection_callbacks: (Connection, Array[Connection], Options) -> void
data/sig/transcoder.rbs CHANGED
@@ -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, ?Proc?) { (string, top) -> void } -> void
8
+ | (string | Symbol, top, ?Proc?) { (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
@@ -7,6 +7,8 @@ module HTTPX
7
7
 
8
8
  @raw: bodyIO
9
9
 
10
+ def content_type: () -> String
11
+
10
12
  private
11
13
 
12
14
  def initialize: (untyped body ) -> untyped
@@ -1,5 +1,9 @@
1
1
  module HTTPX::Transcoder
2
- type urlencoded_input = Enumerable[[string, string], untyped]
2
+ type form_value = string
3
+
4
+ type form_nested_value = form_value | _ToAry[form_value] | _ToHash[string, form_value]
5
+
6
+ type urlencoded_input = Enumerable[[string, form_nested_value], untyped]
3
7
 
4
8
  module Form
5
9
  def self?.encode: (urlencoded_input form) -> Encoder
@@ -8,9 +12,11 @@ module HTTPX::Transcoder
8
12
  include _Encoder
9
13
  include _ToS
10
14
 
15
+ def content_type: () -> String
16
+
11
17
  private
12
18
 
13
- def initalize: (urlencoded_input form) -> untyped
19
+ def initialize: (urlencoded_input form) -> untyped
14
20
  end
15
21
  end
16
22
  end
@@ -6,9 +6,11 @@ module HTTPX::Transcoder
6
6
  include _Encoder
7
7
  include _ToS
8
8
 
9
+ def content_type: () -> String
10
+
9
11
  private
10
12
 
11
- def initalize: (_ToJson json) -> untyped
13
+ def initialize: (_ToJson json) -> untyped
12
14
  end
13
15
  end
14
16
  end
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: 0.10.0
4
+ version: 0.11.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tiago Cardoso
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-25 00:00:00.000000000 Z
11
+ date: 2021-02-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -38,26 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: http-form_data
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: 2.0.0
48
- - - "<"
49
- - !ruby/object:Gem::Version
50
- version: '3'
51
- type: :development
52
- prerelease: false
53
- version_requirements: !ruby/object:Gem::Requirement
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- version: 2.0.0
58
- - - "<"
59
- - !ruby/object:Gem::Version
60
- version: '3'
61
41
  description: A client library for making HTTP requests from Ruby.
62
42
  email:
63
43
  - cardoso_tiago@hotmail.com
@@ -67,33 +47,38 @@ extra_rdoc_files:
67
47
  - LICENSE.txt
68
48
  - README.md
69
49
  - doc/release_notes/0_0_1.md
70
- - doc/release_notes/0_1_0.md
71
- - doc/release_notes/0_0_5.md
50
+ - doc/release_notes/0_0_2.md
51
+ - doc/release_notes/0_0_3.md
72
52
  - doc/release_notes/0_0_4.md
73
- - doc/release_notes/0_6_5.md
74
- - doc/release_notes/0_6_1.md
75
- - doc/release_notes/0_7_0.md
76
- - doc/release_notes/0_6_0.md
77
- - doc/release_notes/0_8_2.md
78
- - doc/release_notes/0_6_4.md
79
- - doc/release_notes/0_9_0.md
80
- - doc/release_notes/0_6_3.md
81
- - doc/release_notes/0_8_1.md
82
- - doc/release_notes/0_5_0.md
83
- - doc/release_notes/0_6_7.md
53
+ - doc/release_notes/0_0_5.md
54
+ - doc/release_notes/0_10_0.md
55
+ - doc/release_notes/0_10_1.md
56
+ - doc/release_notes/0_10_2.md
57
+ - doc/release_notes/0_11_0.md
58
+ - doc/release_notes/0_11_1.md
59
+ - doc/release_notes/0_11_2.md
60
+ - doc/release_notes/0_1_0.md
61
+ - doc/release_notes/0_2_0.md
62
+ - doc/release_notes/0_2_1.md
63
+ - doc/release_notes/0_3_0.md
64
+ - doc/release_notes/0_3_1.md
65
+ - doc/release_notes/0_4_0.md
84
66
  - doc/release_notes/0_4_1.md
67
+ - doc/release_notes/0_5_0.md
85
68
  - doc/release_notes/0_5_1.md
86
- - doc/release_notes/0_6_6.md
87
- - doc/release_notes/0_4_0.md
69
+ - doc/release_notes/0_6_0.md
70
+ - doc/release_notes/0_6_1.md
88
71
  - doc/release_notes/0_6_2.md
89
- - doc/release_notes/0_10_0.md
72
+ - doc/release_notes/0_6_3.md
73
+ - doc/release_notes/0_6_4.md
74
+ - doc/release_notes/0_6_5.md
75
+ - doc/release_notes/0_6_6.md
76
+ - doc/release_notes/0_6_7.md
77
+ - doc/release_notes/0_7_0.md
90
78
  - doc/release_notes/0_8_0.md
91
- - doc/release_notes/0_3_0.md
92
- - doc/release_notes/0_2_1.md
93
- - doc/release_notes/0_0_3.md
94
- - doc/release_notes/0_0_2.md
95
- - doc/release_notes/0_3_1.md
96
- - doc/release_notes/0_2_0.md
79
+ - doc/release_notes/0_8_1.md
80
+ - doc/release_notes/0_8_2.md
81
+ - doc/release_notes/0_9_0.md
97
82
  files:
98
83
  - LICENSE.txt
99
84
  - README.md
@@ -103,6 +88,11 @@ files:
103
88
  - doc/release_notes/0_0_4.md
104
89
  - doc/release_notes/0_0_5.md
105
90
  - doc/release_notes/0_10_0.md
91
+ - doc/release_notes/0_10_1.md
92
+ - doc/release_notes/0_10_2.md
93
+ - doc/release_notes/0_11_0.md
94
+ - doc/release_notes/0_11_1.md
95
+ - doc/release_notes/0_11_2.md
106
96
  - doc/release_notes/0_1_0.md
107
97
  - doc/release_notes/0_2_0.md
108
98
  - doc/release_notes/0_2_1.md
@@ -126,7 +116,9 @@ files:
126
116
  - doc/release_notes/0_8_2.md
127
117
  - doc/release_notes/0_9_0.md
128
118
  - lib/httpx.rb
119
+ - lib/httpx/adapters/datadog.rb
129
120
  - lib/httpx/adapters/faraday.rb
121
+ - lib/httpx/adapters/webmock.rb
130
122
  - lib/httpx/altsvc.rb
131
123
  - lib/httpx/buffer.rb
132
124
  - lib/httpx/callbacks.rb
@@ -161,6 +153,9 @@ files:
161
153
  - lib/httpx/plugins/follow_redirects.rb
162
154
  - lib/httpx/plugins/h2c.rb
163
155
  - lib/httpx/plugins/multipart.rb
156
+ - lib/httpx/plugins/multipart/encoder.rb
157
+ - lib/httpx/plugins/multipart/mime_type_detector.rb
158
+ - lib/httpx/plugins/multipart/part.rb
164
159
  - lib/httpx/plugins/persistent.rb
165
160
  - lib/httpx/plugins/proxy.rb
166
161
  - lib/httpx/plugins/proxy/http.rb
@@ -177,7 +172,6 @@ files:
177
172
  - lib/httpx/resolver.rb
178
173
  - lib/httpx/resolver/https.rb
179
174
  - lib/httpx/resolver/native.rb
180
- - lib/httpx/resolver/options.rb
181
175
  - lib/httpx/resolver/resolver_mixin.rb
182
176
  - lib/httpx/resolver/system.rb
183
177
  - lib/httpx/response.rb
@@ -195,13 +189,13 @@ files:
195
189
  - sig/callbacks.rbs
196
190
  - sig/chainable.rbs
197
191
  - sig/connection.rbs
192
+ - sig/connection/http1.rbs
198
193
  - sig/connection/http2.rbs
199
194
  - sig/domain_name.rbs
200
195
  - sig/errors.rbs
201
196
  - sig/headers.rbs
202
197
  - sig/httpx.rbs
203
198
  - sig/loggable.rbs
204
- - sig/missing.rbs
205
199
  - sig/options.rbs
206
200
  - sig/parser/http1.rbs
207
201
  - sig/plugins/authentication.rbs
@@ -231,9 +225,14 @@ files:
231
225
  - sig/pool.rbs
232
226
  - sig/registry.rbs
233
227
  - sig/request.rbs
228
+ - sig/resolver.rbs
229
+ - sig/resolver/https.rbs
230
+ - sig/resolver/native.rbs
231
+ - sig/resolver/resolver_mixin.rbs
232
+ - sig/resolver/system.rbs
234
233
  - sig/response.rbs
234
+ - sig/selector.rbs
235
235
  - sig/session.rbs
236
- - sig/test.rbs
237
236
  - sig/timeout.rbs
238
237
  - sig/transcoder.rbs
239
238
  - sig/transcoder/body.rbs
@@ -263,7 +262,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
263
262
  - !ruby/object:Gem::Version
264
263
  version: '0'
265
264
  requirements: []
266
- rubygems_version: 3.1.4
265
+ rubygems_version: 3.2.3
267
266
  signing_key:
268
267
  specification_version: 4
269
268
  summary: HTTPX, to the future, and beyond