httpx 0.24.7 → 1.0.0

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.
Files changed (132) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +0 -48
  3. data/README.md +4 -13
  4. data/doc/release_notes/0_24_4.md +3 -3
  5. data/doc/release_notes/1_0_0.md +60 -0
  6. data/lib/httpx/adapters/datadog.rb +40 -141
  7. data/lib/httpx/adapters/faraday.rb +9 -52
  8. data/lib/httpx/adapters/webmock.rb +2 -7
  9. data/lib/httpx/altsvc.rb +4 -22
  10. data/lib/httpx/base64.rb +27 -0
  11. data/lib/httpx/chainable.rb +0 -23
  12. data/lib/httpx/connection.rb +11 -32
  13. data/lib/httpx/domain_name.rb +5 -12
  14. data/lib/httpx/errors.rb +0 -2
  15. data/lib/httpx/extensions.rb +0 -124
  16. data/lib/httpx/io/ssl.rb +26 -59
  17. data/lib/httpx/io/tcp.rb +27 -68
  18. data/lib/httpx/io/udp.rb +13 -48
  19. data/lib/httpx/io/unix.rb +1 -8
  20. data/lib/httpx/loggable.rb +4 -19
  21. data/lib/httpx/options.rb +24 -84
  22. data/lib/httpx/plugins/{authentication → auth}/basic.rb +1 -5
  23. data/lib/httpx/plugins/{authentication → auth}/digest.rb +2 -5
  24. data/lib/httpx/plugins/{authentication → auth}/ntlm.rb +1 -3
  25. data/lib/httpx/plugins/{authentication → auth}/socks5.rb +0 -2
  26. data/lib/httpx/plugins/auth.rb +25 -0
  27. data/lib/httpx/plugins/aws_sigv4.rb +0 -1
  28. data/lib/httpx/plugins/{basic_authentication.rb → basic_auth.rb} +5 -6
  29. data/lib/httpx/plugins/brotli.rb +50 -0
  30. data/lib/httpx/plugins/circuit_breaker/circuit.rb +40 -16
  31. data/lib/httpx/plugins/circuit_breaker/circuit_store.rb +16 -5
  32. data/lib/httpx/plugins/circuit_breaker.rb +11 -4
  33. data/lib/httpx/plugins/cookies/set_cookie_parser.rb +0 -2
  34. data/lib/httpx/plugins/cookies.rb +1 -1
  35. data/lib/httpx/plugins/{digest_authentication.rb → digest_auth.rb} +5 -5
  36. data/lib/httpx/plugins/follow_redirects.rb +21 -24
  37. data/lib/httpx/plugins/grpc/grpc_encoding.rb +82 -0
  38. data/lib/httpx/plugins/grpc/message.rb +7 -39
  39. data/lib/httpx/plugins/grpc.rb +19 -37
  40. data/lib/httpx/plugins/h2c.rb +0 -1
  41. data/lib/httpx/plugins/{ntlm_authentication.rb → ntlm_auth.rb} +5 -5
  42. data/lib/httpx/plugins/oauth.rb +2 -2
  43. data/lib/httpx/plugins/proxy/http.rb +0 -2
  44. data/lib/httpx/plugins/proxy/socks4.rb +0 -4
  45. data/lib/httpx/plugins/proxy/socks5.rb +1 -5
  46. data/lib/httpx/plugins/proxy.rb +3 -32
  47. data/lib/httpx/plugins/retries.rb +3 -4
  48. data/lib/httpx/plugins/stream.rb +4 -6
  49. data/lib/httpx/punycode.rb +9 -291
  50. data/lib/httpx/request/body.rb +145 -0
  51. data/lib/httpx/request.rb +2 -119
  52. data/lib/httpx/resolver/https.rb +1 -1
  53. data/lib/httpx/resolver/native.rb +6 -14
  54. data/lib/httpx/resolver/resolver.rb +1 -1
  55. data/lib/httpx/resolver/system.rb +11 -9
  56. data/lib/httpx/response/body.rb +206 -0
  57. data/lib/httpx/response/buffer.rb +90 -0
  58. data/lib/httpx/response.rb +5 -208
  59. data/lib/httpx/selector.rb +0 -2
  60. data/lib/httpx/session.rb +0 -10
  61. data/lib/httpx/transcoder/body.rb +0 -1
  62. data/lib/httpx/transcoder/deflate.rb +37 -0
  63. data/lib/httpx/transcoder/form.rb +52 -32
  64. data/lib/httpx/transcoder/gzip.rb +74 -0
  65. data/lib/httpx/transcoder/json.rb +2 -4
  66. data/lib/httpx/transcoder/multipart/decoder.rb +139 -0
  67. data/lib/httpx/{plugins → transcoder}/multipart/encoder.rb +3 -3
  68. data/lib/httpx/{plugins → transcoder}/multipart/mime_type_detector.rb +1 -1
  69. data/lib/httpx/{plugins → transcoder}/multipart/part.rb +3 -2
  70. data/lib/httpx/transcoder/multipart.rb +17 -0
  71. data/lib/httpx/transcoder/utils/body_reader.rb +46 -0
  72. data/lib/httpx/transcoder/utils/deflater.rb +72 -0
  73. data/lib/httpx/transcoder/xml.rb +0 -2
  74. data/lib/httpx/transcoder.rb +2 -2
  75. data/lib/httpx/utils.rb +10 -20
  76. data/lib/httpx/version.rb +1 -1
  77. data/lib/httpx.rb +0 -8
  78. data/sig/chainable.rbs +5 -6
  79. data/sig/connection.rbs +0 -1
  80. data/sig/errors.rbs +0 -3
  81. data/sig/httpx.rbs +2 -1
  82. data/sig/io/unix.rbs +1 -1
  83. data/sig/options.rbs +12 -8
  84. data/sig/plugins/{authentication → auth}/basic.rbs +0 -2
  85. data/sig/plugins/auth.rbs +13 -0
  86. data/sig/plugins/{basic_authentication.rbs → basic_auth.rbs} +2 -2
  87. data/sig/plugins/brotli.rbs +22 -0
  88. data/sig/plugins/circuit_breaker.rbs +7 -3
  89. data/sig/plugins/compression.rbs +0 -2
  90. data/sig/plugins/{digest_authentication.rbs → digest_auth.rbs} +2 -2
  91. data/sig/plugins/follow_redirects.rbs +0 -1
  92. data/sig/plugins/grpc/call.rbs +19 -0
  93. data/sig/plugins/grpc/grpc_encoding.rbs +33 -0
  94. data/sig/plugins/grpc/message.rbs +17 -0
  95. data/sig/plugins/grpc.rbs +2 -32
  96. data/sig/plugins/{ntlm_authentication.rbs → ntlm_auth.rbs} +2 -2
  97. data/sig/plugins/oauth.rbs +1 -1
  98. data/sig/plugins/proxy/socks4.rbs +2 -3
  99. data/sig/plugins/proxy/socks5.rbs +0 -1
  100. data/sig/plugins/proxy/ssh.rbs +1 -1
  101. data/sig/plugins/response_cache.rbs +5 -2
  102. data/sig/request/body.rbs +42 -0
  103. data/sig/request.rbs +1 -27
  104. data/sig/resolver/resolver.rbs +1 -1
  105. data/sig/response/body.rbs +52 -0
  106. data/sig/response/buffer.rbs +24 -0
  107. data/sig/response.rbs +0 -39
  108. data/sig/transcoder/body.rbs +4 -3
  109. data/sig/transcoder/deflate.rbs +11 -0
  110. data/sig/transcoder/form.rbs +5 -3
  111. data/sig/transcoder/gzip.rbs +24 -0
  112. data/sig/transcoder/json.rbs +4 -2
  113. data/sig/{plugins → transcoder}/multipart.rbs +3 -10
  114. data/sig/transcoder/utils/body_reader.rbs +15 -0
  115. data/sig/transcoder/utils/deflater.rbs +29 -0
  116. data/sig/transcoder.rbs +18 -2
  117. metadata +50 -36
  118. data/doc/release_notes/0_24_7.md +0 -10
  119. data/lib/httpx/plugins/authentication.rb +0 -24
  120. data/lib/httpx/plugins/compression/brotli.rb +0 -54
  121. data/lib/httpx/plugins/compression/deflate.rb +0 -54
  122. data/lib/httpx/plugins/compression/gzip.rb +0 -90
  123. data/lib/httpx/plugins/compression.rb +0 -165
  124. data/lib/httpx/plugins/multipart/decoder.rb +0 -137
  125. data/lib/httpx/plugins/multipart.rb +0 -96
  126. data/sig/plugins/authentication.rbs +0 -13
  127. data/sig/plugins/compression/brotli.rbs +0 -21
  128. data/sig/plugins/compression/deflate.rbs +0 -17
  129. data/sig/plugins/compression/gzip.rbs +0 -29
  130. /data/sig/plugins/{authentication → auth}/digest.rbs +0 -0
  131. /data/sig/plugins/{authentication → auth}/ntlm.rbs +0 -0
  132. /data/sig/plugins/{authentication → auth}/socks5.rbs +0 -0
