httpx 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +48 -0
  3. data/README.md +2 -0
  4. data/doc/release_notes/0_10_0.md +66 -0
  5. data/lib/httpx.rb +2 -0
  6. data/lib/httpx/adapters/faraday.rb +1 -1
  7. data/lib/httpx/chainable.rb +2 -2
  8. data/lib/httpx/connection.rb +3 -9
  9. data/lib/httpx/connection/http1.rb +1 -1
  10. data/lib/httpx/domain_name.rb +440 -0
  11. data/lib/httpx/errors.rb +1 -0
  12. data/lib/httpx/extensions.rb +21 -1
  13. data/lib/httpx/io/ssl.rb +0 -1
  14. data/lib/httpx/io/tcp.rb +6 -5
  15. data/lib/httpx/io/udp.rb +4 -1
  16. data/lib/httpx/options.rb +2 -0
  17. data/lib/httpx/parser/http1.rb +14 -17
  18. data/lib/httpx/plugins/compression.rb +28 -63
  19. data/lib/httpx/plugins/compression/brotli.rb +10 -14
  20. data/lib/httpx/plugins/compression/deflate.rb +7 -6
  21. data/lib/httpx/plugins/compression/gzip.rb +23 -5
  22. data/lib/httpx/plugins/cookies.rb +21 -60
  23. data/lib/httpx/plugins/cookies/cookie.rb +173 -0
  24. data/lib/httpx/plugins/cookies/jar.rb +74 -0
  25. data/lib/httpx/plugins/cookies/set_cookie_parser.rb +142 -0
  26. data/lib/httpx/plugins/expect.rb +3 -5
  27. data/lib/httpx/plugins/follow_redirects.rb +20 -2
  28. data/lib/httpx/plugins/h2c.rb +1 -1
  29. data/lib/httpx/plugins/multipart.rb +0 -8
  30. data/lib/httpx/plugins/persistent.rb +6 -1
  31. data/lib/httpx/plugins/proxy/socks4.rb +3 -1
  32. data/lib/httpx/plugins/rate_limiter.rb +51 -0
  33. data/lib/httpx/plugins/retries.rb +3 -2
  34. data/lib/httpx/plugins/stream.rb +109 -13
  35. data/lib/httpx/pool.rb +6 -6
  36. data/lib/httpx/request.rb +7 -19
  37. data/lib/httpx/resolver/https.rb +7 -2
  38. data/lib/httpx/resolver/native.rb +7 -3
  39. data/lib/httpx/response.rb +16 -23
  40. data/lib/httpx/selector.rb +2 -4
  41. data/lib/httpx/session.rb +17 -11
  42. data/lib/httpx/transcoder/chunker.rb +0 -2
  43. data/lib/httpx/transcoder/form.rb +0 -6
  44. data/lib/httpx/transcoder/json.rb +0 -4
  45. data/lib/httpx/utils.rb +45 -0
  46. data/lib/httpx/version.rb +1 -1
  47. data/sig/buffer.rbs +24 -0
  48. data/sig/callbacks.rbs +14 -0
  49. data/sig/chainable.rbs +37 -0
  50. data/sig/connection.rbs +2 -0
  51. data/sig/connection/http2.rbs +4 -0
  52. data/sig/domain_name.rbs +17 -0
  53. data/sig/errors.rbs +3 -0
  54. data/sig/headers.rbs +42 -0
  55. data/sig/httpx.rbs +14 -0
  56. data/sig/loggable.rbs +11 -0
  57. data/sig/missing.rbs +12 -0
  58. data/sig/options.rbs +118 -0
  59. data/sig/parser/http1.rbs +50 -0
  60. data/sig/plugins/authentication.rbs +11 -0
  61. data/sig/plugins/basic_authentication.rbs +13 -0
  62. data/sig/plugins/compression.rbs +55 -0
  63. data/sig/plugins/compression/brotli.rbs +21 -0
  64. data/sig/plugins/compression/deflate.rbs +17 -0
  65. data/sig/plugins/compression/gzip.rbs +29 -0
  66. data/sig/plugins/cookies.rbs +26 -0
  67. data/sig/plugins/cookies/cookie.rbs +50 -0
  68. data/sig/plugins/cookies/jar.rbs +27 -0
  69. data/sig/plugins/digest_authentication.rbs +33 -0
  70. data/sig/plugins/expect.rbs +19 -0
  71. data/sig/plugins/follow_redirects.rbs +37 -0
  72. data/sig/plugins/h2c.rbs +26 -0
  73. data/sig/plugins/multipart.rbs +19 -0
  74. data/sig/plugins/persistent.rbs +17 -0
  75. data/sig/plugins/proxy.rbs +47 -0
  76. data/sig/plugins/proxy/http.rbs +14 -0
  77. data/sig/plugins/proxy/socks4.rbs +33 -0
  78. data/sig/plugins/proxy/socks5.rbs +36 -0
  79. data/sig/plugins/proxy/ssh.rbs +18 -0
  80. data/sig/plugins/push_promise.rbs +22 -0
  81. data/sig/plugins/rate_limiter.rbs +11 -0
  82. data/sig/plugins/retries.rbs +48 -0
  83. data/sig/plugins/stream.rbs +39 -0
  84. data/sig/pool.rbs +2 -0
  85. data/sig/registry.rbs +9 -0
  86. data/sig/request.rbs +61 -0
  87. data/sig/response.rbs +87 -0
  88. data/sig/session.rbs +49 -0
  89. data/sig/test.rbs +9 -0
  90. data/sig/timeout.rbs +29 -0
  91. data/sig/transcoder.rbs +16 -0
  92. data/sig/transcoder/body.rbs +18 -0
  93. data/sig/transcoder/chunker.rbs +32 -0
  94. data/sig/transcoder/form.rbs +16 -0
  95. data/sig/transcoder/json.rbs +14 -0
  96. metadata +60 -17
