several signature improvements while testing with steep

This commit is contained in:
HoneyryderChuck 2021-06-30 02:23:20 +03:00
parent c9acb1d079
commit b6ee019014
44 changed files with 271 additions and 144 deletions

View File

@ -1,5 +1,7 @@
module HTTPX
class Buffer
extend Forwardable
include _ToS
include _ToStr

View File

@ -3,41 +3,37 @@ module HTTPX
def request: (*untyped, **untyped) -> (response | Array[response])
def accept: (String) -> Session
def wrap: () { (Session) -> void } -> void
| () -> void
def with: (options) -> Session
| (options) { (Session) -> Session} -> Session
| (options) { (Session) -> void } -> void
def plugin: (:authentication) -> Plugins::sessionAuthentication
| (:basic_authentication) -> Plugins::sessionBasicAuthentication
| (:digest_authentication) -> Plugins::sessionDigestAuthentication
| (:ntlm_authentication) -> Plugins::sessionNTLMAuthentication
| (:aws_sdk_authentication) -> Plugins::sessionAwsSdkAuthentication
| (:compression) -> Session
| (:cookies) -> Plugins::sessionCookies
| (:expect) -> Session
| (:follow_redirects) -> Plugins::sessionFollowRedirects
| (:upgrade) -> Session
| (:h2c) -> Session
| (:multipart) -> Session
| (:persistent) -> Plugins::sessionPersistent
| (:proxy) -> Plugins::sessionProxy
| (:push_promise) -> Plugins::sessionPushPromise
| (:retries) -> Plugins::sessionRetries
| (:rate_limiter) -> Session
| (:stream) -> Plugins::sessionStream
| (:aws_sigv4) -> Plugins::awsSigV4Session
| (:grpc) -> Plugins::grpcSession
| (Symbol | Module, ?options?) { (Class) -> void } -> Session
| (Symbol | Module, ?options?) -> Session
def plugin: (:authentication, ?options) -> Plugins::sessionAuthentication
| (:basic_authentication, ?options) -> Plugins::sessionBasicAuthentication
| (:digest_authentication, ?options) -> Plugins::sessionDigestAuthentication
| (:ntlm_authentication, ?options) -> Plugins::sessionNTLMAuthentication
| (:aws_sdk_authentication, ?options) -> Plugins::sessionAwsSdkAuthentication
| (:compression, ?options) -> Session
| (:cookies, ?options) -> Plugins::sessionCookies
| (:expect, ?options) -> Session
| (:follow_redirects, ?options) -> Plugins::sessionFollowRedirects
| (:upgrade, ?options) -> Session
| (:h2c, ?options) -> Session
| (:multipart, ?options) -> Session
| (:persistent, ?options) -> Plugins::sessionPersistent
| (:proxy, ?options) -> Plugins::sessionProxy
| (:push_promise, ?options) -> Plugins::sessionPushPromise
| (:retries, ?options) -> Plugins::sessionRetries
| (:rate_limiter, ?options) -> Session
| (:stream, ?options) -> Plugins::sessionStream
| (:aws_sigv4, ?options) -> Plugins::awsSigV4Session
| (:grpc, ?options) -> Plugins::grpcSession
| (Symbol | Module, ?options) { (Class) -> void } -> Session
| (Symbol | Module, ?options) -> Session
private
def default_options: () -> Options
def branch: (options) -> Session
| (options) { (Session) -> Session } -> Session
| (options) { (Session) -> void } -> Session
end
end

View File

