httpx 0.8.0 → 0.10.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE.txt +48 -0
  3. data/README.md +9 -5
  4. data/doc/release_notes/0_0_1.md +7 -0
  5. data/doc/release_notes/0_0_2.md +9 -0
  6. data/doc/release_notes/0_0_3.md +9 -0
  7. data/doc/release_notes/0_0_4.md +7 -0
  8. data/doc/release_notes/0_0_5.md +5 -0
  9. data/doc/release_notes/0_10_0.md +66 -0
  10. data/doc/release_notes/0_10_1.md +39 -0
  11. data/doc/release_notes/0_1_0.md +9 -0
  12. data/doc/release_notes/0_2_0.md +5 -0
  13. data/doc/release_notes/0_2_1.md +16 -0
  14. data/doc/release_notes/0_3_0.md +12 -0
  15. data/doc/release_notes/0_3_1.md +6 -0
  16. data/doc/release_notes/0_4_0.md +51 -0
  17. data/doc/release_notes/0_4_1.md +3 -0
  18. data/doc/release_notes/0_5_0.md +15 -0
  19. data/doc/release_notes/0_5_1.md +14 -0
  20. data/doc/release_notes/0_6_0.md +5 -0
  21. data/doc/release_notes/0_6_1.md +6 -0
  22. data/doc/release_notes/0_6_2.md +6 -0
  23. data/doc/release_notes/0_6_3.md +13 -0
  24. data/doc/release_notes/0_6_4.md +21 -0
  25. data/doc/release_notes/0_6_5.md +22 -0
  26. data/doc/release_notes/0_6_6.md +19 -0
  27. data/doc/release_notes/0_6_7.md +5 -0
  28. data/doc/release_notes/0_7_0.md +46 -0
  29. data/doc/release_notes/0_8_0.md +27 -0
  30. data/doc/release_notes/0_8_1.md +8 -0
  31. data/doc/release_notes/0_8_2.md +7 -0
  32. data/doc/release_notes/0_9_0.md +38 -0
  33. data/lib/httpx.rb +2 -0
  34. data/lib/httpx/adapters/faraday.rb +1 -1
  35. data/lib/httpx/chainable.rb +11 -11
  36. data/lib/httpx/connection.rb +23 -31
  37. data/lib/httpx/connection/http1.rb +30 -4
  38. data/lib/httpx/connection/http2.rb +29 -10
  39. data/lib/httpx/domain_name.rb +440 -0
  40. data/lib/httpx/errors.rb +2 -1
  41. data/lib/httpx/extensions.rb +22 -2
  42. data/lib/httpx/headers.rb +2 -2
  43. data/lib/httpx/io/ssl.rb +0 -1
  44. data/lib/httpx/io/tcp.rb +6 -5
  45. data/lib/httpx/io/udp.rb +4 -1
  46. data/lib/httpx/options.rb +5 -1
  47. data/lib/httpx/parser/http1.rb +14 -17
  48. data/lib/httpx/plugins/compression.rb +46 -65
  49. data/lib/httpx/plugins/compression/brotli.rb +10 -14
  50. data/lib/httpx/plugins/compression/deflate.rb +7 -6
  51. data/lib/httpx/plugins/compression/gzip.rb +23 -5
  52. data/lib/httpx/plugins/cookies.rb +21 -60
  53. data/lib/httpx/plugins/cookies/cookie.rb +173 -0
  54. data/lib/httpx/plugins/cookies/jar.rb +74 -0
  55. data/lib/httpx/plugins/cookies/set_cookie_parser.rb +142 -0
  56. data/lib/httpx/plugins/expect.rb +12 -1
  57. data/lib/httpx/plugins/follow_redirects.rb +20 -2
  58. data/lib/httpx/plugins/h2c.rb +1 -1
  59. data/lib/httpx/plugins/multipart.rb +12 -6
  60. data/lib/httpx/plugins/persistent.rb +6 -1
  61. data/lib/httpx/plugins/proxy.rb +16 -2
  62. data/lib/httpx/plugins/proxy/socks4.rb +14 -14
  63. data/lib/httpx/plugins/rate_limiter.rb +51 -0
  64. data/lib/httpx/plugins/retries.rb +3 -2
  65. data/lib/httpx/plugins/stream.rb +109 -13
  66. data/lib/httpx/pool.rb +14 -17
  67. data/lib/httpx/request.rb +8 -20
  68. data/lib/httpx/resolver.rb +7 -10
  69. data/lib/httpx/resolver/https.rb +22 -24
  70. data/lib/httpx/resolver/native.rb +19 -16
  71. data/lib/httpx/resolver/resolver_mixin.rb +4 -2
  72. data/lib/httpx/resolver/system.rb +2 -2
  73. data/lib/httpx/response.rb +16 -25
  74. data/lib/httpx/selector.rb +11 -18
  75. data/lib/httpx/session.rb +40 -26
  76. data/lib/httpx/transcoder.rb +18 -0
  77. data/lib/httpx/transcoder/chunker.rb +0 -2
  78. data/lib/httpx/transcoder/form.rb +9 -7
  79. data/lib/httpx/transcoder/json.rb +0 -4
  80. data/lib/httpx/utils.rb +45 -0
  81. data/lib/httpx/version.rb +1 -1
  82. data/sig/buffer.rbs +24 -0
  83. data/sig/callbacks.rbs +14 -0
  84. data/sig/chainable.rbs +37 -0
  85. data/sig/connection.rbs +85 -0
  86. data/sig/connection/http1.rbs +66 -0
  87. data/sig/connection/http2.rbs +78 -0
  88. data/sig/domain_name.rbs +17 -0
  89. data/sig/errors.rbs +3 -0
  90. data/sig/headers.rbs +42 -0
  91. data/sig/httpx.rbs +15 -0
  92. data/sig/loggable.rbs +11 -0
  93. data/sig/missing.rbs +12 -0
  94. data/sig/options.rbs +118 -0
  95. data/sig/parser/http1.rbs +50 -0
  96. data/sig/plugins/authentication.rbs +11 -0
  97. data/sig/plugins/basic_authentication.rbs +13 -0
  98. data/sig/plugins/compression.rbs +55 -0
  99. data/sig/plugins/compression/brotli.rbs +21 -0
  100. data/sig/plugins/compression/deflate.rbs +17 -0
  101. data/sig/plugins/compression/gzip.rbs +29 -0
  102. data/sig/plugins/cookies.rbs +26 -0
  103. data/sig/plugins/cookies/cookie.rbs +50 -0
  104. data/sig/plugins/cookies/jar.rbs +27 -0
  105. data/sig/plugins/digest_authentication.rbs +33 -0
  106. data/sig/plugins/expect.rbs +19 -0
  107. data/sig/plugins/follow_redirects.rbs +37 -0
  108. data/sig/plugins/h2c.rbs +26 -0
  109. data/sig/plugins/multipart.rbs +21 -0
  110. data/sig/plugins/persistent.rbs +17 -0
  111. data/sig/plugins/proxy.rbs +47 -0
  112. data/sig/plugins/proxy/http.rbs +14 -0
  113. data/sig/plugins/proxy/socks4.rbs +33 -0
  114. data/sig/plugins/proxy/socks5.rbs +36 -0
  115. data/sig/plugins/proxy/ssh.rbs +18 -0
  116. data/sig/plugins/push_promise.rbs +22 -0
  117. data/sig/plugins/rate_limiter.rbs +11 -0
  118. data/sig/plugins/retries.rbs +48 -0
  119. data/sig/plugins/stream.rbs +39 -0
  120. data/sig/pool.rbs +36 -0
  121. data/sig/registry.rbs +9 -0
  122. data/sig/request.rbs +61 -0
  123. data/sig/resolver.rbs +26 -0
  124. data/sig/resolver/https.rbs +49 -0
  125. data/sig/resolver/native.rbs +60 -0
  126. data/sig/resolver/resolver_mixin.rbs +27 -0
  127. data/sig/resolver/system.rbs +17 -0
  128. data/sig/response.rbs +87 -0
  129. data/sig/selector.rbs +20 -0
  130. data/sig/session.rbs +49 -0
  131. data/sig/timeout.rbs +29 -0
  132. data/sig/transcoder.rbs +18 -0
  133. data/sig/transcoder/body.rbs +18 -0
  134. data/sig/transcoder/chunker.rbs +32 -0
  135. data/sig/transcoder/form.rbs +16 -0
  136. data/sig/transcoder/json.rbs +14 -0
  137. metadata +128 -22
  138. data/lib/httpx/resolver/options.rb +0 -25
