212 Commits

Author SHA1 Message Date
HoneyryderChuck
587271ff77 improving sigs 2024-06-11 18:21:22 +01:00
HoneyryderChuck
2d6fde2e5d downgrade to udp when retrying dns queries 2024-06-11 16:27:51 +01:00
HoneyryderChuck
af6ce5dca4 fixing redirect_on sig 2024-06-09 19:40:28 +01:00
HoneyryderChuck
c6a63b55a9 allows for returning buffering to error response on loop error
in some situations on unexpected loop errors, read buffer may still contain response bytes to buffer, which couldn't be buffered to the error responses after error has propagated; this makes it possible by delegating bytes to wrapped response
2024-03-11 23:07:05 +00:00
HoneyryderChuck
ad14df6a7a Merge branch 'issue-287' into 'master'
native resolver will cleanly go from tcp to udp on CNAME resolution

Closes #287

See merge request os85/httpx!331
2024-02-29 14:08:03 +00:00
HoneyryderChuck
77006fd0c9 fix for not allowing default oauth auth method when setting grant type and scope
the oauth plugin already documents defaulting to client_secret_basic
2024-02-26 16:33:09 +00:00
HoneyryderChuck
bab19efcfe fix: make sure happy eyeballs cloned connections set the session callbacks
fixed an issue where a 421 response would not call the misredirected callback, as it wasn't being re-set in the cloned connection, therefore would be never called, and would hang...
2024-02-25 23:24:30 +00:00
HoneyryderChuck
4ad2c50143 bookkeep pool connections on Session#wrap
in order to only close connections initiated during the Session#wrap block, pool also wraps the block so that existing connections do not roll over

Closes #292
2024-01-26 02:11:03 +00:00
HoneyryderChuck
874bb6f1cf immprove h2c to not misuse max_concurrrent_requests
the h2c was relying heavily on rewriting connection options to only allow the first request to upgrade; this changes by instead changing the parser on first incoming request, so that if it's upgrade and contains the header, blocks the remainder until the upgrade is successful or not, and if it's not reverts the max concurrent requests anyway
2023-12-06 14:24:33 +00:00
HoneyryderChuck
3c060a4e8c simplifying connection initialization, while moving conn type calculation to init process 2023-12-05 19:41:49 +00:00
HoneyryderChuck
290db4847a promote HTTPProxyError to a ConnectionError so it is retriable
while not all of them are recoverable, the ones that aren't are raised very early in the request establishment phase; for the ones that are, such as socks4 or 5 connection phase errors, they're retried
2023-12-03 04:49:11 +00:00
HoneyryderChuck
7143245c37 raise error on user-code errors in callbacks
when users of the library code bugs in callbacks, they should not be ignored (as they were before this change), but they should also not be treated as timeouts and such, in that they should not be wrapped in an error response. they should fail loudly, ,i.e. raise

Closes #276
2023-12-02 00:49:52 +00:00
HoneyryderChuck
885bf947b5 deprecating callback methods on raw sessions 2023-12-02 00:49:52 +00:00
HoneyryderChuck
e29a91e7f7 move session callbacks to plugin 2023-12-02 00:49:51 +00:00
HoneyryderChuck
9bab254710 Merge branch 'add-before-redirect-hook' into 'master'
Add `before_redirect` to `follow_redirects` plugin

Closes #272

See merge request os85/httpx!296
2023-12-02 00:05:32 +00:00
HoneyryderChuck
b32f936365 Merge branch 'issue-250' into 'master'
ssrf filter plugin

Closes #250

See merge request os85/httpx!291
2023-12-02 00:04:38 +00:00
HoneyryderChuck
4809e1d0d0 Merge branch 'options-improvements' into 'master'
adding new Options#merge implementation

See merge request os85/httpx!297
2023-11-29 17:17:12 +00:00
HoneyryderChuck
529daa3c6f Merge branch 'resolve-eden' into 'master'
Remove eden, keep single store of connections

See merge request os85/httpx!295
2023-11-29 17:16:59 +00:00
HoneyryderChuck
79756e4ac4 small cleanup in type definitions and webmock testing 2023-11-22 11:07:54 +00:00
HoneyryderChuck
ee66b7e5cc stream plugin fix: do not preempt request
while stream requests are lazy, they were being nonetheless enqueued, before any function would be called. this was not great behaviour, as they could perhaps never been called, it also interfered with how other plugins inferred finished responses, such as the webmock adapter and follow_redirects. Another flaw in the grpc plugin was fixed as a result, given that bidirectional streams were actually being buffered
2023-11-19 23:58:27 +00:00
HoneyryderChuck
78c29804a1 fixing cookie-header-to-jar logic on options merge
because options can be now duped without being initialized
2023-11-19 22:38:27 +00:00
HoneyryderChuck
cce68bcd98 moved altsvc-specific connection behaviour to mixin
this mixin applies only for connections built via Session#build_altsvc_connection. This moves out logic which was always being called on the hot path for connections which hadn't been alt-svc enabled, which improves the Connection#match? bottleneck.
2023-11-19 22:38:25 +00:00
HoneyryderChuck
a27f735eb8 adding new Options#merge implementation
the new merge strategy tries to avoid allocating new objects, whereas the old one relied on transforming objects to hashes for merging, then back to Options objects, which just generated too much garbage. So the new one keeps the merging object as a hash if it can, and tries to bail out if there's nothing new to merge (empty or same objects). If there is new stuff, a shallow dup is called (dup will not dup all attributes by default, more on that later), and new attributes are then passed through the transformation-then-set pipeline (which duplicates this logic in two places now)