@ -1,28 +1,37 @@
module HTTPX
class Connection
interface _Parser
def on: (Symbol) { (*untyped) -> void } -> void
def empty?: () -> bool
# def exhausted?: () -> bool
def close: () -> void
def consume: () -> void
def <<: (string) -> void
# def send: (Request) -> void
# def ping: () -> void
# def timeout: () -> (Integer | Float)
end
extend Forwardable
include Loggable
include Callbacks
extend HTTPX::Registry[String, Class]
include HTTPX::Registry[String, Class]
attr_reader origin: generic_uri
BUFFER_SIZE: Integer
attr_reader origin: URI::Generic
attr_reader state: Symbol
attr_reader pending: Array[Request]
attr_reader options: options
attr_reader options: Options
def addresses: () -> Array[ipaddr]?
def addresses=: (Array[ipaddr]) -> void
def match?: (generic_uri, options) -> bool
def match?: (URI::Generic, options) -> bool
def mergeable?: (Connection) -> bool
@ -35,7 +44,7 @@ module HTTPX
def purge_pending: () { (Request) -> void } -> void
def match_altsvcs?: (generic_uri) -> bool
def match_altsvcs?: (URI::Generic uri) -> bool
def connecting?: () -> bool
def inflight?: () -> boolish
@ -55,7 +64,7 @@ module HTTPX
private
def initialize: (String, generic_uri, options) -> untyped
def initialize: (String, URI::Generic, options) -> untyped
def connect: () -> void
@ -76,10 +85,13 @@ module HTTPX
def handle_response: () -> void
def on_error: (StandardError) -> void
def on_error: (HTTPX::TimeoutError | Error | StandardError) -> void
def handle_error: (StandardError) -> void
def total_timeout: () -> Timers::Timer?
def total_timeout: () -> untyped?
# def total_timeout: () -> Timers::Timer?
#
def purge_after_closed: () -> void
end
end

View File

@ -9,7 +9,7 @@ module HTTPX
@options: Options
@max_concurrent_requests: Integer
@max_requests: Integer
@parser: HTTP1
@parser: Parser::HTTP1
@buffer: Buffer
def interests: () -> io_interests?
@ -54,7 +54,7 @@ module HTTPX
def disable_pipelining: () -> void
def set_protocol_headers: (Request) -> _Each[headers_key, String]
def set_protocol_headers: (Request) -> _Each[[headers_key, String]]
def headline_uri: (Request) -> String
@ -64,7 +64,7 @@ module HTTPX
def join_trailers: (Request request) -> void
def join_headers2: (_Each[headers_key, String] headers) -> void
def join_headers2: (_Each[[headers_key, String]] headers) -> void
def join_body: (Request request) -> void

View File

@ -45,7 +45,7 @@ module HTTPX
def headline_uri: (Request) -> String
def set_protocol_headers: (Request) -> _Each[headers_key, String]
def set_protocol_headers: (Request) -> _Each[[headers_key, String]]
def handle: (Request request, HTTP2Next::Stream stream) -> void

View File

@ -1,3 +1,37 @@
module HTTPX
Error: singleton(StandardError)
class Error < StandardError
end
class TimeoutError < Error
attr_reader timeout: Numeric
def to_connection_error: () -> ConnectTimeoutError
private
def initialize: (Numeric timeout, String message) -> untyped
end
class TotalTimeoutError < TimeoutError
end
class ConnectTimeoutError < TimeoutError
end
class SettingsTimeoutError < TimeoutError
end
class ResolveTimeoutError < TimeoutError
end
class ResolveError < Error
end
class NativeResolveError < ResolveError
attr_reader connection: Connection
attr_reader host: String
private
def initialize: (Connection connection, String hostname, ?String message) -> untyped
end
end

View File

@ -14,13 +14,13 @@ module HTTPX
def add: (headers_key field, string value) -> void
def delete: (headers_key field) -> void
def each: (?_Each[headers_key, String]? extra_headers) { (headers_key, String) -> void } -> void
| (?_Each[headers_key, String]? extra_headers) -> Enumerable[[headers_key, String], void]
def each: (?_Each[[headers_key, String]]? extra_headers) { (headers_key, String) -> void } -> void
| (?_Each[[headers_key, String]]? extra_headers) -> Enumerable[[headers_key, String]]
def get: (headers_key field) -> Array[String]
def key?: (headers_key downcased_key) -> bool
def merge: (_Each[headers_key, headers_value] other) -> Headers
def merge: (_Each[[headers_key, headers_value]] other) -> Headers
def same_headers?: (untyped headers) -> bool

View File

