mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
fixing signatures
also adding some checks on code, in order for steep to stop complaining about potential nil returns.
This commit is contained in:
parent
556c94a575
commit
6b61b8ccdb
@ -540,7 +540,7 @@ module HTTPX
|
||||
|
||||
if @total_timeout && @total_timeout.fires_in.negative?
|
||||
ex = TotalTimeoutError.new(@total_timeout.interval, "Timed out after #{@total_timeout.interval} seconds")
|
||||
ex.set_backtrace(error.backtrace)
|
||||
ex.set_backtrace(error.backtrace) if error.backtrace
|
||||
error = ex
|
||||
elsif connecting?
|
||||
error = error.to_connection_error
|
||||
|
@ -9,7 +9,7 @@ module HTTPX
|
||||
include Callbacks
|
||||
include Loggable
|
||||
|
||||
CHECK_IF_IP = proc do |name|
|
||||
CHECK_IF_IP = ->(name) do
|
||||
begin
|
||||
IPAddr.new(name)
|
||||
true
|
||||
|
@ -86,7 +86,7 @@ class HTTPX::Selector
|
||||
|
||||
readers, writers = IO.select(r, w, nil, interval)
|
||||
|
||||
raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") if readers.nil? && writers.nil?
|
||||
raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") if readers.nil? && writers.nil? && interval
|
||||
rescue IOError, SystemCallError
|
||||
@selectables.reject!(&:closed?)
|
||||
retry
|
||||
@ -109,6 +109,8 @@ class HTTPX::Selector
|
||||
def select_one(interval)
|
||||
io = @selectables.first
|
||||
|
||||
return unless io
|
||||
|
||||
interests = io.interests
|
||||
|
||||
result = case interests
|
||||
@ -118,7 +120,7 @@ class HTTPX::Selector
|
||||
when nil then return
|
||||
end
|
||||
|
||||
raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") unless result
|
||||
raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") unless result || interval.nil?
|
||||
|
||||
yield io
|
||||
rescue IOError, SystemCallError
|
||||
|
@ -203,6 +203,9 @@ module HTTPX
|
||||
# guarantee ordered responses
|
||||
loop do
|
||||
request = requests.first
|
||||
|
||||
return responses unless request
|
||||
|
||||
pool.next_tick until (response = fetch_response(request, connections, request.options))
|
||||
|
||||
responses << response
|
||||
|
@ -1,6 +1,8 @@
|
||||
module HTTPX
|
||||
module Chainable
|
||||
def request: (*untyped, **untyped) -> (response | Array[response])
|
||||
def request: (Request | untyped, **untyped) -> response
|
||||
| (*(Request | untyped), **untyped) -> Array[response]
|
||||
|
||||
def accept: (String) -> Session
|
||||
def wrap: () { (Session) -> void } -> void
|
||||
|
||||
|
@ -37,8 +37,7 @@ module HTTPX
|
||||
|
||||
def coalescable?: (Connection) -> bool
|
||||
|
||||
def create_idle: (options) -> Connection
|
||||
| () -> Connection
|
||||
def create_idle: (?Hash[Symbol | String, untyped] options) -> Connection
|
||||
|
||||
def merge: (Connection) -> void
|
||||
|
||||
@ -51,7 +50,7 @@ module HTTPX
|
||||
|
||||
def interests: () -> io_interests?
|
||||
|
||||
def to_io: () -> _ToIO
|
||||
def to_io: () -> IO
|
||||
|
||||
def call: () -> void
|
||||
|
||||
|
@ -2,9 +2,9 @@ module HTTPX
|
||||
class Headers
|
||||
include _ToS
|
||||
|
||||
@headers: headers_hash
|
||||
@headers: Hash[headers_key, Array[String]]
|
||||
|
||||
def self.new: (?untyped headers) -> Headers
|
||||
def self.new: (?untyped headers) -> instance
|
||||
|
||||
def ==: (untyped other) -> bool
|
||||
|
||||
@ -32,7 +32,7 @@ module HTTPX
|
||||
|
||||
private
|
||||
|
||||
def initialize: (headers?) -> untyped
|
||||
def initialize: (?headers?) -> untyped
|
||||
def array_value: (headers_value) -> Array[String]
|
||||
def downcased: (headers_key) -> String
|
||||
end
|
||||
|
@ -108,7 +108,9 @@ module HTTPX
|
||||
|
||||
private
|
||||
|
||||
def initialize: (?options) -> untyped
|
||||
REQUEST_IVARS: Array[Symbol]
|
||||
|
||||
def initialize: (?options options) -> untyped
|
||||
end
|
||||
|
||||
type options = Options | Hash[Symbol | String, untyped]
|
||||
|
@ -9,8 +9,8 @@ module HTTPX
|
||||
|
||||
class Parameters
|
||||
attr_reader uri: URI::Generic
|
||||
attr_reader username: string?
|
||||
attr_reader password: string?
|
||||
attr_reader username: String?
|
||||
attr_reader password: String?
|
||||
|
||||
def authenticated?: () -> boolish
|
||||
def token_authentication: () -> String?
|
||||
@ -19,7 +19,7 @@ module HTTPX
|
||||
|
||||
private
|
||||
|
||||
def initialize: (uri: generic_uri, ?username: string, ?password: string) -> untyped
|
||||
def initialize: (uri: generic_uri, ?username: String, ?password: String) -> untyped
|
||||
end
|
||||
|
||||
def self.configure: (singleton(Session)) -> void
|
||||
@ -35,9 +35,9 @@ module HTTPX
|
||||
module InstanceMethods
|
||||
private
|
||||
|
||||
def proxy_uris: (uri, Options & _ProxyOptions) -> { uri: (URI | string), username: string, password: string }
|
||||
| (uri, Options & _ProxyOptions) -> { uri: (URI | string) }
|
||||
| (uri, Options & _ProxyOptions) -> nil
|
||||
def proxy_uris: (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri, username: String, password: String }
|
||||
| (generic_uri, Options & _ProxyOptions) -> { uri: generic_uri }
|
||||
| (generic_uri, Options & _ProxyOptions) -> nil
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -60,7 +60,7 @@ module HTTPX
|
||||
|
||||
class ProcIO
|
||||
include _Writer
|
||||
def initialize: (^(_ToS) -> void) -> untyped
|
||||
def initialize: (^(String) -> void) -> untyped
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -5,6 +5,8 @@ module HTTPX
|
||||
include ResolverMixin
|
||||
include _ToIO
|
||||
|
||||
type state = :idle | :open | :closed
|
||||
|
||||
DEFAULTS: Hash[Symbol, untyped]
|
||||
DNS_PORT: Integer
|
||||
|
||||
@ -19,7 +21,7 @@ module HTTPX
|
||||
@queries: Hash[String, Connection]
|
||||
@read_buffer: String
|
||||
@write_buffer: Buffer
|
||||
@state: :idle | :open | :closed
|
||||
@state: state
|
||||
|
||||
def closed?: () -> bool
|
||||
|
||||
@ -56,7 +58,7 @@ module HTTPX
|
||||
|
||||
def build_socket: () -> void
|
||||
|
||||
def transition: (Symbol nextstate) -> void
|
||||
def transition: (state nextstate) -> void
|
||||
|
||||
def handle_error: (NativeResolveError | StandardError) -> void
|
||||
end
|
||||
|
@ -4,7 +4,7 @@ module HTTPX
|
||||
include Callbacks
|
||||
include Loggable
|
||||
|
||||
CHECK_IF_IP: Proc
|
||||
CHECK_IF_IP: ^(String name) -> bool
|
||||
|
||||
def uncache: (Connection) -> void
|
||||
|
||||
|
@ -3,7 +3,7 @@ module HTTPX
|
||||
class System
|
||||
include ResolverMixin
|
||||
|
||||
RESOLV_ERRORS: Array[StandardError] # ResolvError
|
||||
RESOLV_ERRORS: Array[singleton(StandardError)] # ResolvError
|
||||
|
||||
def closed?: () -> true
|
||||
|
||||
|
@ -79,7 +79,7 @@ module HTTPX
|
||||
|
||||
private
|
||||
|
||||
def initialize: (String?, String?) -> untyped
|
||||
def initialize: (String? header_value) -> void
|
||||
end
|
||||
|
||||
class ErrorResponse
|
||||
|
@ -1,20 +1,22 @@
|
||||
module HTTPX
|
||||
class Selector
|
||||
type selectable = Connection | Resolver::Native | Resolver::HTTPS
|
||||
|
||||
READABLE: Array[Symbol]
|
||||
WRITABLE: Array[Symbol]
|
||||
@selectables: Array[_ToIO]
|
||||
@selectables: Array[selectable]
|
||||
|
||||
def register: (_ToIO) -> void
|
||||
def deregister: (_ToIO) -> void
|
||||
def register: (selectable) -> void
|
||||
def deregister: (selectable) -> void
|
||||
|
||||
def select: (Numeric? interval) { (_ToIO) -> void } -> void
|
||||
def select: (Numeric? interval) { (selectable) -> void } -> void
|
||||
|
||||
private
|
||||
|
||||
def initialize: () -> untyped
|
||||
|
||||
def select_many: (Numeric? interval) { (_ToIO) -> void } -> void
|
||||
def select_one: (Numeric? interval) { (_ToIO) -> void } -> void
|
||||
def select_many: (Numeric? interval) { (selectable) -> void } -> void
|
||||
def select_one: (Numeric? interval) { (selectable) -> void } -> void
|
||||
end
|
||||
|
||||
type io_interests = :r | :w | :rw
|
||||
|
@ -13,9 +13,6 @@ module HTTPX
|
||||
|
||||
def close: (*untyped) -> void
|
||||
|
||||
def request: (*Request, **untyped) -> (response | Array[response])
|
||||
| (*untyped, **untyped) -> (response | Array[response])
|
||||
|
||||
def build_request: (String | verb, generic_uri, ?options) -> Request
|
||||
|
||||
# def self.plugin: (Symbol | Module, ?options) { (Class) -> void } -> singleton(Session)
|
||||
@ -27,7 +24,7 @@ module HTTPX
|
||||
|
||||
private
|
||||
|
||||
def initialize: (?options) { (instance) -> void } -> untyped
|
||||
def initialize: (?options) { (self) -> void } -> untyped
|
||||
| (?options) -> untyped
|
||||
|
||||
def pool: -> Pool
|
||||
|
@ -10,7 +10,7 @@ module HTTPX
|
||||
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
|
||||
|
||||
def self?.normalize_query: (Hash[String, untyped] params, String name, String v, Integer depth)
|
||||
def self?.normalize_query: (Hash[String, untyped] params, String name, String v, Integer depth) -> void
|
||||
|
||||
interface _Encode
|
||||
def encode: (untyped payload) -> (_Encoder | _Each[String])
|
||||
|
Loading…
x
Reference in New Issue
Block a user