@@ -0,0 +1,61 @@
1
+ module HTTPX
2
+ class Request
3
+ include Callbacks
4
+
5
+ METHODS: Array[verb]
6
+ USER_AGENT: String
7
+
8
+ attr_reader verb: verb
9
+ attr_reader uri: URI::HTTP | URI::HTTPS
10
+ attr_reader headers: Headers
11
+ attr_reader body: Body
12
+ attr_reader state: Symbol
13
+ attr_reader options: Options
14
+ attr_reader response: Response?
15
+
16
+ def initialize: (verb | String, uri, ?options?) -> untyped
17
+
18
+ def interests: () -> (:r | :w)
19
+
20
+ def merge_headers: (Headers | Hash) -> void
21
+
22
+ def scheme: () -> ("http" | "https")
23
+
24
+ def response=: (Response response) -> void
25
+
26
+ def path: () -> String
27
+
28
+ def authority: () -> String
29
+
30
+ def origin: () -> String
31
+
32
+ def query: () -> String
33
+
34
+ def drain_body: () -> String?
35
+
36
+ def inspect: () -> String
37
+
38
+ def transition: (Symbol) -> void
39
+
40
+ def expects?: () -> bool
41
+
42
+ class Body
43
+ def initialize: (Headers, Options) -> untyped
44
+ def each: () { (String) -> void } -> void
45
+ | () -> Enumerable[String]
46
+
47
+ def empty?: () -> bool
48
+ def bytesize: () -> Integer
49
+ def stream: (Transcoder::_Encoder) -> bodyIO
50
+ def unbounded_body?: () -> bool
51
+ def chunked?: () -> bool
52
+ def chunk!: () -> void
53
+ def inspect: () -> String
54
+ end
55
+
56
+ class ProcIO
57
+ include _Writer
58
+ def initialize: (^(_ToS) -> void) -> untyped
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,87 @@
1
+ module HTTPX
2
+ interface _Response
3
+ def raise_for_status: () -> void
4
+ end
5
+
6
+ class Response
7
+ include _Response
8
+ include _ToS
9
+ include _Reader
10
+
11
+ attr_reader status: int
12
+ attr_reader headers: headers
13
+ attr_reader body: Body
14
+ attr_reader version: String
15
+
16
+ @options: Options
17
+ @request: Request
18
+
19
+ def copy_to: (_ToPath | _Writer destination) -> void
20
+ def close: () -> void
21
+ def uri: () -> uri
22
+
23
+ def merge_headers: (headers) -> void
24
+ def bodyless?: () -> bool
25
+ def content_type: () -> ContentType
26
+ def complete?: () -> bool
27
+
28
+ private
29
+
30
+ def initialize: (Request, _ToS, String, headers) -> untyped
31
+ def no_data?: () -> bool
32
+
33
+ class Body
34
+ include _Writer
35
+ include _Reader
36
+ include _ToS
37
+ include _ToStr
38
+
39
+ @state: :idle | :memory | :buffer
40
+
41
+ def each: () { (String) -> void } -> void
42
+ | () -> Enumerable[String]
43
+
44
+ def bytesize: () -> Integer
45
+ def empty?: () -> bool
46
+ def copy_to: (_ToPath | _Writer destination) -> void
47
+ def close: () -> void
48
+
49
+ private
50
+
51
+ def initialize: (Response, ?threshold_size: Integer, ?window_size: Integer) -> untyped
52
+ def rewind: () -> void
53
+ def transition: () -> void
54
+ end
55
+ end
56
+
57
+ class ContentType
58
+ attr_reader mime_type: String?
59
+ attr_reader charset: String?
60
+
61
+ def self.parse: (_ToS) -> instance
62
+ def self.mime_type: (_ToS) -> String?
63
+ def self.charset: (_ToS) -> String?
64
+
65
+ private
66
+
67
+ def initialize: (String?, String?) -> untyped
68
+ end
69
+
70
+ class ErrorResponse
71
+ include _Response
72
+ include Loggable
73
+
74
+ @options: Options
75
+
76
+ attr_reader request: Request
77
+ attr_reader error: Exception
78
+
79
+ def status: () -> (Integer | _ToS)
80
+
81
+ private
82
+
83
+ def initialize: (Request, Exception, options) -> untyped
84
+ end
85
+
86
+ type response = Response | ErrorResponse
87
+ end
@@ -0,0 +1,49 @@
1
+ module HTTPX
2
+ class Session
3
+ include Loggable
4
+ include Chainable
5
+
6
+ @options: Options
7
+ @responses: Hash[Request, Response]
8
+ @persistent: bool
9
+
10
+ def wrap: () { (instance) -> void } -> void
11
+ | () -> void
12
+ def close: (*untyped) -> void
13
+
14
+ def request: (*Request, **untyped) -> (response | Array[response])
15
+ | (*untyped, **untyped) -> (response | Array[response])
16
+
17
+ def build_request: (String | verb, uri, ?options) -> Request
18
+
19
+ # def self.plugin: | (Symbol | Module, ?options) { (Class) -> void } -> singleton(Session)
20
+ # | (Symbol | Module, ?options) -> singleton(Session)
21
+
22
+
23
+
24
+ def self.default_options: -> Options
25
+
26
+ private
27
+
28
+ def initialize: (?options?) { (instance) -> void } -> untyped
29
+ | (?options?) -> untyped
30
+
31
+ def pool: -> Pool
32
+ # def on_response: (Request, response) -> void
33
+ def on_promise: (untyped, untyped) -> void
34
+ def fetch_response: (Request, *untyped) -> response?
35
+ def set_connection_callbacks: (Connection, Array[Connection], Options) -> void
36
+
37
+ def build_altsvc_connection: (Connection, Array[Connection], URI, String, Hash[String, String], Options) -> Connection?
38
+
39
+ def build_requests: (verb | string, uri, options) -> Array[Request]
40
+ | (Array[[verb | string, uri, options]], options) -> Array[Request]
41
+ | (Array[[verb | string, uri]], options) -> Array[Request]
42
+ | (verb | string, _Each[[uri, options], void], Options) -> Array[Request]
43
+ | (verb | string, _Each[uri, void], options) -> Array[Request]
44
+
45
+ def build_connection: (URI, Options) -> Connection
46
+
47
+ def send_requests: (*Request, options) -> Array[response]
48
+ end
49
+ end
@@ -0,0 +1,9 @@
1
+ class A
2
+ def each_normal: () { (String) -> void } -> void
3
+ | () -> Enumerable[String]
4
+
5
+ def each_abnormal: () { (String) -> void } -> void
6
+ | () -> Enumerable[String]
7
+
8
+ def on_block: (String) -> void
9
+ end
@@ -0,0 +1,29 @@
1
+ module HTTPX
2
+ class Timeout
3
+ CONNECT_TIMEOUT: Numeric
4
+ KEEP_ALIVE_TIMEOUT: Numeric
5
+ OPERATION_TIMEOUT: Numeric
6
+
7
+ attr_reader connect_timeout: Numeric
8
+ attr_reader operation_timeout: Numeric
9
+ attr_reader total_timeout: Numeric?
10
+ attr_reader keep_alive_timeout: Numeric?
11
+
12
+ def self.new: (instance | Hash[Symbol, untyped]) -> instance
13
+ | () -> instance
14
+
15
+ def ==: (untyped other) -> bool
16
+
17
+ def merge: (Timeout | Hash[Symbol, untyped]) -> instance
18
+
19
+ private
20
+
21
+ def initialize: (
22
+ ?connect_timeout: Numeric,
23
+ ?operation_timeout: Numeric,
24
+ ?keep_alive_timeout: Numeric,
25
+ ?total_timeout: Numeric | nil,
26
+ ?loop_timeout: Numeric | nil
27
+ ) -> untyped
28
+ end
29
+ end
@@ -0,0 +1,16 @@
1
+ module HTTPX
2
+ type bodyIO = _Reader | _Each[String, untyped] | _ToS
3
+
4
+ module Transcoder
5
+ extend HTTPX::Registry[String, Class]
6
+
7
+ interface _Encoder
8
+ def bytesize: () -> Integer
9
+ def content_type: () -> String
10
+ end
11
+
12
+ interface _Decoder
13
+ def decode: (string) -> String
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,18 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ module Body
4
+ class Encoder
5
+ include _Encoder
6
+ include _ToS
7
+
8
+ @raw: bodyIO
9
+
10
+ private
11
+
12
+ def initialize: (untyped body ) -> untyped
13
+ end
14
+
15
+ def self?.encode: (bodyIO body) -> Encoder
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,32 @@
1
+ module HTTPX::Transcoder
2
+ module Chunker
3
+ def self?.encode: (_Encoder chunks) -> Encoder
4
+
5
+ class Encoder
6
+ @raw: _Each[String]
7
+
8
+ include _Each[String]
9
+
10
+ private
11
+
12
+ def initialize: (_Encoder chunks) -> untyped
13
+ end
14
+
15
+ class Decoder
16
+ include _ToS
17
+ include _Each[String]
18
+
19
+ def finished?: () -> bool
20
+ def empty?: () -> bool
21
+ def <<: (string) -> void
22
+ def clear: () -> void
23
+
24
+ private
25
+
26
+ def initialize: (String, bool) -> untyped
27
+ | (String) -> untyped
28
+
29
+ def nextstate: (Symbol) -> void
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ module HTTPX::Transcoder
2
+ type urlencoded_input = Enumerable[[string, string], untyped]
3
+
4
+ module Form
5
+ def self?.encode: (urlencoded_input form) -> Encoder
6
+
7
+ class Encoder
8
+ include _Encoder
9
+ include _ToS
10
+
11
+ private
12
+
13
+ def initalize: (urlencoded_input form) -> untyped
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ module HTTPX::Transcoder
2
+ module JSON
3
+ def self?.encode: (_ToJson json) -> Encoder
4
+
5
+ class Encoder
6
+ include _Encoder
7
+ include _ToS
8
+
9
+ private
10
+
11
+ def initalize: (_ToJson json) -> untyped
12
+ end
13
+ end
14
+ 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.9.0
4
+ version: 0.10.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: 2020-10-08 00:00:00.000000000 Z
11
+ date: 2020-11-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-2-next
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: http-cookie
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.0'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: http-form_data
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,6 +86,7 @@ extra_rdoc_files:
100
86
  - doc/release_notes/0_6_6.md