@ -4,12 +4,15 @@ module HTTPX
VERSION: String
type uri = URI::HTTP | URI::HTTPS | string
type generic_uri = uri | URI::Generic
type generic_uri = String | URI::Generic
type verb = :options | :get | :head | :post | :put | :delete | :trace | :connect |
:propfind | :proppatch | :mkcol | :copy | :move | :lock | :unlock | :orderpatch |
:acl | :report | :patch | :search
module Plugins
def self?.load_plugin: (Symbol) -> Module
def self?.register_plugin: (Symbol, Module) -> void
end
end

View File

@ -4,8 +4,10 @@ module HTTPX
end
module Loggable
COLORS: Hash[Symbol, Integer]
def log: (?level: Integer?, ?color: Symbol?) { () -> String } -> void
def log_exception: (StandardError, **untyped) -> void
def log_exception: (Exception error, ?level: Integer, ?color: Symbol) -> void
end
end

View File

@ -4,6 +4,11 @@ module HTTPX
WINDOW_SIZE: Integer
MAX_BODY_THRESHOLD_SIZE: Integer
CONNECT_TIMEOUT: Integer
OPERATION_TIMEOUT: Integer
KEEP_ALIVE_TIMEOUT: Integer
SETTINGS_TIMEOUT: Integer
DEFAULT_OPTIONS: Hash[Symbol, untyped]
type timeout_type = :connect_timeout | :settings_timeout | :operation_timeout | :keep_alive_timeout | :total_timeout
type timeout = Hash[timeout_type, Numeric?]
@ -11,6 +16,8 @@ module HTTPX
def self.new: (options) -> instance
| () -> instance
def self.def_option: (Symbol, ?String) -> void
| (Symbol) { (*nil) -> untyped } -> void
# headers
attr_reader uri: URI?
def uri=: (uri) -> void
@ -32,15 +39,15 @@ module HTTPX
def max_requests=: (Integer) -> void
# window_size
attr_reader window_size: int?
attr_reader window_size: Integer
def window_size=: (int) -> void
# body_threshold_size
attr_reader body_threshold_size: int?
attr_reader body_threshold_size: Integer
def body_threshold_size=: (int) -> void
# transport
attr_reader transport: _ToS?
attr_reader transport: String?
def transport=: (_ToS) -> void
# transport_options
@ -48,8 +55,8 @@ module HTTPX
def transport_options=: (Hash[untyped, untyped]) -> void
# addresses
attr_reader addresses: _ToAry[untyped]?
def addresses=: (_ToAry[untyped]) -> void
attr_reader addresses: _ToAry[ipaddr]?
def addresses=: (_ToAry[ipaddr]) -> void
# params
attr_reader params: Transcoder::urlencoded_input?
@ -71,14 +78,33 @@ module HTTPX
# http2_settings
# classes
attr_reader connection_class: singleton(Connection)
def connection_class=: (singleton(Connection)) -> void
attr_reader request_class: singleton(Request)
def request_class=: (singleton(Request)) -> void
attr_reader response_class: singleton(Response)
def response_class=: (singleton(Response)) -> void
attr_reader headers_class: singleton(Headers)
def headers_class=: (singleton(Headers)) -> void
attr_reader request_body_class: singleton(Request::Body)
def request_body_class=: (singleton(Request::Body)) -> void
attr_reader response_body_class: singleton(Response::Body)
def response_body_class=: (singleton(Response::Body)) -> void
attr_reader ssl: Hash[Symbol, untyped]
def ssl=: (Hash[Symbol, untyped]) -> void
# request_class response_class headers_class request_body_class
# response_body_class connection_class
# resolver_class resolver_options
# request_class
attr_reader request_class: singleton(Request)
def request_class=: (singleton(Request)) -> void
# io
type io_option = _ToIO | Hash[String, _ToIO]
attr_reader io: io_option?
@ -93,19 +119,24 @@ module HTTPX
def debug=: (_IOLogger) -> void
# debug_level
attr_reader debug_level: Integer?
attr_reader debug_level: Integer
def debug_level=: (Integer) -> void
# persistent
attr_reader persistent: bool?
def persistent=: (bool) -> void
# resolver_options
attr_reader resolver_options: Hash[Symbol, untyped]?
def resolver_options=: (Hash[Symbol, untyped]) -> void
def ==: (untyped other) -> bool
def merge: (_ToHash other) -> instance
def merge: (_ToHash[Symbol | String, untyped] other) -> instance
def to_hash: () -> Hash[Symbol, untyped]
private
def initialize: (options) -> untyped
def initialize: (?options) -> untyped
end
type options = Options | Hash[Symbol | String, untyped]

