mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-12-04 00:01:13 -05:00
added more typing, improved correctness of a few checks
This commit is contained in:
parent
bd233c5303
commit
cfac38dc62
@ -101,7 +101,7 @@ module HTTPX
|
|||||||
# was the result of coalescing. To prevent blind trust in the case where the
|
# was the result of coalescing. To prevent blind trust in the case where the
|
||||||
# origin came from an ORIGIN frame, we're going to verify the hostname with the
|
# origin came from an ORIGIN frame, we're going to verify the hostname with the
|
||||||
# SSL certificate
|
# SSL certificate
|
||||||
(@origins.size == 1 || @origin == uri.origin || (@io && @io.verify_hostname(uri.host)))
|
(@origins.size == 1 || @origin == uri.origin || (@io.is_a?(SSL) && @io.verify_hostname(uri.host)))
|
||||||
) && @options == options
|
) && @options == options
|
||||||
) || (match_altsvcs?(uri) && match_altsvc_options?(uri, options))
|
) || (match_altsvcs?(uri) && match_altsvc_options?(uri, options))
|
||||||
end
|
end
|
||||||
@ -115,7 +115,7 @@ module HTTPX
|
|||||||
|
|
||||||
(
|
(
|
||||||
(open? && @origin == connection.origin) ||
|
(open? && @origin == connection.origin) ||
|
||||||
!(@io.addresses & connection.addresses).empty?
|
!(@io.addresses & (connection.addresses || [])).empty?
|
||||||
) && @options == connection.options
|
) && @options == connection.options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -203,6 +203,7 @@ module HTTPX
|
|||||||
end
|
end
|
||||||
|
|
||||||
def receive_requests(requests, connections)
|
def receive_requests(requests, connections)
|
||||||
|
# @type var responses: Array[response]
|
||||||
responses = []
|
responses = []
|
||||||
|
|
||||||
begin
|
begin
|
||||||
|
|||||||
@ -34,7 +34,13 @@ module HTTPX
|
|||||||
@write_buffer: Buffer
|
@write_buffer: Buffer
|
||||||
@inflight: Integer
|
@inflight: Integer
|
||||||
@keep_alive_timeout: Numeric?
|
@keep_alive_timeout: Numeric?
|
||||||
|
@timeout: Numeric?
|
||||||
|
@current_timeout: Numeric?
|
||||||
@total_timeout: Numeric?
|
@total_timeout: Numeric?
|
||||||
|
@io: TCP | SSL | UNIX
|
||||||
|
@parser: HTTP1 | HTTP2 | _Parser
|
||||||
|
@connected_at: Float
|
||||||
|
@response_received_at: Float
|
||||||
|
|
||||||
def addresses: () -> Array[ipaddr]?
|
def addresses: () -> Array[ipaddr]?
|
||||||
|
|
||||||
@ -75,6 +81,8 @@ module HTTPX
|
|||||||
|
|
||||||
def deactivate: () -> void
|
def deactivate: () -> void
|
||||||
|
|
||||||
|
def open?: () -> bool
|
||||||
|
|
||||||
def raise_timeout_error: (Numeric interval) -> void
|
def raise_timeout_error: (Numeric interval) -> void
|
||||||
|
|
||||||
private
|
private
|
||||||
@ -89,17 +97,18 @@ module HTTPX
|
|||||||
|
|
||||||
def send_pending: () -> void
|
def send_pending: () -> void
|
||||||
|
|
||||||
def parser: () -> _Parser
|
def parser: () -> (HTTP1 | HTTP2 | _Parser)
|
||||||
|
|
||||||
def send_request_to_parser: (Request request) -> void
|
def send_request_to_parser: (Request request) -> void
|
||||||
|
|
||||||
def build_parser: () -> _Parser
|
def build_parser: (?String protocol) -> (HTTP1 | HTTP2)
|
||||||
| (String) -> _Parser
|
|
||||||
|
|
||||||
def set_parser_callbacks: (_Parser) -> void
|
def set_parser_callbacks: (HTTP1 | HTTP2 parser) -> void
|
||||||
|
|
||||||
def transition: (Symbol) -> void
|
def transition: (Symbol) -> void
|
||||||
|
|
||||||
|
def handle_transition: (Symbol) -> void
|
||||||
|
|
||||||
def build_socket: (?Array[ipaddr]? addrs) -> (TCP | SSL | UNIX)
|
def build_socket: (?Array[ipaddr]? addrs) -> (TCP | SSL | UNIX)
|
||||||
|
|
||||||
def on_error: (HTTPX::TimeoutError | Error | StandardError) -> void
|
def on_error: (HTTPX::TimeoutError | Error | StandardError) -> void
|
||||||
|
|||||||
@ -2,6 +2,12 @@ module HTTPX
|
|||||||
class Error < StandardError
|
class Error < StandardError
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class UnsupportedSchemeError < Error
|
||||||
|
end
|
||||||
|
|
||||||
|
class ConnectionError < Error
|
||||||
|
end
|
||||||
|
|
||||||
class TimeoutError < Error
|
class TimeoutError < Error
|
||||||
attr_reader timeout: Numeric
|
attr_reader timeout: Numeric
|
||||||
|
|
||||||
@ -55,4 +61,7 @@ module HTTPX
|
|||||||
|
|
||||||
def initialize: (Connection connection, String hostname, ?String message) -> untyped
|
def initialize: (Connection connection, String hostname, ?String message) -> untyped
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class MisdirectedRequestError < HTTPError
|
||||||
|
end
|
||||||
end
|
end
|
||||||
@ -1,6 +1,9 @@
|
|||||||
module HTTPX
|
module HTTPX
|
||||||
IPRegex: Regexp
|
IPRegex: Regexp
|
||||||
|
|
||||||
|
class TLSError < OpenSSL::SSL::SSLError
|
||||||
|
end
|
||||||
|
|
||||||
class SSL < TCP
|
class SSL < TCP
|
||||||
TLS_OPTIONS: Hash[Symbol, untyped]
|
TLS_OPTIONS: Hash[Symbol, untyped]
|
||||||
|
|
||||||
|
|||||||
@ -10,7 +10,7 @@ module HTTPX
|
|||||||
|
|
||||||
attr_reader state: Symbol
|
attr_reader state: Symbol
|
||||||
|
|
||||||
attr_reader interests: Symbol
|
attr_reader interests: io_interests
|
||||||
|
|
||||||
alias host ip
|
alias host ip
|
||||||
|
|
||||||
|
|||||||
@ -46,7 +46,7 @@ module HTTPX
|
|||||||
attr_reader body_threshold_size: Integer
|
attr_reader body_threshold_size: Integer
|
||||||
|
|
||||||
# transport
|
# transport
|
||||||
attr_reader transport: String?
|
attr_reader transport: "unix" | nil
|
||||||
|
|
||||||
# transport_options
|
# transport_options
|
||||||
attr_reader transport_options: Hash[untyped, untyped]?
|
attr_reader transport_options: Hash[untyped, untyped]?
|
||||||
|
|||||||
@ -13,8 +13,8 @@ module HTTPX
|
|||||||
|
|
||||||
def []: (uri) -> Array[Cookie]
|
def []: (uri) -> Array[Cookie]
|
||||||
|
|
||||||
def each: (?uri) { (Cookie) -> void } -> void
|
def each: (?uri?) { (Cookie) -> void } -> void
|
||||||
| (?uri) -> Enumerable[Cookie]
|
| (?uri?) -> Enumerable[Cookie]
|
||||||
|
|
||||||
def merge: (_Each[cookie] cookies) -> instance
|
def merge: (_Each[cookie] cookies) -> instance
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ module HTTPX
|
|||||||
module Plugins
|
module Plugins
|
||||||
module Retries
|
module Retries
|
||||||
MAX_RETRIES: Integer
|
MAX_RETRIES: Integer
|
||||||
IDEMPOTENT_METHODS: Array[verb]
|
IDEMPOTENT_METHODS: Array[String]
|
||||||
RETRYABLE_ERRORS: Array[singleton(StandardError)]
|
RETRYABLE_ERRORS: Array[singleton(StandardError)]
|
||||||
DEFAULT_JITTER: ^(Numeric) -> Numeric
|
DEFAULT_JITTER: ^(Numeric) -> Numeric
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ module HTTPX
|
|||||||
USER_AGENT: String
|
USER_AGENT: String
|
||||||
|
|
||||||
attr_reader verb: verb
|
attr_reader verb: verb
|
||||||
attr_reader uri: URI::Generic
|
attr_reader uri: URI::HTTP | URI::HTTPS
|
||||||
attr_reader headers: Headers
|
attr_reader headers: Headers
|
||||||
attr_reader body: Body
|
attr_reader body: Body
|
||||||
attr_reader state: Symbol
|
attr_reader state: Symbol
|
||||||
|
|||||||
@ -22,7 +22,7 @@ module HTTPX
|
|||||||
def self?.resolver_for: (:native resolver_type) -> singleton(Native) |
|
def self?.resolver_for: (:native resolver_type) -> singleton(Native) |
|
||||||
(:system resolver_type) -> singleton(System) |
|
(:system resolver_type) -> singleton(System) |
|
||||||
(:https resolver_type) -> singleton(HTTPS) |
|
(:https resolver_type) -> singleton(HTTPS) |
|
||||||
(singleton(Resolver::Resolver) resolver_type) -> singleton(Resolver::Resolver)
|
[U] (U resolver_type) -> U
|
||||||
|
|
||||||
def self?.cached_lookup: (String hostname) -> Array[IPAddr]?
|
def self?.cached_lookup: (String hostname) -> Array[IPAddr]?
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ module HTTPX
|
|||||||
include _ToS
|
include _ToS
|
||||||
include _ToStr
|
include _ToStr
|
||||||
|
|
||||||
attr_reader encoding: String
|
attr_reader encoding: Encoding | String
|
||||||
|
|
||||||
@response: Response
|
@response: Response
|
||||||
@headers: Headers
|
@headers: Headers
|
||||||
|
|||||||
@ -11,8 +11,6 @@ module HTTPX
|
|||||||
|
|
||||||
def self.plugin: (Symbol | Module plugin, ?options? options) ?{ (Class) -> void } -> singleton(Session)
|
def self.plugin: (Symbol | Module plugin, ?options? options) ?{ (Class) -> void } -> singleton(Session)
|
||||||
|
|
||||||
def self.default_options: -> Options
|
|
||||||
|
|
||||||
def wrap: () { (instance) -> void } -> void
|
def wrap: () { (instance) -> void } -> void
|
||||||
|
|
||||||
def close: (*untyped) -> void
|
def close: (*untyped) -> void
|
||||||
@ -41,12 +39,14 @@ module HTTPX
|
|||||||
| (verb, _Each[[uri, options]], Options) -> Array[Request]
|
| (verb, _Each[[uri, options]], Options) -> Array[Request]
|
||||||
| (verb, _Each[uri], options) -> Array[Request]
|
| (verb, _Each[uri], options) -> Array[Request]
|
||||||
|
|
||||||
def build_connection: (URI::Generic, Options) -> Connection
|
def build_connection: (URI::HTTP | URI::HTTPS uri, Options options) -> Connection
|
||||||
|
|
||||||
def send_requests: (*Request) -> Array[response]
|
def send_requests: (*Request) -> Array[response]
|
||||||
|
|
||||||
def _send_requests: (Array[Request]) -> Array[Connection]
|
def _send_requests: (Array[Request]) -> Array[Connection]
|
||||||
|
|
||||||
def receive_requests: (Array[Request], Array[Connection]) -> Array[response]
|
def receive_requests: (Array[Request], Array[Connection]) -> Array[response]
|
||||||
|
|
||||||
|
attr_reader self.default_options: Options
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1,5 +1,5 @@
|
|||||||
module HTTPX::Transcoder
|
module HTTPX::Transcoder
|
||||||
module XML
|
module Xml
|
||||||
|
|
||||||
def self?.encode: (untyped xml) -> Encoder
|
def self?.encode: (untyped xml) -> Encoder
|
||||||
def self?.decode: (HTTPX::Response response) -> _Decoder
|
def self?.decode: (HTTPX::Response response) -> _Decoder
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user