@@ -0,0 +1,22 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Brotli
4
+ def self?.load_dependencies: (singleton(Session)) -> void
5
+
6
+ def self?.encode: (body_encoder body) -> Deflater
7
+
8
+ def self?.decode: (HTTPX::Response response, ?bytesize: Integer) -> Transcoder::_Decoder
9
+
10
+ class Deflater < Transcoder::Deflater
11
+ end
12
+
13
+ module RequestBodyClassMethods
14
+ def initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
15
+ end
16
+
17
+ module ResponseBodyClassMethods
18
+ def initialize_inflater_by_encoding: (Encoding | String encoding, Response response, ?bytesize: Integer) -> (Transcoder::_Decoder | Transcoder::GZIP::Inflater)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -3,15 +3,17 @@ module HTTPX
3
3
  module CircuitBreaker
4
4
 
5
5
  class CircuitStore
6
- @circuits: Hash[String, Circuit]
6
+ @circuits: Hash[String, Circuit] & Mutex_m
7
7
 
8
- def try_open: (generic_uri uri, response response) -> response?
8
+ def try_open: (uri uri, response response) -> response?
9
9
 
10
10
  def try_respond: (Request request) -> response?
11
11
 
12
+ def try_close: (http_uri uri) -> void
13
+
12
14
  private