View File

@ -6,6 +6,6 @@ module HTTPX
end
end
type sessionAuthentication = Session & Plugins::Authentication::InstanceMethods
type sessionAuthentication = Session & Authentication::InstanceMethods
end
end

View File

@ -3,6 +3,10 @@ module HTTPX
module AwsSdkAuthentication
class Credentials
include _SigV4Credentials
private
def initialize: (untyped aws_credentials) -> untyped
end
def self.load_dependencies: (singleton(Session)) -> void
@ -16,6 +20,6 @@ module HTTPX
end
end
type sessionAwsSdkAuthentication = Session & Plugins::AwsSdkAuthentication::InstanceMethods
type sessionAwsSdkAuthentication = Session & AwsSdkAuthentication::InstanceMethods
end
end

View File

@ -59,6 +59,6 @@ module HTTPX
end
end
type awsSigV4Session = Session & Plugins::AWSSigV4::InstanceMethods
type awsSigV4Session = Session & AWSSigV4::InstanceMethods
end
end

View File

@ -10,6 +10,6 @@ module HTTPX
end
end
type sessionBasicAuthentication = Plugins::sessionAuthentication & Plugins::BasicAuthentication::InstanceMethods
type sessionBasicAuthentication = sessionAuthentication & BasicAuthentication::InstanceMethods
end
end

View File

@ -19,8 +19,8 @@ module HTTPX
def self.configure: (singleton(Session)) -> void
interface _CompressionOptions
def compression_threshold_size: () -> _Integer?
def compression_threshold_size=: (int) -> int
def compression_threshold_size: () -> Integer?
def compression_threshold_size=: (int) -> _ToInt
def encodings: () -> encodings_registry?
def encodings=: (encodings_registry) -> encodings_registry
@ -31,7 +31,7 @@ module HTTPX
module ResponseBodyMethods
@encodings: Array[String]
@_deflaters: Array[_Decoder]
@_deflaters: Array[_Deflater]
private

View File

@ -1,7 +1,7 @@
module HTTPX
module Plugins
module Cookies
type jar = Jar | _Each[cookies]
type jar = Jar | _Each[Jar::cookie]
interface _CookieOptions
def cookies: () -> Jar?
@ -19,7 +19,7 @@ module HTTPX
end
end
type sessionCookies = Session & Plugins::Cookies::InstanceMethods
type headersCookies = Headers & Plugins::Cookies::HeadersMethods
type sessionCookies = Session & Cookies::InstanceMethods
type headersCookies = Headers & Cookies::HeadersMethods
end
end

View File

@ -1,7 +1,7 @@
module HTTPX
module Plugins::Cookies
class Jar
type cookie = Cookie | Array[String, String, cookie_attributes] | Array[String, String] | cookie_attributes
type cookie = Cookie | Array[[String, String, cookie_attributes]] | Array[[String, String]] | cookie_attributes
include Enumerable[Cookie]

View File

@ -27,6 +27,6 @@ module HTTPX
end
end
type sessionDigestAuthentication = Plugins::sessionAuthentication & Plugins::DigestAuthentication::InstanceMethods
type sessionDigestAuthentication = sessionAuthentication & DigestAuthentication::InstanceMethods
end
end

View File

@ -30,6 +30,6 @@ module HTTPX
end
end
type sessionFollowRedirects = Session & Plugins::FollowRedirects::InstanceMethods
type sessionFollowRedirects = Session & FollowRedirects::InstanceMethods
end
end

View File

