httpx 0.24.6 → 1.0.1
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.
- checksums.yaml +4 -4
- data/LICENSE.txt +0 -48
- data/README.md +4 -13
- data/doc/release_notes/0_24_4.md +3 -3
- data/doc/release_notes/1_0_0.md +60 -0
- data/doc/release_notes/1_0_1.md +5 -0
- data/lib/httpx/adapters/datadog.rb +28 -97
- data/lib/httpx/adapters/faraday.rb +9 -52
- data/lib/httpx/adapters/webmock.rb +2 -7
- data/lib/httpx/altsvc.rb +4 -22
- data/lib/httpx/base64.rb +27 -0
- data/lib/httpx/chainable.rb +0 -23
- data/lib/httpx/connection.rb +11 -32
- data/lib/httpx/domain_name.rb +5 -12
- data/lib/httpx/errors.rb +0 -2
- data/lib/httpx/extensions.rb +0 -124
- data/lib/httpx/io/ssl.rb +26 -59
- data/lib/httpx/io/tcp.rb +27 -68
- data/lib/httpx/io/udp.rb +13 -48
- data/lib/httpx/io/unix.rb +1 -8
- data/lib/httpx/loggable.rb +4 -19
- data/lib/httpx/options.rb +24 -84
- data/lib/httpx/plugins/{authentication → auth}/basic.rb +1 -5
- data/lib/httpx/plugins/{authentication → auth}/digest.rb +2 -5
- data/lib/httpx/plugins/{authentication → auth}/ntlm.rb +1 -3
- data/lib/httpx/plugins/{authentication → auth}/socks5.rb +0 -2
- data/lib/httpx/plugins/auth.rb +25 -0
- data/lib/httpx/plugins/aws_sigv4.rb +0 -1
- data/lib/httpx/plugins/{basic_authentication.rb → basic_auth.rb} +5 -6
- data/lib/httpx/plugins/brotli.rb +50 -0
- data/lib/httpx/plugins/circuit_breaker/circuit.rb +40 -16
- data/lib/httpx/plugins/circuit_breaker/circuit_store.rb +16 -5
- data/lib/httpx/plugins/circuit_breaker.rb +11 -4
- data/lib/httpx/plugins/cookies/set_cookie_parser.rb +0 -2
- data/lib/httpx/plugins/cookies.rb +1 -1
- data/lib/httpx/plugins/{digest_authentication.rb → digest_auth.rb} +5 -5
- data/lib/httpx/plugins/follow_redirects.rb +21 -24
- data/lib/httpx/plugins/grpc/grpc_encoding.rb +82 -0
- data/lib/httpx/plugins/grpc/message.rb +7 -39
- data/lib/httpx/plugins/grpc.rb +15 -21
- data/lib/httpx/plugins/h2c.rb +0 -1
- data/lib/httpx/plugins/{ntlm_authentication.rb → ntlm_auth.rb} +5 -5
- data/lib/httpx/plugins/oauth.rb +2 -2
- data/lib/httpx/plugins/proxy/http.rb +0 -2
- data/lib/httpx/plugins/proxy/socks4.rb +0 -4
- data/lib/httpx/plugins/proxy/socks5.rb +1 -5
- data/lib/httpx/plugins/proxy.rb +3 -32
- data/lib/httpx/plugins/retries.rb +3 -4
- data/lib/httpx/plugins/stream.rb +4 -6
- data/lib/httpx/punycode.rb +9 -291
- data/lib/httpx/request/body.rb +145 -0
- data/lib/httpx/request.rb +2 -119
- data/lib/httpx/resolver/https.rb +1 -1
- data/lib/httpx/resolver/native.rb +6 -14
- data/lib/httpx/resolver/resolver.rb +1 -1
- data/lib/httpx/resolver/system.rb +11 -9
- data/lib/httpx/response/body.rb +206 -0
- data/lib/httpx/response/buffer.rb +90 -0
- data/lib/httpx/response.rb +5 -208
- data/lib/httpx/selector.rb +0 -2
- data/lib/httpx/session.rb +0 -10
- data/lib/httpx/transcoder/body.rb +0 -1
- data/lib/httpx/transcoder/deflate.rb +37 -0
- data/lib/httpx/transcoder/form.rb +52 -32
- data/lib/httpx/transcoder/gzip.rb +74 -0
- data/lib/httpx/transcoder/json.rb +2 -4
- data/lib/httpx/transcoder/multipart/decoder.rb +139 -0
- data/lib/httpx/{plugins → transcoder}/multipart/encoder.rb +3 -3
- data/lib/httpx/{plugins → transcoder}/multipart/mime_type_detector.rb +1 -1
- data/lib/httpx/{plugins → transcoder}/multipart/part.rb +3 -2
- data/lib/httpx/transcoder/multipart.rb +17 -0
- data/lib/httpx/transcoder/utils/body_reader.rb +46 -0
- data/lib/httpx/transcoder/utils/deflater.rb +72 -0
- data/lib/httpx/transcoder/xml.rb +0 -2
- data/lib/httpx/transcoder.rb +2 -2
- data/lib/httpx/utils.rb +10 -20
- data/lib/httpx/version.rb +1 -1
- data/lib/httpx.rb +0 -8
- data/sig/chainable.rbs +5 -6
- data/sig/connection.rbs +0 -1
- data/sig/errors.rbs +0 -3
- data/sig/httpx.rbs +2 -1
- data/sig/io/unix.rbs +1 -1
- data/sig/options.rbs +12 -8
- data/sig/plugins/{authentication → auth}/basic.rbs +0 -2
- data/sig/plugins/auth.rbs +13 -0
- data/sig/plugins/{basic_authentication.rbs → basic_auth.rbs} +2 -2
- data/sig/plugins/brotli.rbs +22 -0
- data/sig/plugins/circuit_breaker.rbs +7 -3
- data/sig/plugins/compression.rbs +0 -2
- data/sig/plugins/{digest_authentication.rbs → digest_auth.rbs} +2 -2
- data/sig/plugins/follow_redirects.rbs +0 -1
- data/sig/plugins/grpc/call.rbs +19 -0
- data/sig/plugins/grpc/grpc_encoding.rbs +33 -0
- data/sig/plugins/grpc/message.rbs +17 -0
- data/sig/plugins/grpc.rbs +2 -32
- data/sig/plugins/{ntlm_authentication.rbs → ntlm_auth.rbs} +2 -2
- data/sig/plugins/oauth.rbs +1 -1
- data/sig/plugins/proxy/socks4.rbs +2 -3
- data/sig/plugins/proxy/socks5.rbs +0 -1
- data/sig/plugins/proxy/ssh.rbs +1 -1
- data/sig/plugins/response_cache.rbs +5 -2
- data/sig/request/body.rbs +42 -0
- data/sig/request.rbs +1 -27
- data/sig/resolver/resolver.rbs +1 -1
- data/sig/response/body.rbs +52 -0
- data/sig/response/buffer.rbs +24 -0
- data/sig/response.rbs +0 -39
- data/sig/transcoder/body.rbs +4 -3
- data/sig/transcoder/deflate.rbs +11 -0
- data/sig/transcoder/form.rbs +5 -3
- data/sig/transcoder/gzip.rbs +24 -0
- data/sig/transcoder/json.rbs +4 -2
- data/sig/{plugins → transcoder}/multipart.rbs +3 -10
- data/sig/transcoder/utils/body_reader.rbs +15 -0
- data/sig/transcoder/utils/deflater.rbs +29 -0
- data/sig/transcoder.rbs +18 -2
- metadata +52 -34
- data/lib/httpx/plugins/authentication.rb +0 -24
- data/lib/httpx/plugins/compression/brotli.rb +0 -54
- data/lib/httpx/plugins/compression/deflate.rb +0 -54
- data/lib/httpx/plugins/compression/gzip.rb +0 -90
- data/lib/httpx/plugins/compression.rb +0 -165
- data/lib/httpx/plugins/multipart/decoder.rb +0 -137
- data/lib/httpx/plugins/multipart.rb +0 -96
- data/sig/plugins/authentication.rbs +0 -13
- data/sig/plugins/compression/brotli.rbs +0 -21
- data/sig/plugins/compression/deflate.rbs +0 -17
- data/sig/plugins/compression/gzip.rbs +0 -29
- /data/sig/plugins/{authentication → auth}/digest.rbs +0 -0
- /data/sig/plugins/{authentication → auth}/ntlm.rbs +0 -0
- /data/sig/plugins/{authentication → auth}/socks5.rbs +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module HTTPX
|
|
2
|
+
module Transcoder
|
|
3
|
+
class Deflater
|
|
4
|
+
extend Forwardable
|
|
5
|
+
|
|
6
|
+
@body: BodyReader
|
|
7
|
+
@buffer: Response::Buffer?
|
|
8
|
+
@body: _Encoder | StringIO
|
|
9
|
+
@closed: bool
|
|
10
|
+
|
|
11
|
+
attr_reader content_type: String
|
|
12
|
+
|
|
13
|
+
def initialize: (_Encoder body) -> void
|
|
14
|
+
|
|
15
|
+
def bytesize: () -> (Integer | Float)
|
|
16
|
+
|
|
17
|
+
def read: (?int? length, ?string outbuf) -> String?
|
|
18
|
+
|
|
19
|
+
def close: () -> void
|
|
20
|
+
|
|
21
|
+
def deflate: (String? chunk) -> String?
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def buffer_deflate!: () -> void
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/sig/transcoder.rbs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module HTTPX
|
|
2
|
-
type bodyIO = _Reader | _Each[
|
|
2
|
+
type bodyIO = _Reader | _Each[String] | _ToS
|
|
3
3
|
|
|
4
|
-
type body_encoder = Transcoder::_Encoder | _Each[String]
|
|
4
|
+
type body_encoder = (Transcoder::_Encoder & _ToS) | (Transcoder::_Encoder & _Reader) | (Transcoder::_Encoder & _Each[String])
|
|
5
5
|
|
|
6
6
|
module Transcoder
|
|
7
7
|
def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value, ?(^(untyped value) -> bool | nil) cond) { (String, ?untyped) -> U } -> U
|
|
@@ -18,10 +18,26 @@ module HTTPX
|
|
|
18
18
|
|
|
19
19
|
interface _Encoder
|
|
20
20
|
def bytesize: () -> (Integer | Float)
|
|
21
|
+
|
|
22
|
+
def content_type: () -> String
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
interface _Decoder
|
|
24
26
|
def call: (Response response, *untyped) -> untyped
|
|
25
27
|
end
|
|
28
|
+
|
|
29
|
+
interface _Inflater
|
|
30
|
+
def initialize: (Integer | Float bytesize) -> void
|
|
31
|
+
|
|
32
|
+
def call: (String chunk) -> String
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
interface _Deflater
|
|
36
|
+
def initialize: (Response body) -> void
|
|
37
|
+
|
|
38
|
+
def deflate: () -> void
|
|
39
|
+
|
|
40
|
+
def call: (StringIO | File buffer, ?chunk_size: Integer) ?{ (String chunk) -> void } -> void
|
|
41
|
+
end
|
|
26
42
|
end
|
|
27
43
|
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.
|
|
4
|
+
version: 1.0.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tiago Cardoso
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-
|
|
11
|
+
date: 2023-10-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: http-2-next
|
|
@@ -16,14 +16,14 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: 0.
|
|
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: 0.
|
|
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
|
|
@@ -127,6 +127,8 @@ extra_rdoc_files:
|
|
|
127
127
|
- doc/release_notes/0_8_1.md
|
|
128
128
|
- doc/release_notes/0_8_2.md
|
|
129
129
|
- doc/release_notes/0_9_0.md
|
|
130
|
+
- doc/release_notes/1_0_0.md
|
|
131
|
+
- doc/release_notes/1_0_1.md
|
|
130
132
|
files:
|
|
131
133
|
- LICENSE.txt
|
|
132
134
|
- README.md
|
|
@@ -225,12 +227,15 @@ files:
|
|
|
225
227
|
- doc/release_notes/0_8_1.md
|
|
226
228
|
- doc/release_notes/0_8_2.md
|
|
227
229
|
- doc/release_notes/0_9_0.md
|
|
230
|
+
- doc/release_notes/1_0_0.md
|
|
231
|
+
- doc/release_notes/1_0_1.md
|
|
228
232
|
- lib/httpx.rb
|
|
229
233
|
- lib/httpx/adapters/datadog.rb
|
|
230
234
|
- lib/httpx/adapters/faraday.rb
|
|
231
235
|
- lib/httpx/adapters/sentry.rb
|
|
232
236
|
- lib/httpx/adapters/webmock.rb
|
|
233
237
|
- lib/httpx/altsvc.rb
|
|
238
|
+
- lib/httpx/base64.rb
|
|
234
239
|
- lib/httpx/buffer.rb
|
|
235
240
|
- lib/httpx/callbacks.rb
|
|
236
241
|
- lib/httpx/chainable.rb
|
|
@@ -249,39 +254,32 @@ files:
|
|
|
249
254
|
- lib/httpx/loggable.rb
|
|
250
255
|
- lib/httpx/options.rb
|
|
251
256
|
- lib/httpx/parser/http1.rb
|
|
252
|
-
- lib/httpx/plugins/
|
|
253
|
-
- lib/httpx/plugins/
|
|
254
|
-
- lib/httpx/plugins/
|
|
255
|
-
- lib/httpx/plugins/
|
|
256
|
-
- lib/httpx/plugins/
|
|
257
|
+
- lib/httpx/plugins/auth.rb
|
|
258
|
+
- lib/httpx/plugins/auth/basic.rb
|
|
259
|
+
- lib/httpx/plugins/auth/digest.rb
|
|
260
|
+
- lib/httpx/plugins/auth/ntlm.rb
|
|
261
|
+
- lib/httpx/plugins/auth/socks5.rb
|
|
257
262
|
- lib/httpx/plugins/aws_sdk_authentication.rb
|
|
258
263
|
- lib/httpx/plugins/aws_sigv4.rb
|
|
259
|
-
- lib/httpx/plugins/
|
|
264
|
+
- lib/httpx/plugins/basic_auth.rb
|
|
265
|
+
- lib/httpx/plugins/brotli.rb
|
|
260
266
|
- lib/httpx/plugins/circuit_breaker.rb
|
|
261
267
|
- lib/httpx/plugins/circuit_breaker/circuit.rb
|
|
262
268
|
- lib/httpx/plugins/circuit_breaker/circuit_store.rb
|
|
263
|
-
- lib/httpx/plugins/compression.rb
|
|
264
|
-
- lib/httpx/plugins/compression/brotli.rb
|
|
265
|
-
- lib/httpx/plugins/compression/deflate.rb
|
|
266
|
-
- lib/httpx/plugins/compression/gzip.rb
|
|
267
269
|
- lib/httpx/plugins/cookies.rb
|
|
268
270
|
- lib/httpx/plugins/cookies/cookie.rb
|
|
269
271
|
- lib/httpx/plugins/cookies/jar.rb
|
|
270
272
|
- lib/httpx/plugins/cookies/set_cookie_parser.rb
|
|
271
|
-
- lib/httpx/plugins/
|
|
273
|
+
- lib/httpx/plugins/digest_auth.rb
|
|
272
274
|
- lib/httpx/plugins/expect.rb
|
|
273
275
|
- lib/httpx/plugins/follow_redirects.rb
|
|
274
276
|
- lib/httpx/plugins/grpc.rb
|
|
275
277
|
- lib/httpx/plugins/grpc/call.rb
|
|
278
|
+
- lib/httpx/plugins/grpc/grpc_encoding.rb
|
|
276
279
|
- lib/httpx/plugins/grpc/message.rb
|
|
277
280
|
- lib/httpx/plugins/h2c.rb
|
|
278
281
|
- lib/httpx/plugins/internal_telemetry.rb
|
|
279
|
-
- lib/httpx/plugins/
|
|
280
|
-
- lib/httpx/plugins/multipart/decoder.rb
|
|
281
|
-
- lib/httpx/plugins/multipart/encoder.rb
|
|
282
|
-
- lib/httpx/plugins/multipart/mime_type_detector.rb
|
|
283
|
-
- lib/httpx/plugins/multipart/part.rb
|
|
284
|
-
- lib/httpx/plugins/ntlm_authentication.rb
|
|
282
|
+
- lib/httpx/plugins/ntlm_auth.rb
|
|
285
283
|
- lib/httpx/plugins/oauth.rb
|
|
286
284
|
- lib/httpx/plugins/persistent.rb
|
|
287
285
|
- lib/httpx/plugins/proxy.rb
|
|
@@ -303,6 +301,7 @@ files:
|
|
|
303
301
|
- lib/httpx/pool.rb
|
|
304
302
|
- lib/httpx/punycode.rb
|
|
305
303
|
- lib/httpx/request.rb
|
|
304
|
+
- lib/httpx/request/body.rb
|
|
306
305
|
- lib/httpx/resolver.rb
|
|
307
306
|
- lib/httpx/resolver/https.rb
|
|
308
307
|
- lib/httpx/resolver/multi.rb
|
|
@@ -310,6 +309,8 @@ files:
|
|
|
310
309
|
- lib/httpx/resolver/resolver.rb
|
|
311
310
|
- lib/httpx/resolver/system.rb
|
|
312
311
|
- lib/httpx/response.rb
|
|
312
|
+
- lib/httpx/response/body.rb
|
|
313
|
+
- lib/httpx/response/buffer.rb
|
|
313
314
|
- lib/httpx/selector.rb
|
|
314
315
|
- lib/httpx/session.rb
|
|
315
316
|
- lib/httpx/session2.rb
|
|
@@ -318,8 +319,17 @@ files:
|
|
|
318
319
|
- lib/httpx/transcoder.rb
|
|
319
320
|
- lib/httpx/transcoder/body.rb
|
|
320
321
|
- lib/httpx/transcoder/chunker.rb
|
|
322
|
+
- lib/httpx/transcoder/deflate.rb
|
|
321
323
|
- lib/httpx/transcoder/form.rb
|
|
324
|
+
- lib/httpx/transcoder/gzip.rb
|
|
322
325
|
- lib/httpx/transcoder/json.rb
|
|
326
|
+
- lib/httpx/transcoder/multipart.rb
|
|
327
|
+
- lib/httpx/transcoder/multipart/decoder.rb
|
|
328
|
+
- lib/httpx/transcoder/multipart/encoder.rb
|
|
329
|
+
- lib/httpx/transcoder/multipart/mime_type_detector.rb
|
|
330
|
+
- lib/httpx/transcoder/multipart/part.rb
|
|
331
|
+
- lib/httpx/transcoder/utils/body_reader.rb
|
|
332
|
+
- lib/httpx/transcoder/utils/deflater.rb
|
|
323
333
|
- lib/httpx/transcoder/xml.rb
|
|
324
334
|
- lib/httpx/utils.rb
|
|
325
335
|
- lib/httpx/version.rb
|
|
@@ -341,29 +351,29 @@ files:
|
|
|
341
351
|
- sig/loggable.rbs
|
|
342
352
|
- sig/options.rbs
|
|
343
353
|
- sig/parser/http1.rbs
|
|
344
|
-
- sig/plugins/
|
|
345
|
-
- sig/plugins/
|
|
346
|
-
- sig/plugins/
|
|
347
|
-
- sig/plugins/
|
|
348
|
-
- sig/plugins/
|
|
354
|
+
- sig/plugins/auth.rbs
|
|
355
|
+
- sig/plugins/auth/basic.rbs
|
|
356
|
+
- sig/plugins/auth/digest.rbs
|
|
357
|
+
- sig/plugins/auth/ntlm.rbs
|
|
358
|
+
- sig/plugins/auth/socks5.rbs
|
|
349
359
|
- sig/plugins/aws_sdk_authentication.rbs
|
|
350
360
|
- sig/plugins/aws_sigv4.rbs
|
|
351
|
-
- sig/plugins/
|
|
361
|
+
- sig/plugins/basic_auth.rbs
|
|
362
|
+
- sig/plugins/brotli.rbs
|
|
352
363
|
- sig/plugins/circuit_breaker.rbs
|
|
353
364
|
- sig/plugins/compression.rbs
|
|
354
|
-
- sig/plugins/compression/brotli.rbs
|
|
355
|
-
- sig/plugins/compression/deflate.rbs
|
|
356
|
-
- sig/plugins/compression/gzip.rbs
|
|
357
365
|
- sig/plugins/cookies.rbs
|
|
358
366
|
- sig/plugins/cookies/cookie.rbs
|
|
359
367
|
- sig/plugins/cookies/jar.rbs
|
|
360
|
-
- sig/plugins/
|
|
368
|
+
- sig/plugins/digest_auth.rbs
|
|
361
369
|
- sig/plugins/expect.rbs
|
|
362
370
|
- sig/plugins/follow_redirects.rbs
|
|
363
371
|
- sig/plugins/grpc.rbs
|
|
372
|
+
- sig/plugins/grpc/call.rbs
|
|
373
|
+
- sig/plugins/grpc/grpc_encoding.rbs
|
|
374
|
+
- sig/plugins/grpc/message.rbs
|
|
364
375
|
- sig/plugins/h2c.rbs
|
|
365
|
-
- sig/plugins/
|
|
366
|
-
- sig/plugins/ntlm_authentication.rbs
|
|
376
|
+
- sig/plugins/ntlm_auth.rbs
|
|
367
377
|
- sig/plugins/oauth.rbs
|
|
368
378
|
- sig/plugins/persistent.rbs
|
|
369
379
|
- sig/plugins/proxy.rbs
|
|
@@ -379,6 +389,7 @@ files:
|
|
|
379
389
|
- sig/plugins/upgrade.rbs
|
|
380
390
|
- sig/pool.rbs
|
|
381
391
|
- sig/request.rbs
|
|
392
|
+
- sig/request/body.rbs
|
|
382
393
|
- sig/resolver.rbs
|
|
383
394
|
- sig/resolver/https.rbs
|
|
384
395
|
- sig/resolver/multi.rbs
|
|
@@ -386,14 +397,21 @@ files:
|
|
|
386
397
|
- sig/resolver/resolver.rbs
|
|
387
398
|
- sig/resolver/system.rbs
|
|
388
399
|
- sig/response.rbs
|
|
400
|
+
- sig/response/body.rbs
|
|
401
|
+
- sig/response/buffer.rbs
|
|
389
402
|
- sig/selector.rbs
|
|
390
403
|
- sig/session.rbs
|
|
391
404
|
- sig/timers.rbs
|
|
392
405
|
- sig/transcoder.rbs
|
|
393
406
|
- sig/transcoder/body.rbs
|
|
394
407
|
- sig/transcoder/chunker.rbs
|
|
408
|
+
- sig/transcoder/deflate.rbs
|
|
395
409
|
- sig/transcoder/form.rbs
|
|
410
|
+
- sig/transcoder/gzip.rbs
|
|
396
411
|
- sig/transcoder/json.rbs
|
|
412
|
+
- sig/transcoder/multipart.rbs
|
|
413
|
+
- sig/transcoder/utils/body_reader.rbs
|
|
414
|
+
- sig/transcoder/utils/deflater.rbs
|
|
397
415
|
- sig/transcoder/xml.rbs
|
|
398
416
|
- sig/utils.rbs
|
|
399
417
|
homepage: https://gitlab.com/os85/httpx
|
|
@@ -414,7 +432,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
414
432
|
requirements:
|
|
415
433
|
- - ">="
|
|
416
434
|
- !ruby/object:Gem::Version
|
|
417
|
-
version:
|
|
435
|
+
version: 2.7.0
|
|
418
436
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
419
437
|
requirements:
|
|
420
438
|
- - ">="
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module HTTPX
|
|
4
|
-
module Plugins
|
|
5
|
-
#
|
|
6
|
-
# This plugin adds a shim +authentication+ method to the session, which will fill
|
|
7
|
-
# the HTTP Authorization header.
|
|
8
|
-
#
|
|
9
|
-
# https://gitlab.com/os85/httpx/wikis/Authentication#authentication
|
|
10
|
-
#
|
|
11
|
-
module Authentication
|
|
12
|
-
module InstanceMethods
|
|
13
|
-
def authentication(token)
|
|
14
|
-
with(headers: { "authorization" => token })
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def bearer_auth(token)
|
|
18
|
-
authentication("Bearer #{token}")
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
register_plugin :authentication, Authentication
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module HTTPX
|
|
4
|
-
module Plugins
|
|
5
|
-
module Compression
|
|
6
|
-
module Brotli
|
|
7
|
-
class << self
|
|
8
|
-
def load_dependencies(klass)
|
|
9
|
-
require "brotli"
|
|
10
|
-
klass.plugin(:compression)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def extra_options(options)
|
|
14
|
-
options.merge(encodings: options.encodings.merge("br" => self))
|
|
15
|
-
end
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
module Deflater
|
|
19
|
-
module_function
|
|
20
|
-
|
|
21
|
-
def deflate(raw, buffer = "".b, chunk_size: 16_384)
|
|
22
|
-
while (chunk = raw.read(chunk_size))
|
|
23
|
-
compressed = ::Brotli.deflate(chunk)
|
|
24
|
-
buffer << compressed
|
|
25
|
-
yield compressed if block_given?
|
|
26
|
-
end
|
|
27
|
-
buffer
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
class Inflater
|
|
32
|
-
def initialize(bytesize)
|
|
33
|
-
@bytesize = bytesize
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def inflate(chunk)
|
|
37
|
-
::Brotli.inflate(chunk)
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
module_function
|
|
42
|
-
|
|
43
|
-
def deflater
|
|
44
|
-
Deflater
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def inflater(bytesize)
|
|
48
|
-
Inflater.new(bytesize)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
register_plugin :"compression/brotli", Compression::Brotli
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module HTTPX
|
|
4
|
-
module Plugins
|
|
5
|
-
module Compression
|
|
6
|
-
module Deflate
|
|
7
|
-
class << self
|
|
8
|
-
def load_dependencies(_klass)
|
|
9
|
-
require "stringio"
|
|
10
|
-
require "zlib"
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
def configure(klass)
|
|
14
|
-
klass.plugin(:"compression/gzip")
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
def extra_options(options)
|
|
18
|
-
options.merge(encodings: options.encodings.merge("deflate" => self))
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
module Deflater
|
|
23
|
-
module_function
|
|
24
|
-
|
|
25
|
-
def deflate(raw, buffer = "".b, chunk_size: 16_384)
|
|
26
|
-
deflater = Zlib::Deflate.new
|
|
27
|
-
while (chunk = raw.read(chunk_size))
|
|
28
|
-
compressed = deflater.deflate(chunk)
|
|
29
|
-
buffer << compressed
|
|
30
|
-
yield compressed if block_given?
|
|
31
|
-
end
|
|
32
|
-
last = deflater.finish
|
|
33
|
-
buffer << last
|
|
34
|
-
yield last if block_given?
|
|
35
|
-
buffer
|
|
36
|
-
ensure
|
|
37
|
-
deflater.close if deflater
|
|
38
|
-
end
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
module_function
|
|
42
|
-
|
|
43
|
-
def deflater
|
|
44
|
-
Deflater
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def inflater(bytesize)
|
|
48
|
-
GZIP::Inflater.new(bytesize)
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
register_plugin :"compression/deflate", Compression::Deflate
|
|
53
|
-
end
|
|
54
|
-
end
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require "forwardable"
|
|
4
|
-
|
|
5
|
-
module HTTPX
|
|
6
|
-
module Plugins
|
|
7
|
-
module Compression
|
|
8
|
-
module GZIP
|
|
9
|
-
class << self
|
|
10
|
-
def load_dependencies(*)
|
|
11
|
-
require "zlib"
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def extra_options(options)
|
|
15
|
-
options.merge(encodings: options.encodings.merge("gzip" => self))
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
class Deflater
|
|
20
|
-
def initialize
|
|
21
|
-
@compressed_chunk = "".b
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def deflate(raw, buffer = "".b, chunk_size: 16_384)
|
|
25
|
-
gzip = Zlib::GzipWriter.new(self)
|
|
26
|
-
|
|
27
|
-
begin
|
|
28
|
-
while (chunk = raw.read(chunk_size))
|
|
29
|
-
gzip.write(chunk)
|
|
30
|
-
gzip.flush
|
|
31
|
-
compressed = compressed_chunk
|
|
32
|
-
buffer << compressed
|
|
33
|
-
yield compressed if block_given?
|
|
34
|
-
end
|
|
35
|
-
ensure
|
|
36
|
-
gzip.close
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
return unless (compressed = compressed_chunk)
|
|
40
|
-
|
|
41
|
-
buffer << compressed
|
|
42
|
-
yield compressed if block_given?
|
|
43
|
-
buffer
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
private
|
|
47
|
-
|
|
48
|
-
def write(chunk)
|
|
49
|
-
@compressed_chunk << chunk
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def compressed_chunk
|
|
53
|
-
@compressed_chunk.dup
|
|
54
|
-
ensure
|
|
55
|
-
@compressed_chunk.clear
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
class Inflater
|
|
60
|
-
def initialize(bytesize)
|
|
61
|
-
@inflater = Zlib::Inflate.new(Zlib::MAX_WBITS + 32)
|
|
62
|
-
@bytesize = bytesize
|
|
63
|
-
@buffer = nil
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def inflate(chunk)
|
|
67
|
-
buffer = @inflater.inflate(chunk)
|
|
68
|
-
@bytesize -= chunk.bytesize
|
|
69
|
-
if @bytesize <= 0
|
|
70
|
-
buffer << @inflater.finish
|
|
71
|
-
@inflater.close
|
|
72
|
-
end
|
|
73
|
-
buffer
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
module_function
|
|
78
|
-
|
|
79
|
-
def deflater
|
|
80
|
-
Deflater.new
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def inflater(bytesize)
|
|
84
|
-
Inflater.new(bytesize)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
register_plugin :"compression/gzip", Compression::GZIP
|
|
89
|
-
end
|
|
90
|
-
end
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module HTTPX
|
|
4
|
-
module Plugins
|
|
5
|
-
#
|
|
6
|
-
# This plugin adds compression support. Namely it:
|
|
7
|
-
#
|
|
8
|
-
# * Compresses the request body when passed a supported "Content-Encoding" mime-type;
|
|
9
|
-
# * Decompresses the response body from a supported "Content-Encoding" mime-type;
|
|
10
|
-
#
|
|
11
|
-
# It supports both *gzip* and *deflate*.
|
|
12
|
-
#
|
|
13
|
-
# https://gitlab.com/os85/httpx/wikis/Compression
|
|
14
|
-
#
|
|
15
|
-
module Compression
|
|
16
|
-
class << self
|
|
17
|
-
def configure(klass)
|
|
18
|
-
klass.plugin(:"compression/gzip")
|
|
19
|
-
klass.plugin(:"compression/deflate")
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def extra_options(options)
|
|
23
|
-
options.merge(encodings: {})
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
module OptionsMethods
|
|
28
|
-
def option_compression_threshold_size(value)
|
|
29
|
-
bytes = Integer(value)
|
|
30
|
-
raise TypeError, ":compression_threshold_size must be positive" unless bytes.positive?
|
|
31
|
-
|
|
32
|
-
bytes
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def option_encodings(value)
|
|
36
|
-
raise TypeError, ":encodings must be an Hash" unless value.is_a?(Hash)
|
|
37
|
-
|
|
38
|
-
value
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
module RequestMethods
|
|
43
|
-
def initialize(*)
|
|
44
|
-
super
|
|
45
|
-
# forego compression in the Range cases
|
|
46
|
-
if @headers.key?("range")
|
|
47
|
-
@headers.delete("accept-encoding")
|
|
48
|
-
else
|
|
49
|
-
@headers["accept-encoding"] ||= @options.encodings.keys
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|
|
53
|
-
|
|
54
|
-
module RequestBodyMethods
|
|
55
|
-
def initialize(*, options)
|
|
56
|
-
super
|
|
57
|
-
return if @body.nil?
|
|
58
|
-
|
|
59
|
-
threshold = options.compression_threshold_size
|
|
60
|
-
return if threshold && !unbounded_body? && @body.bytesize < threshold
|
|
61
|
-
|
|
62
|
-
@headers.get("content-encoding").each do |encoding|
|
|
63
|
-
next if encoding == "identity"
|
|
64
|
-
|
|
65
|
-
next unless options.encodings.key?(encoding)
|
|
66
|
-
|
|
67
|
-
@body = Encoder.new(@body, options.encodings[encoding].deflater)
|
|
68
|
-
end
|
|
69
|
-
@headers["content-length"] = @body.bytesize unless unbounded_body?
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
module ResponseBodyMethods
|
|
74
|
-
using ArrayExtensions::FilterMap
|
|
75
|
-
|
|
76
|
-
attr_reader :encodings
|
|
77
|
-
|
|
78
|
-
def initialize(*)
|
|
79
|
-
@encodings = []
|
|
80
|
-
|
|
81
|
-
super
|
|
82
|
-
|
|
83
|
-
return unless @headers.key?("content-encoding")
|
|
84
|
-
|
|
85
|
-
# remove encodings that we are able to decode
|
|
86
|
-
@headers["content-encoding"] = @headers.get("content-encoding") - @encodings
|
|
87
|
-
|
|
88
|
-
compressed_length = if @headers.key?("content-length")
|
|
89
|
-
@headers["content-length"].to_i
|
|
90
|
-
else
|
|
91
|
-
Float::INFINITY
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
@_inflaters = @headers.get("content-encoding").filter_map do |encoding|
|
|
95
|
-
next if encoding == "identity"
|
|
96
|
-
|
|
97
|
-
next unless @options.encodings.key?(encoding)
|
|
98
|
-
|
|
99
|
-
inflater = @options.encodings[encoding].inflater(compressed_length)
|
|
100
|
-
# do not uncompress if there is no decoder available. In fact, we can't reliably
|
|
101
|
-
# continue decompressing beyond that, so ignore.
|
|
102
|
-
break unless inflater
|
|
103
|
-
|
|
104
|
-
@encodings << encoding
|
|
105
|
-
inflater
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
# this can happen if the only declared encoding is "identity"
|
|
109
|
-
remove_instance_variable(:@_inflaters) if @_inflaters.empty?
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
def write(chunk)
|
|
113
|
-
return super unless defined?(@_inflaters) && !chunk.empty?
|
|
114
|
-
|
|
115
|
-
chunk = decompress(chunk)
|
|
116
|
-
super(chunk)
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
private
|
|
120
|
-
|
|
121
|
-
def decompress(buffer)
|
|
122
|
-
@_inflaters.reverse_each do |inflater|
|
|
123
|
-
buffer = inflater.inflate(buffer)
|
|
124
|
-
end
|
|
125
|
-
buffer
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
class Encoder
|
|
130
|
-
attr_reader :content_type
|
|
131
|
-
|
|
132
|
-
def initialize(body, deflater)
|
|
133
|
-
@content_type = body.content_type
|
|
134
|
-
@body = body.respond_to?(:read) ? body : StringIO.new(body.to_s)
|
|
135
|
-
@buffer = StringIO.new("".b, File::RDWR)
|
|
136
|
-
@deflater = deflater
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def each(&blk)
|
|
140
|
-
return enum_for(__method__) unless blk
|
|
141
|
-
|
|
142
|
-
return deflate(&blk) if @buffer.size.zero? # rubocop:disable Style/ZeroLengthPredicate
|
|
143
|
-
|
|
144
|
-
@buffer.rewind
|
|
145
|
-
@buffer.each(&blk)
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
def bytesize
|
|
149
|
-
deflate
|
|
150
|
-
@buffer.size
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
private
|
|
154
|
-
|
|
155
|
-
def deflate(&blk)
|
|
156
|
-
return unless @buffer.size.zero? # rubocop:disable Style/ZeroLengthPredicate
|
|
157
|
-
|
|
158
|
-
@body.rewind
|
|
159
|
-
@deflater.deflate(@body, @buffer, chunk_size: 16_384, &blk)
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
end
|
|
163
|
-
register_plugin :compression, Compression
|
|
164
|
-
end
|
|
165
|
-
end
|