101
87
  - doc/release_notes/0_4_0.md
102
88
  - doc/release_notes/0_6_2.md
89
+ - doc/release_notes/0_10_0.md
103
90
  - doc/release_notes/0_8_0.md
104
91
  - doc/release_notes/0_3_0.md
105
92
  - doc/release_notes/0_2_1.md
@@ -115,6 +102,7 @@ files:
115
102
  - doc/release_notes/0_0_3.md
116
103
  - doc/release_notes/0_0_4.md
117
104
  - doc/release_notes/0_0_5.md
105
+ - doc/release_notes/0_10_0.md
118
106
  - doc/release_notes/0_1_0.md
119
107
  - doc/release_notes/0_2_0.md
120
108
  - doc/release_notes/0_2_1.md
@@ -146,6 +134,7 @@ files:
146
134
  - lib/httpx/connection.rb
147
135
  - lib/httpx/connection/http1.rb
148
136
  - lib/httpx/connection/http2.rb
137
+ - lib/httpx/domain_name.rb
149
138
  - lib/httpx/errors.rb
150
139
  - lib/httpx/extensions.rb
151
140
  - lib/httpx/headers.rb
@@ -164,6 +153,9 @@ files:
164
153
  - lib/httpx/plugins/compression/deflate.rb
165
154
  - lib/httpx/plugins/compression/gzip.rb