@ -15,6 +15,8 @@ module HTTPX
type grpc_request = untyped | _Each[untyped]
type grpc_response = untyped | _Each[untyped]
type credentials = Proc
class Call
attr_writer decoder: _Callable
@ -88,6 +90,6 @@ module HTTPX
end
end
type grpcSession = Session & Plugins::GRPC::InstanceMethods
type grpcSession = Session & GRPC::InstanceMethods
end
end

View File

@ -15,7 +15,5 @@ module HTTPX
def upgrade_to_h2c: (Request, Response) -> void
end
end
type sessionH2C = Session & Plugins::H2C::InstanceMethods
end
end

View File

@ -13,8 +13,6 @@ module HTTPX
type multipart_nested_value = multipart_value | _ToAry[multipart_value] | _ToHash[string, multipart_value]
type multipart_input = Enumerable[[string, multipart_value], untyped]
class Encoder
include Transcoder::_Encoder
include _Reader
@ -23,7 +21,7 @@ module HTTPX
private
def initialize: (_Each[Symbol | string, multipart_nested_value] multipart_data) -> untyped
def initialize: (_Each[[Symbol | string, multipart_nested_value]] multipart_data) -> untyped
def header_part: (string key, String content_type, String? filename) -> StringIO
@ -37,7 +35,7 @@ module HTTPX
end
module MimeTypeDetector
def self?.call: (IO file, ?String filename) -> String?
def self?.call: (::IO file, ?String filename) -> String?
end
end
end

View File

@ -22,6 +22,6 @@ module HTTPX
end
end
type sessionNTLMAuthentication = Plugins::sessionAuthentication & Plugins::NTLMAuthentication::InstanceMethods
type sessionNTLMAuthentication = sessionAuthentication & NTLMAuthentication::InstanceMethods
end
end

View File

@ -1,5 +1,6 @@
module HTTPX
HTTPProxyError: singleton(Error)
class HTTPProxyError < Error
end
module Plugins
module Proxy
@ -23,11 +24,11 @@ module HTTPX
def self.configure: (singleton(Session)) -> void
type proxyParam = Parameters | Hash
type proxyParam = Parameters | Hash[Symbol, untyped]
interface _ProxyOptions
def proxy: () -> proxyParam?
def proxy=: (Parameters | _ToHash) -> proxyParam
def proxy=: (Parameters | _ToHash[Symbol, untyped]) -> proxyParam
end
def self.extra_options: (Options) -> (Options & _ProxyOptions)
@ -41,6 +42,6 @@ module HTTPX
end
end
type sessionProxy = Session & Plugins::Proxy::InstanceMethods
type sessionProxy = Session & Proxy::InstanceMethods
end
end

View File

@ -3,16 +3,16 @@ module HTTPX
module Proxy
module SSH
def self.load_dependencies: (singleton(Session)) -> void
module InstancenMethods
module InstanceMethods
private
def build_gateway_socket: (int, URI::HTTPS | URI::HTTPS, Options) -> IO
def build_gateway_socket: (int, URI::HTTP | URI::HTTPS, Options) -> _ToIO
end
end
end
type sessionSSHProxy = Plugins::Proxy::InstanceMethods & Plugins::Proxy::SSH::InstanceMethods
type sessionSSHProxy = Proxy::InstanceMethods & Proxy::SSH::InstanceMethods
end
end

View File

@ -39,6 +39,6 @@ module HTTPX
end
end
type sessionRetries = Session & Plugins::Retries::InstanceMethods
type sessionRetries = Session & Retries::InstanceMethods
end
end

View File

@ -35,6 +35,6 @@ module HTTPX
end
type sessionStream = Session & Plugins::Stream::InstanceMethods
type sessionStream = Session & Stream::InstanceMethods
end
end

View File

@ -4,8 +4,7 @@ module HTTPX
def next_tick: () -> void
def close: (Array[Connection]) -> void
| () -> void
def close: (*Array[Connection]) -> void
def init_connection: (Connection, Options) -> void

View File