13
15
 
14
- def get_circuit_for_uri: (generic_uri uri) -> Circuit
16
+ def get_circuit_for_uri: (uri uri) -> Circuit
15
17
 
16
18
  def initialize: (Options & _CircuitOptions options) -> void
17
19
  end
@@ -23,6 +25,8 @@ module HTTPX
23
25
  @break_in: Float
24
26
  @circuit_breaker_half_open_drip_rate: Float
25
27
  @attempts: Integer
28
+ @real_attempts: Integer
29
+ @drip_factor: Integer
26
30
 
27
31
  @response: response?
28
32
  @opened_at: Float?
@@ -23,8 +23,6 @@ module HTTPX
23
23
  def self.configure: (singleton(Session)) -> void
24
24
 
25
25
  interface _CompressionOptions
26
- def compression_threshold_size: () -> Integer?
27
-
28
26
  def encodings: () -> Hash[String, _Compressor]
29
27
  end
30
28
 
@@ -12,10 +12,10 @@ module HTTPX
12
12
  def self.load_dependencies: (*untyped) -> void
13
13
 
14
14
  module InstanceMethods
15
- def digest_authentication: (string user, string password, ?hashed: bool) -> instance
15
+ def digest_auth: (string user, string password, ?hashed: bool) -> instance
16
16
  end
17
17
  end
18
18
 
