1117 Commits

Author SHA1 Message Date
HoneyryderChuck
1e4177a079 allow connections to be closed before they even started, if some error coming from the parser requires it (can happen if user input is evaluated in httpx time and fails) 2021-09-27 16:18:02 +01:00
HoneyryderChuck
eb5bdc1fe6 telemetry: fixed visibility of #close; more log data 2021-09-27 16:18:02 +01:00
HoneyryderChuck
207ecb2da0 bugfix: making https resolver subscribe to the right pool
(such as when it's overwritten, such as in the case of SessionWithPool Module)
2021-09-27 16:18:02 +01:00
HoneyryderChuck
efddd72caa removing persistent connections from the selector whe inactive
keeping them around was resulting in some busy loops on timer events
(i.e. retry after), making them unreliable, innacurate  and CPU
draining. they're now kept out whenever they're inactive.
2021-09-27 16:18:02 +01:00
HoneyryderChuck
52948e0f83 bugfix: prevent stream close callback from being called 2 times
an issue was observed when stream was closed from our side, that the
the request in-flight count on the connection. This was fixed by not
reacting to :stream_closed events if request has been previously deleted.
2021-09-23 12:12:48 +01:00
HoneyryderChuck
81a41d889c bugfix: remove connections from selector which have been unregistered
during interest calculation

A quirk was found whereby a connection which failed while connecting
(such as the badssl test) was properly unregistered from the pool, was
however kept in the selectables selector pool, because if this operation
happening during the interest calculation pool, and the var substitution
being performed right afterwards, leaving the pool and selector out of
sync and causing all sorts of miscalculations around timers later on.
2021-09-22 12:53:33 +01:00
HoneyryderChuck
6425e5d8ee moved calculation of pool timeout to #next_timeout fully 2021-09-22 12:48:40 +01:00
HoneyryderChuck
c1881dc65b preparing for URI::HTTP#origin in mainline 2021-09-22 12:48:40 +01:00
HoneyryderChuck
bd1946999f improving retry logs 2021-09-22 12:48:40 +01:00
HoneyryderChuck
13e865e488 hiding monotonic time funcs under the utils API 2021-09-20 16:16:20 +01:00
HoneyryderChuck
27d81f3090 introduce custom timer to replace Timers::Group
The HTTPX::Timers class mimicks the same top-level API as its
predecessors, but simplifies its implementation. Adding a timer will
resort all timers, while lookups are roughly the same complexity. The
key difference is that callbacks are now aggregated by interval, i.e.
different requests setting the same timeout, will reuse the same timer.
This is a more simple design than Timers::Group, which stores timers in
a binary search tree; the latter will perform well in any environment,
whereas the first one is more tailored for the use-case of httpx, where
most of the times no timers will be set, and when they do, the same
timer will be reused for all requests because they usually have the same
set of options (and therefore timeouts).
2021-09-20 13:19:55 +01:00
HoneyryderChuck
9d861c3c2f total_timeout does not rely on Timers#after
Instead, timeout accounting is done using total_timeout math. It
supersedes all other timeouts in the connection, and will start from th
moment the connection is established.
2021-09-20 13:19:55 +01:00
HoneyryderChuck
b0e057c15d reworked the keep-alive timer logic to not rely on Timers#after 2021-09-20 13:19:55 +01:00
HoneyryderChuck
bdacaf1d41 Merge branch 'issue-153' into 'master'
Improving API compatibility and error checking in responses

Closes #156 and #153

See merge request honeyryderchuck/httpx!170
2021-09-20 12:19:32 +00:00
HoneyryderChuck
a31a315e08 deprecating ErrorResponse#status 2021-09-20 13:02:20 +01:00
HoneyryderChuck
f768cf7a0e Improving API compatibility and error checking in responses
* `Response#error`, which, coupled with `ErrorResponse#error`, allows
  for `if response.error` kind of conditional;
* `Response#raise_for_status` now returns the response when no error is
  raise (for method chaining);

Closes #153
2021-09-20 13:02:20 +01:00
HoneyryderChuck
cdce779e44 ErrorResponse#to_s should not contain tty color codes (Closes #152) 2021-09-20 13:01:59 +01:00
HoneyryderChuck
6e6c7848cc making jitter a retry plugin option 2021-09-20 12:37:48 +01:00
HoneyryderChuck
3b85678834 Merge branch 'issue-150' into 'master'
retries: apply some jitter on the retry after value

Closes #150

See merge request honeyryderchuck/httpx!167
2021-09-12 16:37:52 +00:00
HoneyryderChuck
579ee4d0cc retries: apply some jitter on the retry after value 2021-09-12 16:10:50 +01:00
HoneyryderChuck
d9e5c5b134 Merge branch 'add_webmock_to_timeout' into 'master'
Add support of WebMock's `stub_http_request#to_timeout`

See merge request honeyryderchuck/httpx!165
2021-09-10 17:31:54 +00:00
ojab
9f74a57112
Add support of WebMock's stub_http_request#to_timeout 2021-09-10 17:15:47 +00:00
ojab
6f3b11eb16
Fixup decoders content type checks 2021-09-10 15:53:38 +00:00
HoneyryderChuck
d350bebe81 integrating .sum and .filter_map + backports 2021-09-04 15:25:14 +01:00
HoneyryderChuck
0575c87dec added example blocks to class_eval defs 2021-09-03 12:52:26 +01:00
HoneyryderChuck
c95e926886 auto-corrected the easy ones first 2021-09-03 12:24:18 +01:00
HoneyryderChuck
b836d79c55 bump version to 0.17.0 2021-08-31 16:47:40 +01:00
HoneyryderChuck
74dfb18ed3 few extra changes to appease the type checker 2021-08-31 13:50:29 +01:00
HoneyryderChuck
b92829d025 do not needlessly forward method used only once 2021-08-31 13:50:29 +01:00
ojab
aa3be21c89
Remove response body finalizer
it's unnecessary, see discussion in
https://gitlab.com/honeyryderchuck/httpx/-/merge_requests/159
2021-08-30 14:07:36 +00:00
HoneyryderChuck
e435dd0534 prevent multiple declarations of the host header 2021-08-17 14:09:21 +01:00
HoneyryderChuck
f520785572 added content-type filtering to decoders 2021-08-10 13:50:34 +01:00
HoneyryderChuck
c7f177adbb added regexp extensions where using match? 2021-08-10 11:25:36 +01:00
HoneyryderChuck
e19041aaad no ned to call Kernel directly (at least, not anymore) 2021-08-10 11:10:45 +01:00
HoneyryderChuck
c4f5362156 making responses coercable to string 2021-08-10 11:10:45 +01:00
HoneyryderChuck
20db082db2 changing proc to lambda (just because of rbs) 2021-08-10 11:10:45 +01:00
HoneyryderChuck
802c47a037 multipart decoding: fail if no boundary found in header 2021-08-10 11:10:45 +01:00
HoneyryderChuck
e1ee8c69dc proxy: fixing proxy resolve error filtering to also work with system resolver 2021-08-10 11:10:45 +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
556c94a575 added multipart decooder, which overtakes on Response#form for multipart payloads 2021-08-09 15:54:25 +01:00
HoneyryderChuck
f2d3c1f09b added Response#form (supports only x-www-urlencoded for now) 2021-08-09 15:54:25 +01:00
HoneyryderChuck
a85828d0d5 added Response#json 2021-08-09 15:54:24 +01:00
HoneyryderChuck
c9de63d4cd bumped version to 0.16.1 2021-08-09 15:54:16 +01:00
HoneyryderChuck
582447f10e bugfix: fixed native resolver timeout when dealing with absolute DNS
names

DNS answers are decoded using `resolv` internal structures. In this
particular case, we were using `Resolv::DNS::Name#to_s` to infer the
query dns name an answer refers to. This failed, because, as per
documentaation:

```ruby
p Resolv::DNS::Name.create("x.y.z.").to_s #=> "x.y.z"
p Resolv::DNS::Name.create("x.y.z").to_s #=> "x.y.z"
```

this caused issues when marking the DNS resolving as done. As a fix, I
applied the same logic from `Resolv::DNS::Name#inspect`. which correctly
prints absolute names.

Fixes #145
2021-08-09 13:36:49 +01:00
HoneyryderChuck
f9c17af6f3 save against file handle from system resolve being closed abruptly 2021-08-05 23:29:49 +01:00
HoneyryderChuck
48a2d82c34 http2 connection: removed interests calculation traversing requests
the traversal seems unnnecessary, given the subsequent cheaper checks. A
request with a stream will always be writable unless it's done, or is
expecting a 1xx response; however, there'll be drains in place, and
that's a cheaper check.
2021-08-05 22:52:58 +01:00
HoneyryderChuck
59755d7d01 connection: avoid calculating interests when there was nothing that could have changed the result 2021-08-05 22:51:16 +01:00
HoneyryderChuck
63c39a4032 fixed respond_to_missing? sig 2021-08-05 15:03:50 +01:00
HoneyryderChuck
65261217b1 optimization for calculation whether parser is empty
This avoids traversing all requests in the parser. this is possible for
HTTP/1.1 because, given that requests are sequentially concluded, one
can get away with checking only first and last request state.
2021-08-05 15:03:49 +01:00
HoneyryderChuck
3d549817cb optimization on build_request to reduce Options object allocations on
multi-request calls

request options already get aggregated in #build_requests. this
optimization removes the Options object rebuild for each request,
thereby sharing the same across concurrent requests.

this is possible because, although #build_request is public, we document
it only with passing hash of options, never an Options object. This
would probably result in errors.
2021-08-05 15:03:49 +01:00