@ -2,7 +2,7 @@ module HTTPX::Registry[T, V]
# type registrable = Symbol | String | Class
def self.registry: (T tag) -> Class
| () -> Hash[K, V]
| () -> Hash[T, V]
def self.register: (T tag, V handler) -> void
def registry: (?T tag) -> V

View File

@ -14,11 +14,11 @@ module HTTPX
attr_reader response: response?
attr_reader drain_error: StandardError?
def initialize: (verb | String, uri, ?options?) -> untyped
def initialize: (verb | String, generic_uri, ?options?) -> untyped
def interests: () -> (:r | :w)
def merge_headers: (Headers | Hash) -> void
def merge_headers: (_Each[[headers_key, headers_value]]) -> void
def scheme: () -> ("http" | "https")

View File

@ -4,6 +4,13 @@ module HTTPX
type resolver = Resolver::System | Resolver::Native | Resolver::HTTPS
module Resolver
RESOLVE_TIMEOUT: Integer | Float
def self.registry: (Symbol tag) -> Class
| () -> Hash[Symbol, Class]
def self.register: (Symbol tag, Class handler) -> void
type dns_resource = singleton(Resolv::DNS::Resource)
type dns_result = { "name" => String, "TTL" => Numeric, "alias" => String }

View File

@ -1,9 +1,13 @@
module HTTPX
module Resolver
class Native
extend Forwardable
include ResolverMixin
include _ToIO
DEFAULTS: Hash[Symbol, untyped]
DNS_PORT: Integer
@options: Options
@ns_index: Integer
@resolver_options: Hash[Symbol, untyped]
@ -15,7 +19,7 @@ module HTTPX
@queries: Hash[String, Connection]
@read_buffer: String
@write_buffer: Buffer
@state: :idle | :closed
@state: :idle | :open | :closed
def closed?: () -> bool
@ -35,6 +39,8 @@ module HTTPX
def initialize: (options) -> untyped
def calculate_interests: () -> (:r | :w)
def consume: () -> void
def do_retry: () -> void
@ -46,15 +52,13 @@ module HTTPX
def parse: (String) -> void
def resolve: (Connection, String hostname) -> void
| (Connection) -> void
| () -> void
def resolve: (?Connection connection, ?String hostname) -> void
def build_socket: () -> void
def transition: (Symbol nextstate) -> void
def handle_error: (StandardError) -> void
def handle_error: (NativeResolveError | StandardError) -> void
end
end
end

View File

@ -4,6 +4,8 @@ module HTTPX
include Callbacks
include Loggable
CHECK_IF_IP: Proc
def uncache: (Connection) -> void
private
@ -16,12 +18,9 @@ module HTTPX
def system_resolve: (String hostname) -> Array[ipaddr]?
def emit_resolve_error: (Connection, String hostname, StandardError) -> void
| (Connection, String hostname) -> void
| (Connection) -> void
def emit_resolve_error: (Connection, ?String hostname, ?StandardError) -> void
def resolve_error: (String hostname, StandardError?) -> void
| (String hostname) -> void
def resolve_error: (String hostname, ?StandardError?) -> void
end
end
end

View File

@ -3,6 +3,8 @@ module HTTPX
class System
include ResolverMixin
RESOLV_ERRORS: Array[StandardError] # ResolvError
def closed?: () -> true
def empty?: () -> true

View File