19
- type sessionDigestAuth = sessionAuthentication & DigestAuth::InstanceMethods
19
+ type sessionDigestAuth = sessionAuthorization & DigestAuth::InstanceMethods
20
20
  end
21
21
  end
@@ -17,7 +17,6 @@ module HTTPX
17
17
  module InstanceMethods
18
18
  def max_redirects: (_ToI) -> instance
19
19
 
20
- def build_redirect_request: (Request, Response, Options) -> Request
21
20
  def __get_location_from_response: (Response) -> (URI::HTTP | URI::HTTPS)
22
21
  end
23
22
 
@@ -0,0 +1,19 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module GRPC
4
+ class Call
5
+ attr_writer decoder: _Callable
6
+
7
+ def metadata: () -> headers
8
+
9
+ def trailing_metadata: () -> headers?
10
+
11
+ private
12
+
13
+ def initialize: (Response | StreamResponse response) -> untyped
14
+
15
+ def grpc_response: () -> grpc_response
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,33 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ module GRPCEncoding
4
+
5
+ def self?.encode: (body_encoder body, compressed: bool) -> Deflater
6
+
7
+ def self?.decode: (Response | StreamResponse response) -> Inflater
8
+
9
+ class Deflater
10
+ attr_reader content_type: String
11
+
12
+ @body: BodyReader
13
+ @compressed: bool
14
+
15
+ def initialize: (body_encoder body, compressed: bool) -> void
16
+
17
+ def bytesize: () -> (Integer | Float)
18
+
19
+ def read: (?int? length, ?string outbuf) -> String?
20
+ end
21
+
22
+ class Inflater
23
+ @response: Response
24
+ @encodings: Array[String]
25
+
26
+ def initialize: (Response | StreamResponse response) -> void
27
+
28
+ def call: (String message) ?{ (String) -> void } -> String
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,17 @@
1
+
2
+ module HTTPX
3
+ module Plugins
4
+ module GRPC
5
+ module Message
6
+ def self?.unary: (response) -> grpc_message
7
+
8
+ def self?.stream: (StreamResponse) { (String) -> void } -> void
9
+ | (StreamResponse) -> Enumerable[String]
10
+
11
+ def self?.cancel: (Request) -> void
12
+
13
+ def self?.verify_status: (StreamResponse | response) -> void
14
+ end
15
+ end
16
+ end
17
+ end
data/sig/plugins/grpc.rbs CHANGED
@@ -17,36 +17,6 @@ module HTTPX
17
17
 
18
18
  type credentials = Proc
19
19
 
20
- class Call
21
- attr_writer decoder: _Callable
22
-
23
- def metadata: () -> headers
24
-
25
- def trailing_metadata: () -> headers?
26
-
27
- private
28
-
29
- def initialize: (Response | StreamResponse response) -> untyped
30
-
31
- def grpc_response: () -> grpc_response
32
- end
33
-
34
- module Message
35
- def self?.unary: (response) -> grpc_message
36
-
37
- def self?.stream: (StreamResponse) { (String) -> void } -> void
38
- | (StreamResponse) -> Enumerable[String]
39
-
40
- def self?.encode: (String bytes, ?deflater: Compression::_Deflater?) -> String
41
-
42
- def self?.decode: (String message, encodings: Array[String], encoders: Hash[String, Compression::_Compressor]) -> String
43
- | (String message, encodings: Array[String], encoders: Hash[String, Compression::_Compressor]) { (String) -> void } -> void
44
-
45
- def self?.cancel: (Request) -> void
46
-
47
- def self?.verify_status: (StreamResponse | response) -> void
48
- end
49
-
50
20
  interface _GRPCOptions
51
21
  def grpc_service: () -> String?
52
22
 
@@ -63,9 +33,9 @@ module HTTPX
63
33
  def self.load_dependencies: (singleton(Session)) -> void
64
34
 
65
35
  module ResponseMethods
66
- def merge_headers: (headers_input trailers) -> void
36
+ attr_reader trailing_metadata: Hash[String, untyped]
67
37
 