@@ -0,0 +1,50 @@
1
+ module HTTPX
2
+ module Parser
3
+ type parsed_headers = Hash[String, Array[String]]
4
+
5
+ interface _HTTP1Events
6
+
7
+ def on_start: () -> void
8
+ def on_headers: (parsed_headers) -> void
9
+ def on_trailers: (parsed_headers) -> void
10
+ def on_data: (String) -> void
11
+ def on_complete: () -> void
12
+ end
13
+
14
+ class HTTP1
15
+ VERSIONS: Array[String]
16
+
17
+ def <<: (String chunk) -> void
18
+
19
+ def headers: () -> parsed_headers
20
+
21
+ def http_version: () -> Array[1 | 0]
22
+
23
+ def reset!: () -> void
24
+
25
+ def status_code: () -> Integer
26
+
27
+ def upgrade?: () -> bool
28
+
29
+ def upgrade_data: () -> String
30
+
31
+ private
32
+
33
+ def initialize: (_HTTP1Events observer) -> untyped
34
+
35
+ def nextstate: (Symbol state) -> void
36
+
37
+ def no_more_data?: () -> bool
38
+
39
+ def parse: () -> void
40
+
41
+ def parse_data: () -> void
42
+
43
+ def parse_headers: () -> void
44
+
45
+ def parse_headline: () -> void
46
+
47
+ def prepare_data: (parsed_headers headers) -> void
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,11 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Authentication
4
+ module InstanceMethods
5
+ def authentication: (string token) -> instance
6
+ end
7
+ end
8
+
9
+ type sessionAuthentication = Session & Plugins::Authentication::InstanceMethods
10
+ end
11
+ end
@@ -0,0 +1,13 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module BasicAuthentication
4
+ def self.load_dependencies: (singleton(Session)) -> void
5
+
6
+ module InstanceMethods
7
+ def basic_authentication: (string user, string password) -> instance
8
+ end
9
+ end
10
+
11
+ type sessionBasicAuthentication = Plugins::sessionAuthentication & Plugins::Authentication::InstanceMethods
12
+ end
13
+ end
@@ -0,0 +1,55 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Compression
4
+ extend Registry[Symbol, Class]
5
+
6
+ type deflatable = _Reader | _ToS
7
+
8
+ interface _Deflater
9
+ def deflate: (deflatable, _Writer, chunk_size: Integer) -> void
10
+ | (deflatable, _Writer, chunk_size: Integer) { (String) -> void } -> void
11
+ end
12
+
13
+ interface _Inflater
14
+ def inflate: (string) -> String
15
+
16
+ def initialize: (Numeric bytesize) -> untyped
17
+ end
18
+
19
+ def self.load_dependencies: (singleton(Session)) -> void
20
+
21
+ interface _CompressionOptions
22
+ def compression_threshold_size: () -> _Integer?
23
+ def compression_threshold_size=: (int) -> int
24
+ def with_compression_threshold_size: (int) -> instance
25
+ end
26
+
27
+ def self.extra_options: (Options) -> (Options & _CompressionOptions)
28
+
29
+
30
+ module ResponseBodyMethods
31
+ @encodings: Array[String]
32
+ @_deflaters: Array[_Decoder]
33
+
34
+ private
35
+
36
+ def decompress: (string) -> String
37
+ end
38
+
39
+ class Encoder
40
+ include Transcoder::_Encoder
41
+ include _ToS
42
+ include _Each[String]
43
+
44
+ def close: () -> void
45
+
46
+ private
47
+
48
+ def initialize: (deflatable body, _Deflater deflater) -> untyped
49
+ def deflate: () -> void
50
+ | () { (String) -> void } -> void
51
+ end
52
+
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,21 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Compression
4
+ module Brotli
5
+ def self.load_dependencies: (singleton(Session)) -> void
6
+ def self.configure: (*untyped) -> void
7
+
8
+ def self?.deflater: () -> _Deflater
9
+ def self?.decoder: (Numeric bytesize) -> Inflater
10
+
11
+ module Deflater
12
+ extend _Deflater
13
+ end
14
+
15
+ class Inflater
16
+ include _Inflater
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,17 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Compression
4
+ module Deflate
5
+ def self.load_dependencies: (singleton(Session)) -> void
6
+ def self.configure: (*untyped) -> void
7
+
8
+ def self?.deflater: () -> _Deflater
9
+ def self?.inflater: (Numeric bytesize) -> GZIP::Inflater
10
+
11
+ module Deflater
12
+ extend _Deflater
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Compression
4
+ module GZIP
5
+ def self.load_dependencies: (singleton(Session)) -> void
6
+ def self.configure: (*untyped) -> void
7
+
8
+ def self?.deflater: () -> _Deflater
9
+ def self?.inflater: (Numeric bytesize) -> Inflater
10
+
11
+ class Deflater
12
+ include _Deflater
13
+
14
+ @compressed_chunk: String
15
+
16
+ private
17
+
18
+ def initialize: () -> untyped
19
+ def write: (string) -> void
20
+ def compressed_chunk: () -> String
21
+ end
22
+
23
+ class Inflater
24
+ include _Inflater
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,26 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Cookies
4
+ type jar = Jar | _Each[cookies]
5
+
6
+ interface _CookieOptions
7
+ def cookies: () -> Jar?
8
+ def cookies=: (jar) -> Jar
9
+ def with_cookies: (jar) -> instance
10
+ end
11
+
12
+ def self.extra_options: (Options) -> (Options & _CookieOptions)
13
+
14
+ module InstanceMethods
15
+ def cookies: () -> Jar
16
+ end
17
+
18
+ module HeadersMethods
19
+ def set_cookie: (Array[Cookie]) -> void
20
+ end
21
+ end
22
+
23
+ type sessionCookies = Session & Plugins::Cookies::InstanceMethods
24
+ type headersCookies = Headers & Plugins::Cookies::HeadersMethods
25
+ end
26
+ end
@@ -0,0 +1,50 @@
1
+ module HTTPX
2
+ module Plugins::Cookies
3
+ type cookie_attributes = Hash[Symbol | String, top]
4
+
5
+ class Cookie
6
+ include Comparable
7
+
8
+ MAX_LENGTH: Integer
9
+
10
+ attr_reader domain: DomainName?
11
+
12
+ attr_reader path: String
13
+
14
+ attr_reader name: String
15
+
16
+ attr_reader value: String?
17
+
18
+ attr_reader created_at: Time
19
+
20
+ def path=: (string) -> void
21
+
22
+ def domain=: (string) -> void
23
+
24
+ def expires: () -> Time?
25
+
26
+ def expired?: () -> bool
27
+ | (Time) -> bool
28
+
29
+ def cookie_value: () -> String
30
+ alias to_s cookie_value
31
+
32
+ def valid_for_uri?: (uri) -> bool
33
+
34
+ def self.new: (Cookie) -> untyped
35
+ | (cookie_attributes) -> untyped
36
+ | (String, String) -> untyped
37
+ | (String, String, cookie_attributes) -> untyped
38
+
39
+ def self.path_match?: (String, String) -> bool
40
+
41
+ private
42
+
43
+ def initialize: (cookie_attributes) -> untyped
44
+ | (String, String) -> untyped
45
+ | (String, String, cookie_attributes?) -> untyped
46
+
47
+ def acceptable_from_uri?: (uri) -> bool
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,27 @@
1
+ module HTTPX
2
+ module Plugins::Cookies
3
+ class Jar
4
+ type cookie = Cookie | Array[String, String, cookie_attributes] | Array[String, String] | cookie_attributes
5
+
6
+ include Enumerable[Cookie]
7
+
8
+ @cookies: Array[Cookie]
9
+
10
+ def parse: (String) -> void
11
+
12
+ def add: (Cookie) -> void
13
+ | (Cookie, String) -> void
14
+
15
+ def []: (uri) -> Array[Cookie]
16
+
17
+ def each: (uri) { (Cookie) -> void } -> void
18
+ | (uri) -> Enumerable[Cookie]
19
+ | () { (Cookie) -> void } -> void
20
+ | () -> Enumerable[Cookie]
21
+ private
22
+
23
+ def initialize: () -> void
24
+ | (_Each[cookie]) -> untyped
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module DigestAuthentication
4
+ DigestError: singleton(Error)
5
+
6
+ interface _DigestOptions
7
+ def digest: () -> Digest?
8
+ def digest=: (Digest) -> Digest
9
+ def with_digest: (Digest) -> instance
10
+ end
11
+
12
+ def self.extra_options: (Options) -> (Options & _DigestOptions)
13
+
14
+ def self.load_dependencies: (*untyped) -> void
15
+
16
+ module InstanceMethods
17
+ def digest_authentication: (string user, string password) -> instance
18
+ end
19
+
20
+ class Digest
21
+ def generate_header: (Request, Response, ?bool?) -> String
22
+
23
+ private
24
+
25
+ def initialize: (string user, string password) -> untyped
26
+ def make_cnonce: () -> String
27
+ def next_nonce: () -> Integer
28
+ end
29
+ end
30
+
31
+ type sessionDigestAuthentication = Plugins::sessionAuthentication & Plugins::Authentication::InstanceMethods
32
+ end
33
+ end
@@ -0,0 +1,19 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Expect
4
+ EXPECT_TIMEOUT: Integer
5
+
6
+ interface _ExpectOptions
7
+ def expect_timeout: () -> Integer?
8
+ def expect_timeout=: (int) -> Integer
9
+ def with_expect_timeout: (int) -> instance
10
+
11
+ def expect_threshold_size: () -> Integer?
12
+ def expect_threshold_size=: (int) -> Integer
13
+ def with_expect_threshold_size: (int) -> instance
14
+ end
15
+
16
+ def self.extra_options: (Options) -> (Options & _ExpectOptions)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,37 @@
1
+ module HTTPX
2
+ InsecureRedirectError: singleton(Error)
3
+
4
+ module Plugins
5
+ module FollowRedirects
6
+ MAX_REDIRECTS: Integer
7
+ REDIRECT_STATUS: Range[Integer]
8
+
9
+ interface _FollowRedirectsOptions
10
+ def max_redirects: () -> Integer?
11
+ def max_redirects=: (int) -> Integer
12
+ def with_max_redirects: (int) -> instance
13
+
14
+ def follow_insecure_redirects: () -> bool?
15
+ def follow_insecure_redirects=: (bool) -> bool
16
+ def with_follow_insecure_redirects: (bool) -> instance
17
+ end
18
+
19
+ def self.extra_options: (Options) -> (Options & _FollowRedirectsOptions)
20
+
21
+ module InstanceMethods
22
+ def max_redirects: (_ToI) -> instance
23
+
24
+ def build_redirect_request: (Request, Response, Options) -> Request
25
+ def __get_location_from_response: (Response) -> (URI::HTTP | URI::HTTPS)
26
+ end
27
+
28
+ module RequestMethods
29
+ def redirect_request: () -> Request
30
+ def redirect_request=: (Request) -> void
31
+ def max_redirects: () -> Integer
32
+ end
33
+ end
34
+
35
+ type sessionFollowRedirects = Session & Plugins::Authentication::InstanceMethods
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module H2C
4
+ def self.load_dependencies: (singleton(Session)) -> void
5
+
6
+ module InstanceMethods
7
+ VALID_H2C_METHODS: Array[Symbol]
8
+
9
+ private
10
+
11
+ def valid_h2c_upgrade_request: (Request) -> bool
12
+ def valid_h2c_upgrade?: (Request, Response, Options) -> bool
13
+ end
14
+
15
+ class H2CParser < Connection::HTTP2
16
+ def upgrade: (Request, Response) -> void
17
+ end
18
+
19
+ module ConnectionMethods
20
+ def upgrade: (Request, Response) -> void
21
+ end
22
+ end
23
+
24
+ type sessionH2C = Session & Plugins::H2C::InstanceMethods
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ module HTTPX
2
+ module Plugins
3
+ module Multipart
4
+ def self.load_dependencies: (singleton(Session)) -> void
5
+ def self.configure: (*untyped) -> void
6
+ def self?.encode: (untyped) -> Encoder
7
+
8
+ class Encoder
9
+ include Transcoder::_Encoder
10
+ include _ToS
11
+ include _Reader
12
+
13
+ private
14
+
15
+ def initialize: (Hash[Symbol | string, HTTP::FormData::Part | string] multipart_data) -> untyped
16
+
17
+ def multipart?: (top) -> bool
18
+ end
19
+ end
20
+ end
21
+ end