@ -1,15 +1,17 @@
module HTTPX
interface _Response
def raise_for_status: () -> void
def raise_for_status: () -> void
end
class Response
extend Forwardable
include _Response
include _ToS
include _Reader
attr_reader status: int
attr_reader headers: headers
attr_reader status: Integer
attr_reader headers: Headers
attr_reader body: Body
attr_reader version: String
@ -18,50 +20,54 @@ module HTTPX
def copy_to: (_ToPath | _Writer destination) -> void
def close: () -> void
def uri: () -> uri
def uri: () -> URI::Generic
def merge_headers: (headers) -> void
def merge_headers: (_Each[[headers_key, headers_value]]) -> void
def bodyless?: () -> bool
def content_type: () -> ContentType
def complete?: () -> bool
private
def initialize: (Request, _ToS, String, headers?) -> untyped
def initialize: (Request request, String | Integer status, String version, headers?) -> untyped
def no_data?: () -> bool
class Body
include _Writer
include _Reader
include _ToS
include _ToStr
@state: :idle | :memory | :buffer
@state: :idle | :memory | :buffer | :closed
@threshold_size: Integer
@window_size: Integer
def write:(String chunk) -> Integer?
def each: () { (String) -> void } -> void
| () -> Enumerable[String]
def bytesize: () -> Numeric
def empty?: () -> bool
def copy_to: (_ToPath | _Writer destination) -> void
def copy_to: (String | File | _Writer destination) -> void
def close: () -> void
def closed?: () -> bool
private
def initialize: (Response, options) -> untyped
def initialize: (Response, Options) -> untyped
def rewind: () -> void
def transition: () -> void
end
end
class ContentType
MIME_TYPE_RE: Regexp
CHARSET_RE: Regexp
attr_reader mime_type: String?
attr_reader charset: String?
def self.parse: (_ToS) -> instance
def self.parse: (_ToS) -> ContentType
def self.mime_type: (_ToS) -> String?
def self.charset: (_ToS) -> String?

View File

@ -1,20 +1,20 @@
module HTTPX
class Selector
READABLE: :r | :rw
WRITABLE: :w | :rw
READABLE: Array[Symbol]
WRITABLE: Array[Symbol]
@selectables: Array[_ToIO]
def register: (_ToIO) -> void
def deregister: (_ToIO) -> void
def select: (Numeric?) { (_ToIO) -> void } -> void
def select: (Numeric? interval) { (_ToIO) -> void } -> void
private
def initialize: () -> untyped
def select_many: (Numeric?) { (_ToIO) -> void } -> void
def select_one: (Numeric?) { (_ToIO) -> void } -> void
def select_many: (Numeric? interval) { (_ToIO) -> void } -> void
def select_one: (Numeric? interval) { (_ToIO) -> void } -> void
end
type io_interests = :r | :w | :rw

View File

@ -3,21 +3,23 @@ module HTTPX
include Loggable
include Chainable
EMPTY_HASH: Hash[untyped, untyped]
@options: Options
@responses: Hash[Request, Response]
@persistent: bool
@responses: Hash[Request, response]
@persistent: bool?
def wrap: () { (instance) -> void } -> void
| () -> void
def close: (*untyped) -> void
def request: (*Request, **untyped) -> (response | Array[response])
| (*untyped, **untyped) -> (response | Array[response])
def build_request: (String | verb, uri, ?options) -> Request
def build_request: (String | verb, generic_uri, ?options) -> Request
def self.plugin: (Symbol | Module, ?options) { (Class) -> void } -> singleton(Session)
| (Symbol | Module, ?options) -> singleton(Session)
# def self.plugin: (Symbol | Module, ?options) { (Class) -> void } -> singleton(Session)
# | (Symbol | Module, ?options) -> singleton(Session)
@ -25,28 +27,31 @@ module HTTPX
private
def initialize: (?options?) { (instance) -> void } -> untyped
| (?options?) -> untyped
def initialize: (?options) { (instance) -> void } -> untyped
| (?options) -> untyped
def pool: -> Pool
def on_response: (Request, response) -> void
def on_promise: (untyped, untyped) -> void
def fetch_response: (Request, *untyped) -> response?
def fetch_response: (Request request, untyped, untyped) -> response?
def find_connection: (Request, Array[Connection] connections, Options options) -> Connection
def set_connection_callbacks: (Connection, Array[Connection], Options) -> void
def build_altsvc_connection: (Connection, Array[Connection], URI, String, Hash[String, String], Options) -> Connection?
def build_altsvc_connection: (Connection, Array[Connection], URI::Generic, String, Hash[String, String], Options) -> Connection?
def build_requests: (verb | string, uri, options) -> Array[Request]
| (Array[[verb | string, uri, options]], options) -> Array[Request]
| (Array[[verb | string, uri]], options) -> Array[Request]
| (verb | string, _Each[[uri, options], void], Options) -> Array[Request]
| (verb | string, _Each[uri, void], options) -> Array[Request]
| (verb | string, _Each[[uri, options]], Options) -> Array[Request]
| (verb | string, _Each[uri], options) -> Array[Request]
def build_connection: (URI, Options) -> Connection
def build_connection: (URI::Generic, Options) -> Connection
def send_requests: (*Request, options) -> Array[response]
def _send_requests: (Array[Request], options) -> Array[Connection]
def _send_requests: (Array[Request], Options) -> Array[Connection]
def receive_requests: (Array[Request], Array[Connection], options) -> Array[response]
end