68
- def encoders: () -> Hash[String, Compression::_Compressor]
38
+ def encoders: () -> Array[String | Encoding]
69
39
  end
70
40
 
71
41
  module InstanceMethods
@@ -11,11 +11,11 @@ module HTTPX
11
11
  def self.load_dependencies: (*untyped) -> void
12
12
 
13
13
  module InstanceMethods
14
- def ntlm_authentication: (string user, string password, ?string? domain) -> instance
14
+ def ntlm_auth: (string user, string password, ?string? domain) -> instance
15
15
  end
16
16
 
17
17
  end
18
18
 
19
- type sessionNTLMAuth = sessionAuthentication & NTLMAuth::InstanceMethods
19
+ type sessionNTLMAuth = sessionAuthorization & NTLMAuth::InstanceMethods
20
20
  end
21
21
  end
@@ -43,7 +43,7 @@ module HTTPX
43
43
  end
44
44
 
45
45
  module InstanceMethods
46
- def oauth_authentication: (**untyped args) -> instance
46
+ def oauth_auth: (**untyped args) -> instance
47
47
 
48
48
  def with_access_token: () -> instance
49
49
  end
@@ -4,17 +4,16 @@ module HTTPX
4
4
  module Plugins
5
5
  module Proxy
6
6
  module Socks4
7
-
7
+
8
8
  module ConnectionMethods
9
9
  def __socks4_proxy_connect: () -> void
10
10
  def __socks4_on_packet: (String packet) -> void
11
11
  def on_socks4_error: (string) -> void
12
12
  end
13
-
13
+
14
14
  class SocksParser
15
15
  include Callbacks
16
16
 
17
- def timeout: () -> Integer
18
17
  def close: () -> void
19
18
  def consume: (*untyped) -> void
20
19
  def empty: () -> bool
@@ -16,7 +16,6 @@ module HTTPX
16
16
  class SocksParser
17
17
  include Callbacks
18
18
 
19
- def timeout: () -> Integer
20
19
  def close: () -> void
21
20
  def consume: (*untyped) -> void
22
21
  def empty: () -> bool
@@ -7,7 +7,7 @@ module HTTPX
7
7
  module InstanceMethods
8
8
  private
9
9
 
10
- def build_gateway_socket: (int, URI::HTTP | URI::HTTPS, Options) -> _ToIO
10
+ def build_gateway_socket: (int, http_uri, Options) -> _ToIO
11
11
  end
12
12
  end
13
13
  end
@@ -2,9 +2,10 @@ module HTTPX
2
2
  module Plugins
3
3
  module ResponseCache
4
4
  CACHEABLE_VERBS: Array[verb]
5
+ CACHEABLE_STATUS_CODES: Array[Integer]
5
6
 
6
- def self?.cacheable_request?: (Request request) -> bool
7
- def self?.cacheable_response?: (response response) -> bool
7
+ def self?.cacheable_request?: (Request & RequestMethods request) -> bool
8
+ def self?.cacheable_response?: (::HTTPX::ErrorResponse | (Response & ResponseMethods) response) -> bool
8
9
  def self?.cached_response?: (response response) -> bool
9
10
 
10
11
  class Store
@@ -34,6 +35,8 @@ module HTTPX
34
35
  end
35
36
 
36
37
  module RequestMethods
38
+ @response_cache_key: String
39
+
37
40
  def response_cache_key: () -> String
38
41
  end
39
42
 