Because .dup creates a full shallow copy, extending classes for plugins needs to be taken into account, and these must also be duped when extendable. This has the benefit of sharing more classes across plugins
2023-11-19 22:37:20 +00:00
HoneyryderChuck
abe4997d44 moving logic to compare options ivars into separate function 2023-11-19 22:37:20 +00:00
Earlopain
8290afc737
Add redirect_on to follow_redirects plugin
Returning false from this callable will result in the redirect not
being followed.

Closes #272
2023-11-18 11:36:01 +01:00
HoneyryderChuck
6106f5cd43 allow early resolve errors to bubble up the session just like lack of nameserver 2023-11-17 23:39:59 +00:00
HoneyryderChuck
b6611ec321 bugfix: protect all find-connection-and-send-request calls from early-resolve errors
httpx uses throw/catch in order to save from so-called early resolve errors, i.e. errors which may happen before the name resolution process is either early-complete or setup, such as when there are no nameservers (internet turned off), and the requests were piped into the connection, which means they're outside of the 'on_error' callback reach. there errors were only covered on the initial send flow, i.e. in other situations when new connections may have to be established ad may early-fail, the throw would not be caught, and would reach user code
2023-11-17 23:38:39 +00:00
HoneyryderChuck
ffb24f71c6 remove authorization header when redirecting to different-origin urls
this is an old vuln fixed in curl (https://github.com/advisories/GHSA-7xmh-mw7w-rr97), which has been fixed for a long time, where credentials via authorization header would be resent on all follow location requests; this limits it to same-origin redirects; an option, "auth_to_other_origins", can be used to keep original behaviour
2023-11-17 15:16:52 +00:00
HoneyryderChuck
a9ecbec6f1 Merge branch 'issue-271' into 'master'
fix: stream + follow_redirects plugins working now

Closes #271

See merge request os85/httpx!299
2023-11-17 15:06:37 +00:00
HoneyryderChuck
8b80f15ee7 bugfix: allow stream responses to decode compressed content as well 2023-11-16 17:00:26 +00:00
Earlopain
ac21f563de Remove dependency on mutex_m 2023-11-16 12:38:22 +00:00
HoneyryderChuck
c150bd1341 fix: stream + follow_redirects plugins working now
stream responses weren't following redirects when both plugins were
loaded. This was due to the stream callback object not being passed
across the redirect chain.
2023-11-16 11:29:34 +00:00
HoneyryderChuck
ce7eb0b91a out with eden connections, keep closed around
connection bookkeeping on the pool changes, where all conections are kept around, even the ones that close during the scope of the requests; new requests may then find them, reset them, an reselect them. this is a major improvement, as objects get more reused, so less gc and object movement. this also changes the way pool terminates, as connections nonw follow a termination protocol, instead of just closing (which they can while scope is open)
2023-11-15 10:37:38 +00:00
HoneyryderChuck
100394b29c adding :close_handshake_timeout timeout option
used to monitor readiness of connection to write the last goaway frame from HTTP/2
2023-11-15 10:37:37 +00:00
HoneyryderChuck
d9a52ec795 readding DNS retries to native resolver
when they fail once, the whole thing crumbles, which breaks rate limit strategies from some known software

Fixes #257
2023-11-06 09:56:40 +00:00
HoneyryderChuck
1e05cdbe62 http/1.1 fix: close connection even if the server does not respect connectionn: close in request 2023-11-04 02:21:03 +00: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
489c7280ec cleaned up timeout setup logic by usign a shared function for the set/unset phases 2023-10-25 07:44:40 +01:00
HoneyryderChuck
d5e469d6c6 removing threshold size var from req body 2023-10-25 07:44:40 +01: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
6176afbf2c removing unneeded var 2023-10-24 22:53:59 +01:00
HoneyryderChuck
e4facd9b7a defaulting max requests to infinity
this limit wasn't doing any favours to anyone, particularly during benchmmarks
2023-10-24 22:53:22 +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
8bd4dc1fbd fix timers overhead causing spurious wakeups on the select loop
the change to read/write cancellation-driven timeouts as the default
timeout strategy revealed a performance regression; because these were
built on Timers, which never got unsubscribed, this meant that they were
kept beyond the duration of the request they were created for, and
needlessly got picked up for the next timeout tick.

This was fixed by adding a callback on timer intervals, which
unsubscribes them from the timer group when called; these would then be
activated after the timeout is not needed anymore (request send /
response received), thereby removing the overhead on subsequent
requests.

An additional intervals array is also kept in the connection itself;
timeouts from timers are signalled via socket wait calls, however they
were always resulting in timeouts, even when they shouldn't (ex: expect
timeout and send full response payload as a result), and with the wrong
exception class in some cases. By keeping intervals from its requests
around, and monitoring whether there are relevant request triggers, the
connection can therefore handle a timeout or bail out (so that timers
can fire the correct callback).
2023-10-24 22:53:22 +01:00
HoneyryderChuck
dbc7536724 fix for timeouts performance regression
since v1, performance has regressed due to the new default timeouts,
which are based on timers. That's because they were not being cleanup
after requests were done with, and were causing spurious wakeups in the
select loop after the fact.

Fixed by cleaning up each timer after each relevant request event.
2023-10-24 22:53:22 +01:00
HoneyryderChuck
f089d57d7d added rdoc to most public accessible classes 2023-10-14 16:02:11 +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
e4869e1a4b circuit-breaker plugin. fix half-open decision to emit real request
the previous logic was relying on a random order which didn't work in practice; instead, one now reuses the max-attempts to define how many requests happen in the half-open state, and the drip rate defines how may of them will be real
2023-09-27 18:12:56 +01:00
HoneyryderChuck
d856ae81e0 added missing release notes 2023-09-27 11:59:52 +01:00
HoneyryderChuck
085cec0c8e improve coverage and simplified faraday adapter
and some other modules
2023-09-20 17:57:41 +01:00