166
155
  - lib/httpx/plugins/cookies.rb
156
+ - lib/httpx/plugins/cookies/cookie.rb
157
+ - lib/httpx/plugins/cookies/jar.rb
158
+ - lib/httpx/plugins/cookies/set_cookie_parser.rb
167
159
  - lib/httpx/plugins/digest_authentication.rb
168
160
  - lib/httpx/plugins/expect.rb
169
161
  - lib/httpx/plugins/follow_redirects.rb
@@ -176,6 +168,7 @@ files:
176
168
  - lib/httpx/plugins/proxy/socks5.rb
177
169
  - lib/httpx/plugins/proxy/ssh.rb
178
170
  - lib/httpx/plugins/push_promise.rb
171
+ - lib/httpx/plugins/rate_limiter.rb
179
172
  - lib/httpx/plugins/retries.rb
180
173
  - lib/httpx/plugins/stream.rb
181
174
  - lib/httpx/pool.rb
@@ -196,7 +189,57 @@ files:
196
189
  - lib/httpx/transcoder/chunker.rb
197
190
  - lib/httpx/transcoder/form.rb
198
191
  - lib/httpx/transcoder/json.rb
192
+ - lib/httpx/utils.rb
199
193
  - lib/httpx/version.rb
194
+ - sig/buffer.rbs
195
+ - sig/callbacks.rbs
196
+ - sig/chainable.rbs
197
+ - sig/connection.rbs
198
+ - sig/connection/http2.rbs
199
+ - sig/domain_name.rbs
200
+ - sig/errors.rbs
201
+ - sig/headers.rbs
202
+ - sig/httpx.rbs
203
+ - sig/loggable.rbs
204
+ - sig/missing.rbs
205
+ - sig/options.rbs
206
+ - sig/parser/http1.rbs
207
+ - sig/plugins/authentication.rbs
208
+ - sig/plugins/basic_authentication.rbs
209
+ - sig/plugins/compression.rbs
210
+ - sig/plugins/compression/brotli.rbs
211
+ - sig/plugins/compression/deflate.rbs
212
+ - sig/plugins/compression/gzip.rbs
213
+ - sig/plugins/cookies.rbs
214
+ - sig/plugins/cookies/cookie.rbs
215
+ - sig/plugins/cookies/jar.rbs
216
+ - sig/plugins/digest_authentication.rbs
217
+ - sig/plugins/expect.rbs
218
+ - sig/plugins/follow_redirects.rbs
219
+ - sig/plugins/h2c.rbs
220
+ - sig/plugins/multipart.rbs
221
+ - sig/plugins/persistent.rbs
222
+ - sig/plugins/proxy.rbs
223
+ - sig/plugins/proxy/http.rbs
224
+ - sig/plugins/proxy/socks4.rbs
225
+ - sig/plugins/proxy/socks5.rbs
226
+ - sig/plugins/proxy/ssh.rbs
227
+ - sig/plugins/push_promise.rbs
228
+ - sig/plugins/rate_limiter.rbs
229
+ - sig/plugins/retries.rbs
230
+ - sig/plugins/stream.rbs
231
+ - sig/pool.rbs
232
+ - sig/registry.rbs
233
+ - sig/request.rbs
234
+ - sig/response.rbs
235
+ - sig/session.rbs
236
+ - sig/test.rbs
237
+ - sig/timeout.rbs
238
+ - sig/transcoder.rbs
239
+ - sig/transcoder/body.rbs
240
+ - sig/transcoder/chunker.rbs
241
+ - sig/transcoder/form.rbs
242
+ - sig/transcoder/json.rbs
200
243
  homepage: https://gitlab.com/honeyryderchuck/httpx
201
244
  licenses:
202
245
  - Apache 2.0
@@ -220,7 +263,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
220
263
  - !ruby/object:Gem::Version
221
264
  version: '0'
222
265
  requirements: []
223
- rubygems_version: 3.1.2
266
+ rubygems_version: 3.1.4
224
267
  signing_key:
225
268
  specification_version: 4
226
269
  summary: HTTPX, to the future, and beyond