@@ -0,0 +1,42 @@
1
+ module HTTPX
2
+ class Request::Body
3
+ attr_reader threshold_size: Integer?
4
+
5
+ @headers: Headers
6
+ @body: body_encoder?
7
+ @unbounded_body: bool
8
+
9
+ def initialize: (Headers headers, Options options) -> void
10
+
11
+ def each: () { (String) -> void } -> void
12
+ | () -> Enumerable[String]
13
+
14
+ def rewind: () -> void
15
+
16
+ def empty?: () -> bool
17
+
18
+ def bytesize: () -> (Integer | Float)
19
+
20
+ def stream: (Transcoder::_Encoder) -> bodyIO
21
+
22
+ def unbounded_body?: () -> bool
23
+
24
+ def chunked?: () -> bool
25
+
26
+ def chunk!: () -> void
27
+
28
+ private
29
+
30
+ def initialize_body: (Options options) -> void
31
+
32
+ def self.initialize_deflater_body: (body_encoder body, Encoding | String encoding) -> body_encoder
33
+ end
34
+
35
+ class ProcIO
36
+ @block: ^(String) -> void
37
+
38
+ def initialize: (^(String) -> void) -> untyped
39
+
40
+ def write: (String data) -> Integer
41
+ end
42
+ end
data/sig/request.rbs CHANGED
@@ -7,7 +7,7 @@ module HTTPX
7
7
  USER_AGENT: String
8
8
 
9
9
  attr_reader verb: verb
10
- attr_reader uri: URI::HTTP | URI::HTTPS
10
+ attr_reader uri: http_uri
11
11
  attr_reader headers: Headers
12
12
  attr_reader body: Body
13
13
  attr_reader state: Symbol
@@ -60,31 +60,5 @@ module HTTPX
60
60
 
61
61
  def initialize_body: (Options options) -> Transcoder::_Encoder?
62
62
 
63
- class Body
64
- @headers: Headers
65
- @body: body_encoder?
66
- @unbounded_body: bool
67
-
68
- def initialize: (Headers, Options) -> untyped
69
- def each: () { (String) -> void } -> void
70
- | () -> Enumerable[String]
71
-
72
- def rewind: () -> void
73
- def empty?: () -> bool
74
- def bytesize: () -> (Integer | Float)
75
- def stream: (Transcoder::_Encoder) -> bodyIO
76
- def unbounded_body?: () -> bool
77
- def chunked?: () -> bool
78
- def chunk!: () -> void
79
- def inspect: () -> String
80
- end
81
-
82
- class ProcIO
83
- @block: ^(String) -> void
84
-
85
- def initialize: (^(String) -> void) -> untyped
86
-
87
- def write: (String data) -> Integer
88
- end
89
63
  end
90
64
  end
@@ -30,7 +30,7 @@ module HTTPX
30
30
 
31
31
  def emit_resolve_error: (Connection connection, ?String hostname, ?StandardError) -> void
32
32
 
33
- def resolve_error: (String hostname, ?StandardError?) -> ResolveError
33
+ def resolve_error: (String hostname, ?StandardError?) -> (ResolveError | ResolveTimeoutError)
34
34
  end
35
35
  end
36
36
  end
@@ -0,0 +1,52 @@
1
+ module HTTPX
2
+ class Response::Body
3
+ include _Reader
4
+ include _ToS
5
+ include _ToStr
6
+
7
+ attr_reader encoding: Encoding | String
8
+ attr_reader encodings: Array[Encoding | String]
9
+
10
+ @response: Response
11
+ @headers: Headers
12
+ @options: Options
13
+ @state: :idle | :memory | :buffer | :closed
14
+ @threshold_size: Integer
15
+ @window_size: Integer
16
+ @length: Integer
17
+ @buffer: StringIO | Tempfile | nil
18
+ @reader: StringIO | Tempfile | nil
19
+ @inflaters: Array[Transcoder::_Inflater]
20
+
21
+ def initialize: (Response, Options) -> void
22
+
23
+ def closed?: () -> bool
24
+
25
+ def write:(String chunk) -> Integer?
26
+
27
+ def filename: () -> String?
28
+
29
+ def bytesize: () -> Integer
30
+
31
+ def each: () { (String) -> void } -> void
32
+ | () -> Enumerable[String]
33
+
34
+ def empty?: () -> bool
35
+
36
+ def copy_to: (String | File | _Writer destination) -> void
37
+
38
+ def close: () -> void
39
+
40
+ def rewind: () -> void
41
+
42
+ private
43
+
44
+ def initialize_inflaters: () -> void
45
+
46
+ def self.initialize_inflater_by_encoding: (Encoding | String encoding, Response response, ?bytesize: Integer) -> Transcoder::GZIP::Inflater
47
+
48
+ def transition: (Symbol nextstate) -> void
49
+
50
+ def _with_same_buffer_pos: [A] () { () -> A } -> A
51
+ end
52
+ end
@@ -0,0 +1,24 @@
1
+ module HTTPX
2
+ class Response::Buffer
3
+ @threshold_size: Integer
4
+ @bytesize: Integer
5
+ @encoding: Encoding
6
+ @buffer: StringIO | Tempfile
7
+
8
+ def initialize: (threshold_size: Integer, ?bytesize: Integer, ?encoding: Encoding | String) -> void
9
+
10
+ def size: () -> Integer
11
+
12
+ def write: (String) -> void
13
+
14
+ def to_s: () -> String
15
+
16
+ def close: () -> void
17
+
18
+ private
19
+
20
+ def try_upgrade_buffer: () -> void
21
+
22
+ def _with_same_buffer_pos: () { () -> void } -> void
23
+ end
24
+ end
data/sig/response.rbs CHANGED
@@ -43,45 +43,6 @@ module HTTPX
43
43
  def no_data?: () -> bool