View File

@ -1,11 +1,18 @@
module HTTPX
type bodyIO = _Reader | _Each[String, untyped] | _ToS
type bodyIO = _Reader | _Each[[String, untyped]] | _ToS
module Transcoder
extend HTTPX::Registry[String, Class]
def self?.registry: (String tag) -> _Encode
| () -> Hash[String, _Encode]
def self.normalize_keys: (string | Symbol, top, ?Proc?) { (string, top) -> void } -> void
| (string | Symbol, top, ?Proc?) { (string) -> void } -> void
def self?.register: (String tag, _Encode handler) -> void
def self?.normalize_keys: (_ToS key, _ToAry[untyped] | _ToHash[_ToS, untyped] | untyped value) { (String, ?untyped) -> void } -> void
| (_ToS key, untyped value, Proc? cond) { (String, untyped) -> void } -> void
interface _Encode
def encode: (untyped payload) -> (_Encoder | _Each[String])
end
interface _Encoder
def bytesize: () -> Numeric

View File

@ -1,7 +1,12 @@
module HTTPX
module Transcoder
module Body
class Error < HTTPX::Error
end
class Encoder
extend Forwardable
include _Encoder
include _ToS
@ -11,7 +16,7 @@ module HTTPX
private
def initialize: (untyped body ) -> untyped
def initialize: (untyped body) -> untyped
end
def self?.encode: (bodyIO body) -> Encoder

View File

@ -1,6 +1,11 @@
module HTTPX::Transcoder
module Chunker
def self?.encode: (_Encoder chunks) -> Encoder
CRLF: String
class Error < HTTPX::Error
end
def self?.encode: (_Each[String] chunks) -> Encoder
class Encoder
@raw: _Each[String]
@ -9,10 +14,11 @@ module HTTPX::Transcoder
private
def initialize: (_Encoder chunks) -> untyped
def initialize: (_Each[String] chunks) -> untyped
end
class Decoder
extend Forwardable
include _ToS
include _Each[String]

View File

@ -3,12 +3,13 @@ module HTTPX::Transcoder
type form_nested_value = form_value | _ToAry[form_value] | _ToHash[string, form_value]
type urlencoded_input = Enumerable[[string, form_nested_value], untyped]
type urlencoded_input = Enumerable[[_ToS, form_nested_value]]
module Form
def self?.encode: (urlencoded_input form) -> Encoder
class Encoder
extend Forwardable
include _Encoder
include _ToS

View File

@ -3,6 +3,7 @@ module HTTPX::Transcoder
def self?.encode: (_ToJson json) -> Encoder
class Encoder
extend Forwardable
include _Encoder
include _ToS

View File

@ -1,5 +1,7 @@
module HTTPX
module Utils
URIParser: URI::RFC2396_Parser
def self?.parse_retry_after: (String) -> Numeric
def self?.to_uri: (generic_uri uri) -> URI::Generic

View File

@ -67,7 +67,7 @@ if [[ ${RUBY_VERSION:0:1} = "3" ]]; then
export RUBYOPT="$RUBYOPT -rbundler/setup -rrbs/test/setup"
export RBS_TEST_RAISE=true
export RBS_TEST_LOGLEVEL=error
export RBS_TEST_OPT="-Isig -ruri -rjson -ripaddr -rpathname -rhttp-2-next"
export RBS_TEST_OPT="-Isig -rforwardable -ruri -rjson -ripaddr -rpathname -rhttp-2-next"
export RBS_TEST_TARGET="HTTP*"
fi