33 Commits

Author SHA1 Message Date
HoneyryderChuck
cfce76bd8b adding Resolver::Entry, using it everywhere internally
this acts as a delegator to ipaddr, and should be a drop-in replacement everywhere the ipaddress was used, with the extra information about expiration
2025-09-02 10:58:06 +01:00
HoneyryderChuck
53a3ba7037 moved logic related with supporting the fiber scheduler into its own plugin
this plugin is loaded into the persistent plugin by default, as it's already expected to work across fibers
2025-09-01 11:43:30 +01:00
HoneyryderChuck
09342187f5 removing fiber reference when emitting request completion event 2025-08-19 18:14:55 +01:00
HoneyryderChuck
aa03a3a52e set fiber context for sent request
this is used downstream to inform the selector (via IO interest calculation) whether the connection should wait on events for the current fiber (i.e. the connection should be used for requests of the current fiber, or DNS requests for the connection of such requests must be pending)
2025-08-19 18:14:55 +01:00
HoneyryderChuck
03170b6c89 promote certain transition logs to regular code (under level 3)
not really useful as telemetry metered, but would have been useful for other bugs
2025-07-18 17:48:23 +01:00
HoneyryderChuck
c48f6c8e8f adding Request#can_buffer?
abstracts some logic around whether a request has request body bytes to buffer
2025-04-04 00:20:29 +01:00
HoneyryderChuck
e40d3c9552 do not exhaust retry attempts when probing connections after keep alive timeout expires
since pools can keep multiple persistent connections which may have been terminated by the peer already, exhausting the one retry attempt from the persistent plugin may make request fail before trying it on an actual connection. in this patch, requests which are preceded by a PING frame used for probing are therefore marked as such, and do not decrement the attempts counter when failing
2025-04-03 11:04:15 +01:00
HoneyryderChuck
4653b48602 fix: do not close request right after sending it, assume it may have to be retried
with the retries plugin, the request payload will be rewinded, and that may not be possible if already closed. this was never detected so far because no request body transcoder internally closes, but the faraday multipart adapter does

the request is therefore closed alongside the response (when the latter is closed)

Fixes https://github.com/HoneyryderChuck/httpx/issues/75\#issuecomment-2731219586
2025-03-19 16:57:47 +00:00
HoneyryderChuck
88f8f5d287 fix: reset timeout callbacks when requests are routed to a different connection
this may happen in a few contexts, such as connection exhaustion, but more importantly, when a request is retried in a different connection; if the request successfully sets the callbacks before the connection raises an issue and the request is retried in a new one, the callback from the faulty connection are carried with it, and triggered at a time when the connection is back in the connection pool, or worse, used in a different thread

this fix relies on :idle transition callback, which is called before request is routed around
2025-03-03 18:21:04 +00:00
HoneyryderChuck
8bee6956eb adding Timer, making Timers#after return it, to allow single cancellation
the previous iteration relied on internal behaviour do delete the correct callback; in the process, logic to delete all callbacks from an interval was accidentally committed, which motivated this refactoring. the premise is: timeouts can cancel the timer; they set themselves as active until done; operation timeouts rely on the previous to be ignored or not.

a new error, OperationTimeoutError, was added for that effect
2025-03-01 01:03:24 +00:00
HoneyryderChuck
8b2ee0b466 remove form, json, ,xml and body from the Options class
Options become a bunch of session and connection level parameters, and requests do not need to maintain a separate Options object when they contain a body anymore, instead, objects is shared with the session, while request-only parameters get passed downwards to the request and its body. This reduces allocations of Options, currently the heaviest object to manage.
2024-06-11 18:23:45 +01:00
HoneyryderChuck
9465a077b1 Add Response#peer_address and ErrorResponse#peer_address
responses can now expose the IP address used to connect to the peer
server to fetch the response from.
2023-10-30 09:52:30 +00:00
HoneyryderChuck
bc99188c80 adding persistent= setter to Request
this avoids the creation of another options object
2023-10-25 07:44:40 +01:00
HoneyryderChuck
bdc9478aa8 do not use INFINITY for timeouts
it isn't a valid input for IO#wait family of functions; instead, use nil
2023-10-24 22:53:22 +01:00
HoneyryderChuck
09be632cd9 circuit breaker: use Enumerator#with_object, treat uris as strings to avoid allocation 2023-09-29 10:29:09 +01:00
HoneyryderChuck
0d58408c58 compression plugins for gzip and deflate supported by default
most of the code was moved to the transcoder layer.

The `compression_threshold_size` option has been removed.

The `:compression/brotli` plugin becomes only ´:brotli`, and depends on
the new transcoding APIs.

options to skip compression and decompression were added.
2023-09-20 17:57:41 +01:00
HoneyryderChuck
cfac38dc62 added more typing, improved correctness of a few checks 2023-04-28 23:57:25 +01:00
HoneyryderChuck
bbf257477b Removing HTTPX::Registry and its usage internally
These internnal registries were a bit magical to use, difficult to
debug, not thread-safe, and overall a nuisance when it came to type
checking. So long.
2023-04-27 22:49:20 +01:00
HoneyryderChuck
092e594a4b Request.verb is now an upcased string (ex: "GET")
The reference for a request verb is now the string which is used
everywhere else, instead of the symbol corresponding to it. This was an
artifact from the import from httprb, and there is no advantage in it,
since these strings are frozen in most use cases, and the
transformations from symbol to strings being performed everywhere are
prooof that keeping the atom isn't really bringing any benefit.
2023-04-17 16:54:31 +03:00
HoneyryderChuck
8f8febc10e sig fixes 2022-08-08 22:19:20 +01:00
HoneyryderChuck
3f9c165d51 added request_timeout 2022-08-06 23:20:21 +01:00
HoneyryderChuck
6d33b5e59f adding support for tempfile sigs, other improvements 2022-01-16 22:54:56 +02:00
HoneyryderChuck
cdcbf14675 few sig changes (more assertive) 2021-08-31 13:50:29 +01:00
HoneyryderChuck
6b61b8ccdb fixing signatures
also adding some checks on code, in order for steep to stop complaining
about potential nil returns.
2021-08-10 10:28:58 +01:00
HoneyryderChuck
b6ee019014 several signature improvements while testing with steep 2021-07-07 19:21:36 +01:00
HoneyryderChuck
441716a5ac fixing double-response for streams
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.
2021-05-20 00:11:26 +01:00
HoneyryderChuck
232b94590a grpc: added client and server cancellation request support 2021-05-07 16:55:48 +01:00
HoneyryderChuck
7a60346bf7 Added trailer header support for writing requests
Request can also add their own trailer headers, either explicitly via
Request#trailers , or via request lifecycle callbacks
2021-05-06 10:38:20 +01:00
HoneyryderChuck
c2a85311d4 fixed signature of expects\? 2021-01-09 17:28:02 +00:00
HoneyryderChuck
a675fde7dd enable singleton usage in rbs sigs 2020-12-02 01:30:38 +00:00
HoneyryderChuck
1e21c33da0 fixinng the signatures for the last rbs upstream 2020-11-24 00:42:54 +00:00
HoneyryderChuck
267f320fe0 updated signatures to use latest interface additions in rbs 2020-11-04 01:21:28 +00:00
HoneyryderChuck
936a8533a7 initial signatures for typed ruby 2020-10-27 17:00:44 +00:00