44
44
 
45
45
  def decode:(Transcoder::_Decode transcoder, ?untyped options) -> untyped
46
-
47
- class Body
48
- include _Reader
49
- include _ToS
50
- include _ToStr
51
-
52
- attr_reader encoding: Encoding | String
53
-
54
- @response: Response
55
- @headers: Headers
56
- @options: Options
57
- @state: :idle | :memory | :buffer | :closed
58
- @threshold_size: Integer
59
- @window_size: Integer
60
- @length: Integer
61
- @buffer: StringIO | Tempfile | nil
62
- @reader: StringIO | Tempfile | nil
63
-
64
- def write:(String chunk) -> Integer?
65
-
66
- def each: () { (String) -> void } -> void
67
- | () -> Enumerable[String]
68
-
69
- def filename: () -> String?
70
-
71
- def bytesize: () -> (Integer | Float)
72
- def empty?: () -> bool
73
- def copy_to: (String | File | _Writer destination) -> void
74
- def close: () -> void
75
- def closed?: () -> bool
76
-
77
- def rewind: () -> void
78
-
79
- private
80
-
81
- def initialize: (Response, Options) -> void
82
- def transition: () -> void
83
- def _with_same_buffer_pos: [A] () { () -> A } -> A
84
- end
85
46
  end
86
47
 
87
48
  class ContentType
@@ -7,13 +7,14 @@ module HTTPX
7
7
  class Encoder
8
8
  extend Forwardable
9
9
 
10
- include _Encoder
11
- include _ToS
12
-
13
10
  @raw: bodyIO
14
11
 
12
+ def bytesize: () -> (Integer | Float)
13
+
15
14
  def content_type: () -> String
16
15
 
16
+ def to_s: () -> String
17
+
17
18
  private
18
19
 
19
20
  def initialize: (untyped body) -> untyped
@@ -0,0 +1,11 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ module Deflate
4
+ def self?.encode: (_Encoder body) -> Deflater
5
+ def self?.decode: (Response body, ?bytesize: Integer) -> GZIP::Inflater
6
+
7
+ class Deflater < Transcoder::Deflater
8
+ end
9
+ end
10
+ end
11
+ end
@@ -3,17 +3,19 @@ module HTTPX::Transcoder
3
3
 
4
4
  type form_nested_value = form_value | _ToAry[form_value] | _ToHash[string, form_value]
5
5
 
6
- type urlencoded_input = Enumerable[[_ToS, form_nested_value]]
6
+ type urlencoded_input = Enumerable[[_ToS, form_nested_value | Multipart::multipart_nested_value]]
7
7
 
8
8
  module Form
