mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-05 00:02:38 -04:00
there was a long-standing buggy workaround, whereas in stream-mode, when there was no response yet to query from, a synchronous request would be fired. This would break when under event streams, so we had to document this as "make sure that...". This fixes it by implementing a general session API convention, which separates the step of sending the requests, from waiting for its receival. And, given that the request knows when the response is available, we can actually "tick until response". This might be used in the future to refactor the way we handle the responses, which buffer the full payload by default, instead of reading from the connection at will.
53 lines
1.9 KiB
Plaintext
53 lines
1.9 KiB
Plaintext
module HTTPX
|
|
class Session
|
|
include Loggable
|
|
include Chainable
|
|
|
|
@options: Options
|
|
@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 self.plugin: (Symbol | Module, ?options) { (Class) -> void } -> singleton(Session)
|
|
| (Symbol | Module, ?options) -> singleton(Session)
|
|
|
|
|
|
|
|
def self.default_options: -> Options
|
|
|
|
private
|
|
|
|
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 set_connection_callbacks: (Connection, Array[Connection], Options) -> void
|
|
|
|
def build_altsvc_connection: (Connection, Array[Connection], URI, 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]
|
|
|
|
def build_connection: (URI, Options) -> Connection
|
|
|
|
def send_requests: (*Request, options) -> Array[response]
|
|
|
|
def _send_requests: (Array[Request], options) -> Array[Connection]
|
|
|
|
def receive_requests: (Array[Request], Array[Connection], options) -> Array[response]
|
|
end
|
|
end |