9
- def self?.encode: (urlencoded_input form) -> Encoder
9
+ def self?.encode: (urlencoded_input form) -> (Encoder | Multipart::Encoder)
10
10
  def self?.decode: (HTTPX::Response response) -> _Decoder
11
+ def self?.multipart?: (form_nested_value | Multipart::multipart_nested_value data) -> bool
11
12
 
12
13
  class Encoder
13
14
  extend Forwardable
14
- include _Encoder
15
15
  include _ToS
16
16
 
17
+ def bytesize: () -> Integer
18
+
17
19
  def content_type: () -> String
18
20
 
19
21
  private
@@ -0,0 +1,24 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ module GZIP
4
+ def self?.encode: (_Encoder body) -> Deflater
5
+ def self?.decode: (Response response, ?bytesize: Integer) -> Inflater
6
+
7
+ class Deflater < Transcoder::Deflater
8
+ @compressed_chunk: String
9
+
10
+ private
11
+
12
+ def write: (String chunk) -> void
13
+
14
+ def compressed_chunk: () -> String
15
+ end
16
+
17
+ class Inflater
18
+ def initialize: (Integer | Float bytesize) -> void
19
+
20
+ def call: (String chunk) -> String
21
+ end
22
+ end
23
+ end
24
+ end
@@ -10,14 +10,16 @@ module HTTPX::Transcoder
10
10
 
11
11
  class Encoder
12
12
  extend Forwardable
13
- include _Encoder
14
- include _ToS
15
13
 
16
14
  @raw: String
17
15
  @charset: String
18
16
 
17
+ def bytesize: () -> Integer
18
+
19
19
  def content_type: () -> String
20
20
 
21
+ def to_s: () -> String
22
+
21
23
  private
22
24
 
23
25
  def initialize: (_ToJson json) -> void
@@ -1,5 +1,5 @@
1
1
  module HTTPX
2
- module Plugins
2
+ module Transcoder
3
3
  module Multipart
4
4
  interface _MultipartInput
5
5
  def filename: () -> String
@@ -9,13 +9,6 @@ module HTTPX
9
9
 
10
10
  MULTIPART_VALUE_COND: ^(_Reader | record_multipart_value value) -> bool
11
11
 
12
- def self.load_dependencies: (singleton(Session)) -> void
13
- def self.configure: (*untyped) -> void
14
- def self?.encode: (untyped) -> (Encoder | Transcoder::Form::Encoder)
15
- def self?.decode: (HTTPX::Response response) -> Transcoder::_Decoder
16
-
17
- def self?.normalize_keys: [U] (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value) { (String, ?untyped) -> U } -> U
18
-
19
12
  type multipart_value = string | Pathname | File | _Reader
20
13
 
21
14
  type record_multipart_value = { content_type: String, filename: String, body: multipart_value } |
@@ -24,8 +17,6 @@ module HTTPX
24
17
  type multipart_nested_value = multipart_value | _ToAry[multipart_value] | _ToHash[string, multipart_value]
25
18
 
26
19
  class Encoder
27
- include Transcoder::_Encoder
28
-
29
20
  @boundary: String
30
21
  @part_index: Integer
31
22
  @buffer: String
@@ -33,6 +24,8 @@ module HTTPX
33
24
  @form: Enumerable[[Symbol | string, multipart_nested_value]]
34
25
  @parts: Array[_Reader]
35
26
 
27
+ def bytesize: () -> Integer
28
+
36
29
  def content_type: () -> String
37
30
 
38
31
  def read: (?int? length, ?string? buffer) -> String?
@@ -0,0 +1,15 @@
1
+ module HTTPX
2
+ module Transcoder
3
+ class BodyReader
4
+ @body: _Reader | _Each[String]
5
+
6
+ def initialize: (bodyIO body) -> void
7
+
8
+ def bytesize: () -> (Integer | Float)
9
+
10
+ def read: (?int? length, ?string outbuf) -> String?
11
+
12
+ def close: () -> void
13
+ end
14
+ end
15
+ end