httpx 0.21.1 → 0.22.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +8 -8
- data/doc/release_notes/0_10_0.md +2 -2
- data/doc/release_notes/0_11_0.md +3 -5
- data/doc/release_notes/0_12_0.md +5 -5
- data/doc/release_notes/0_13_0.md +4 -4
- data/doc/release_notes/0_14_0.md +2 -2
- data/doc/release_notes/0_16_0.md +3 -3
- data/doc/release_notes/0_17_0.md +1 -1
- data/doc/release_notes/0_18_0.md +4 -4
- data/doc/release_notes/0_18_2.md +1 -1
- data/doc/release_notes/0_19_0.md +1 -1
- data/doc/release_notes/0_20_0.md +1 -1
- data/doc/release_notes/0_21_0.md +3 -3
- data/doc/release_notes/0_22_0.md +13 -0
- data/lib/httpx/adapters/datadog.rb +1 -1
- data/lib/httpx/adapters/sentry.rb +1 -1
- data/lib/httpx/connection.rb +7 -0
- data/lib/httpx/extensions.rb +9 -1
- data/lib/httpx/plugins/authentication.rb +1 -1
- data/lib/httpx/plugins/aws_sigv4.rb +2 -2
- data/lib/httpx/plugins/basic_authentication.rb +1 -1
- data/lib/httpx/plugins/circuit_breaker.rb +1 -1
- data/lib/httpx/plugins/compression.rb +1 -1
- data/lib/httpx/plugins/cookies.rb +1 -1
- data/lib/httpx/plugins/digest_authentication.rb +1 -1
- data/lib/httpx/plugins/expect.rb +1 -1
- data/lib/httpx/plugins/follow_redirects.rb +1 -1
- data/lib/httpx/plugins/grpc.rb +1 -1
- data/lib/httpx/plugins/h2c.rb +1 -1
- data/lib/httpx/plugins/multipart/decoder.rb +1 -1
- data/lib/httpx/plugins/multipart.rb +2 -2
- data/lib/httpx/plugins/ntlm_authentication.rb +1 -1
- data/lib/httpx/plugins/persistent.rb +1 -1
- data/lib/httpx/plugins/proxy.rb +1 -1
- data/lib/httpx/plugins/push_promise.rb +1 -1
- data/lib/httpx/plugins/rate_limiter.rb +1 -1
- data/lib/httpx/plugins/response_cache.rb +1 -1
- data/lib/httpx/plugins/retries.rb +1 -1
- data/lib/httpx/pool.rb +1 -0
- data/lib/httpx/resolver/https.rb +2 -1
- data/lib/httpx/resolver/resolver.rb +13 -7
- data/lib/httpx/response.rb +2 -0
- data/lib/httpx/transcoder/xml.rb +0 -2
- data/lib/httpx/version.rb +1 -1
- data/sig/connection.rbs +2 -0
- data/sig/response.rbs +2 -1
- metadata +11 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 193a22f95b5e48159faf27f4bd060abae29fe5c22dcddc3c462177a57aff7a2c
|
4
|
+
data.tar.gz: 3574cb0a3392127275872186db0ef4cbef139573710a093d61c420544f359a7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a72a33280f1d2bbe0a439e00bfdbcbcc70fef690e5d6cceb7f5f2a13bfec3db45e407733251bd03b47a02f138a96f059cefb1f35462a9dd049cc062c2b16c4e
|
7
|
+
data.tar.gz: cac069c954943fc756b81700c32e9a33eb76b4d27bd9e2ce29f83a9322c787012731b9f43298da64ea5a9f5df751405df209637fe9b069c4a49631a41abe9568
|
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# HTTPX: A Ruby HTTP library for tomorrow... and beyond!
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/httpx.svg)](http://rubygems.org/gems/httpx)
|
4
|
-
[![pipeline status](https://gitlab.com/
|
5
|
-
[![coverage report](https://gitlab.com/
|
4
|
+
[![pipeline status](https://gitlab.com/os85/httpx/badges/master/pipeline.svg)](https://gitlab.com/os85/httpx/pipelines?page=1&scope=all&ref=master)
|
5
|
+
[![coverage report](https://gitlab.com/os85/httpx/badges/master/coverage.svg?job=coverage)](https://os85.gitlab.io/httpx/coverage/#_AllFiles)
|
6
6
|
|
7
7
|
HTTPX is an HTTP client library for the Ruby programming language.
|
8
8
|
|
@@ -141,10 +141,10 @@ All Rubies greater or equal to 2.1, and always latest JRuby and Truffleruby.
|
|
141
141
|
## Resources
|
142
142
|
| | |
|
143
143
|
| ------------- | --------------------------------------------------- |
|
144
|
-
| Website | https://
|
145
|
-
| Documentation | https://
|
146
|
-
| Wiki | https://
|
147
|
-
| CI | https://gitlab.com/
|
144
|
+
| Website | https://os85.gitlab.io/httpx/ |
|
145
|
+
| Documentation | https://os85.gitlab.io/httpx/rdoc/ |
|
146
|
+
| Wiki | https://os85.gitlab.io/httpx/wiki/home.html |
|
147
|
+
| CI | https://gitlab.com/os85/httpx/pipelines |
|
148
148
|
| Rubygems | https://rubygems.org/gems/httpx |
|
149
149
|
|
150
150
|
## Caveats
|
@@ -155,8 +155,8 @@ ALPN negotiation is required for "auto" HTTP/2 "https" requests. This is availab
|
|
155
155
|
|
156
156
|
### Known bugs
|
157
157
|
|
158
|
-
* Doesn't work with ruby 2.4.0 for Windows (see [#36](https://gitlab.com/
|
159
|
-
* Using `total_timeout` along with the `:persistent` plugin [does not work as you might expect](https://gitlab.com/
|
158
|
+
* Doesn't work with ruby 2.4.0 for Windows (see [#36](https://gitlab.com/os85/httpx/issues/36)).
|
159
|
+
* Using `total_timeout` along with the `:persistent` plugin [does not work as you might expect](https://gitlab.com/os85/httpx/-/wikis/Timeouts#total_timeout).
|
160
160
|
|
161
161
|
## Versioning Policy
|
162
162
|
|
data/doc/release_notes/0_10_0.md
CHANGED
@@ -15,7 +15,7 @@ http.get(stream_api_endpoint, stream: true).each_line do |line|
|
|
15
15
|
end
|
16
16
|
```
|
17
17
|
|
18
|
-
https://gitlab.com/
|
18
|
+
https://gitlab.com/os85/httpx/-/wikis/Stream
|
19
19
|
|
20
20
|
### Rate Limiter
|
21
21
|
|
@@ -27,7 +27,7 @@ HTTPX.plugin(:rate_limiter).get(rate_limited_api_endpoint)
|
|
27
27
|
# waits 3 seconds before retrying
|
28
28
|
```
|
29
29
|
|
30
|
-
https://gitlab.com/
|
30
|
+
https://gitlab.com/os85/httpx/-/wikis/Rate-Limiter
|
31
31
|
|
32
32
|
### Ruby 3
|
33
33
|
|
data/doc/release_notes/0_11_0.md
CHANGED
@@ -21,7 +21,7 @@ stub_http_request(:get, "https://www.google.com").and_return(status: 200, body:
|
|
21
21
|
|
22
22
|
```
|
23
23
|
|
24
|
-
Read more about it in the [webmock integration documentation](https://
|
24
|
+
Read more about it in the [webmock integration documentation](https://os85.gitlab.io/httpx/wiki/Webmock-Adapter).
|
25
25
|
|
26
26
|
### Datadog Adapter
|
27
27
|
|
@@ -40,7 +40,7 @@ A trace will be emitted for every request, so this should be an interesting visu
|
|
40
40
|
|
41
41
|
Customization options and traces are similar to what [the net-http adapter provides](https://docs.datadoghq.com/tracing/setup_overview/setup/ruby/#nethttp).
|
42
42
|
|
43
|
-
Read more about it in the [datadog integration documentation](https://
|
43
|
+
Read more about it in the [datadog integration documentation](https://os85.gitlab.io/httpx/wiki/Datadog-Adapter).
|
44
44
|
|
45
45
|
## Improvements
|
46
46
|
|
@@ -52,7 +52,7 @@ Read more about it in the [datadog integration documentation](https://honeyryder
|
|
52
52
|
HTTPX.plugin(:multipart).post(uri, form: {file: File.new("path/to/file")})
|
53
53
|
```
|
54
54
|
|
55
|
-
Read more about it in the [multipart plugin documentation](https://
|
55
|
+
Read more about it in the [multipart plugin documentation](https://os85.gitlab.io/httpx/wiki/Multipart-Uploads), including also about why this was made.
|
56
56
|
|
57
57
|
### Expect Plugin
|
58
58
|
|
@@ -72,5 +72,3 @@ response = session.get(proxy_ip, headers: { "host" => upstream_hostname }, ssl:
|
|
72
72
|
## Bugfixes
|
73
73
|
|
74
74
|
A default 5 second timeout is in-place when using the DNS `:system` resolver, as it was found out that. when using the `resolv` library, the DNS query will not be retried otherwise. You can change this setting py passing `resolver_options: { timeouts: ANOTHER_TIMEOUT}`. In the future, this may become another timeout option, however.
|
75
|
-
|
76
|
-
|
data/doc/release_notes/0_12_0.md
CHANGED
@@ -6,19 +6,19 @@
|
|
6
6
|
|
7
7
|
A new plugin, `:aws_sigv4`, is now shipped with `httpx`. It implements the [AWS Signature Version 4 request signing process](https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html), a well documented way of authenticating requests to AWS services, which has since been adopted by other cloud providers, such as Google Cloud Storage.
|
8
8
|
|
9
|
-
See how to use it here: https://gitlab.com/
|
9
|
+
See how to use it here: https://gitlab.com/os85/httpx/-/wikis/AWS-Sigv4#sessionaws_sigv4_authentication
|
10
10
|
|
11
11
|
For convenience, there's a derivative plugin, `:aws_sdk_authentication`, which builds on top of `:aws_sigv4`, and integrates with the `aws-sdk-core` gem, maintained by AWS, to resolve the authentication credentials (p.ex. if you support ephemeral access keys).
|
12
12
|
|
13
|
-
See how to use it here: https://gitlab.com/
|
13
|
+
See how to use it here: https://gitlab.com/os85/httpx/-/wikis/AWS-Sigv4#sessionaws_sdk_authentication
|
14
14
|
|
15
|
-
Other FAQ: https://gitlab.com/
|
15
|
+
Other FAQ: https://gitlab.com/os85/httpx/-/wikis/AWS-Sigv4#faqs
|
16
16
|
|
17
17
|
### HTTP/2 support for JRuby
|
18
18
|
|
19
19
|
`jruby-openssl` doesn't support ALPN protocol negotiation, nor are there plans to implement, which limited the seamless HTTP/2 usage in `httpx`. A new connection adapter was therefore added specifically for JRuby, where ssl/tls connections will be handled using ffi-based openssl bindings, provided you bundle `ffi-compiler` and `concurrent-ruby`, and install a TLS/1.2-compatible `openssl` package.
|
20
20
|
|
21
|
-
See how to use it here: https://gitlab.com/
|
21
|
+
See how to use it here: https://gitlab.com/os85/httpx/-/wikis/JRuby-Truffleruby-Other-Rubies#http2
|
22
22
|
|
23
23
|
## Improvements
|
24
24
|
|
@@ -52,4 +52,4 @@ They all contributed to a massive performance improvement, itself reflected in t
|
|
52
52
|
* Fixed TCP handshake Errno::INPROGRESS handling inside TLS connnections, which was causing the process to hang in a high handshake contention scenario;
|
53
53
|
* Do not call the event loop if there's nothing to listen on (the DoH resolver was being listened on even if there was nothing to be request);
|
54
54
|
* Fixed double event registry for DoH resolvers;
|
55
|
-
*
|
55
|
+
*
|
data/doc/release_notes/0_13_0.md
CHANGED
@@ -4,9 +4,9 @@
|
|
4
4
|
|
5
5
|
### Upgrade plugin
|
6
6
|
|
7
|
-
A new plugin, `:upgrade`, is now available. This plugin allows one to "hook" on HTTP/1.1's protocol upgrade mechanism (see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism), which is the mechanism that browsers use to initiate websockets (there is an example of how to use `httpx` to start a websocket client connection [in the tests](https://gitlab.com/
|
7
|
+
A new plugin, `:upgrade`, is now available. This plugin allows one to "hook" on HTTP/1.1's protocol upgrade mechanism (see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Protocol_upgrade_mechanism), which is the mechanism that browsers use to initiate websockets (there is an example of how to use `httpx` to start a websocket client connection [in the tests](https://gitlab.com/os85/httpx/-/blob/master/test/support/requests/plugins/upgrade.rb))
|
8
8
|
|
9
|
-
You can read more about the `:upgrade` plugin in the [wiki](https://
|
9
|
+
You can read more about the `:upgrade` plugin in the [wiki](https://os85.gitlab.io/httpx/wiki/Connection-Upgrade).
|
10
10
|
|
11
11
|
It's the basis of two plugins:
|
12
12
|
|
@@ -14,13 +14,13 @@ It's the basis of two plugins:
|
|
14
14
|
|
15
15
|
This plugin was been rewritten on top of the `:upgrade` plugin, and handles upgrading a plaintext (non-"https") HTTP/1.1 connection, into an HTTP/2 connection.
|
16
16
|
|
17
|
-
https://
|
17
|
+
https://os85.gitlab.io/httpx/wiki/Connection-Upgrade#h2c
|
18
18
|
|
19
19
|
#### `:upgrade/h2`
|
20
20
|
|
21
21
|
This plugin handles when a server responds to a request with an `Upgrade: h2` header, does the following requests to the same origin via HTTP/2 prior knowledge (bypassing the necessity for ALPN negotiation, which is the whole point of the feature).
|
22
22
|
|
23
|
-
https://
|
23
|
+
https://os85.gitlab.io/httpx/wiki/Connection-Upgrade#h2
|
24
24
|
|
25
25
|
### `:addresses` option
|
26
26
|
|
data/doc/release_notes/0_14_0.md
CHANGED
@@ -17,7 +17,7 @@ helloworld_svc = helloworld_stub.rpc(:SayHello, HelloRequest, HelloReply)
|
|
17
17
|
result = helloworld_svc.say_hello(HelloRequest.new(name: "Jack")) #=> HelloReply: "Hello Jack"
|
18
18
|
```
|
19
19
|
|
20
|
-
You can read more about the `:grpc` plugin in the [wiki](https://
|
20
|
+
You can read more about the `:grpc` plugin in the [wiki](https://os85.gitlab.io/httpx/wiki/GRPC).
|
21
21
|
|
22
22
|
### :origin
|
23
23
|
|
@@ -37,7 +37,7 @@ httpbin.get("/httpbin/get") #=> #<Response:5420 HTTP/2.0 @status=200 ....
|
|
37
37
|
* setting an unexpected option will now raise an `HTTPX::Error` with an helpful message, instead of a confusing `NoMethodError`:
|
38
38
|
|
39
39
|
```ruby
|
40
|
-
HTTPX.with(foo: "bar")
|
40
|
+
HTTPX.with(foo: "bar")
|
41
41
|
# before
|
42
42
|
#=> NoMethodError
|
43
43
|
# after
|
data/doc/release_notes/0_16_0.md
CHANGED
@@ -16,7 +16,7 @@ response.body.to_s #=> ""
|
|
16
16
|
|
17
17
|
The justification for this behaviour probably had to do with avoiding keeping huge payloads around, but it got a bit lost in git history. It became a feature, not a bug.
|
18
18
|
|
19
|
-
However, I got an [issue report](https://gitlab.com/
|
19
|
+
However, I got an [issue report](https://gitlab.com/os85/httpx/-/issues/143) that made me change my mind about this behaviour (tl;dr: it broke pattern matching when matching against response bodies more than once).
|
20
20
|
|
21
21
|
So now, you can call `.to_s` how many times you want!
|
22
22
|
|
@@ -62,7 +62,7 @@ stub.get_feature(# ...
|
|
62
62
|
|
63
63
|
### OptionsMethods for plugins
|
64
64
|
|
65
|
-
https://gitlab.com/
|
65
|
+
https://gitlab.com/os85/httpx/-/wikis/Custom-Plugins
|
66
66
|
|
67
67
|
You can now define an `OptionsMethods` module under your custom plugin to define your own methods. The tl;dr is, that, given the following module below, a new `:bar` option will be available (and the method will be used to set it):
|
68
68
|
|
@@ -80,7 +80,7 @@ HTTPX.plugin(CustomPlugin).with(bar: 2)
|
|
80
80
|
|
81
81
|
The behaviour of the cookies jar from the `:cookies` plugin was a bit unpredictable in certain conditions, for instance if a "Cookie" header would be passed directly via `.with(headers: {"Cookie" => "a=1"})` and there'd be a value for it already (in same cases, it'd be fully ignored). This would even get worse, if the session had a jar, and a specific set of cookies would be passed to a request(i.e.: `session_with_cookies.get("http://url.get", headers: {"Cookies" => "..."}`).
|
82
82
|
|
83
|
-
The behaviour was fixed, and is now specced under https://gitlab.com/
|
83
|
+
The behaviour was fixed, and is now specced under https://gitlab.com/os85/httpx/-/blob/master/test/support/requests/plugins/cookies.rb .
|
84
84
|
|
85
85
|
## Bugfixes
|
86
86
|
|
data/doc/release_notes/0_17_0.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
### Response mime type decoders (#json, #form)
|
6
6
|
|
7
|
-
https://gitlab.com/
|
7
|
+
https://gitlab.com/os85/httpx/-/wikis/Response-Handling#response-decoding
|
8
8
|
|
9
9
|
Two new methods, `#json` and `#form`, were added to `HTTPX::Response`. As the name implies, they'll decode the raw payload into ruby objects you can work with.
|
10
10
|
|
data/doc/release_notes/0_18_0.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
### Response Cache
|
6
6
|
|
7
|
-
https://gitlab.com/
|
7
|
+
https://gitlab.com/os85/httpx/-/wikis/Response-Cache
|
8
8
|
|
9
9
|
The `:response_cache` plugin handles transparent usage of HTTP caching and conditional requests to improve performance and bandwidth usage.
|
10
10
|
|
@@ -22,7 +22,7 @@ r1.body == r2.body #=> true
|
|
22
22
|
|
23
23
|
On the `:retries` plugin, jitter calculation is now applied to the value in seconds defined by user after which a request should be retried (i.e. if `:retry_after` option is set to `2`, the retry interval may be `1.5422312` seconds, for example). This is important to avoid cases of synchronized "thundering herd", where server rejects requests, but they all get retried at the same time because the retry interval is exactly the same.
|
24
24
|
|
25
|
-
You can override the jitter calculation function by using the [:retry_jitter](https://gitlab.com/
|
25
|
+
You can override the jitter calculation function by using the [:retry_jitter](https://gitlab.com/os85/httpx/-/wikis/Retries#retry_jitter) option:
|
26
26
|
|
27
27
|
```ruby
|
28
28
|
HTTPX.plugin(:retries, retry_after: 2, retry_jitter: ->(interval) { interval + rand }) # interval is 3
|
@@ -44,7 +44,7 @@ end
|
|
44
44
|
|
45
45
|
## Improvements
|
46
46
|
|
47
|
-
* `webmock` adapter: added support for "stub_http_request#to_timeout" (https://gitlab.com/
|
47
|
+
* `webmock` adapter: added support for "stub_http_request#to_timeout" (https://gitlab.com/os85/httpx/-/merge_requests/165).
|
48
48
|
|
49
49
|
## timers not a dependency
|
50
50
|
|
@@ -57,7 +57,7 @@ The functionality provided by the `timers` gem was replaced by a simpler custom
|
|
57
57
|
|
58
58
|
## Bugfixes
|
59
59
|
|
60
|
-
* Fixed Error class declaration on response decoders when mime type is invalid (https://gitlab.com/
|
60
|
+
* Fixed Error class declaration on response decoders when mime type is invalid (https://gitlab.com/os85/httpx/-/merge_requests/166).
|
61
61
|
* `ErrorResponse#to_s` now removes ANSI escape sequences from error backtraces.
|
62
62
|
* Persistent connections were kept around both in the pool and in the selector; the first is necessary, but the second caused busy loop scenarios all over; they are now removed when no requests are being handled.
|
63
63
|
* Connections which failed connection handshake were removed from the pool, but not from the selector list, causing busy loop scenarios in a few cases; this has been fixed.
|
data/doc/release_notes/0_18_2.md
CHANGED
@@ -7,4 +7,4 @@
|
|
7
7
|
|
8
8
|
## Chore
|
9
9
|
|
10
|
-
The quirk of using the `:persistent` plugin with `:total_timeout` has been documented: https://gitlab.com/
|
10
|
+
The quirk of using the `:persistent` plugin with `:total_timeout` has been documented: https://gitlab.com/os85/httpx/-/wikis/Timeouts#total_timeout.
|
data/doc/release_notes/0_19_0.md
CHANGED
@@ -28,7 +28,7 @@ Connection coalescing has also been enabled for proxied connections (also `CONNE
|
|
28
28
|
|
29
29
|
### curl-to-httpx
|
30
30
|
|
31
|
-
widget in [project website](https://
|
31
|
+
widget in [project website](https://os85.gitlab.io/httpx/) to turn curl commands into the equivalent `httpx` code.
|
32
32
|
|
33
33
|
## Bugfixes
|
34
34
|
|
data/doc/release_notes/0_20_0.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
### Sentry integration
|
6
6
|
|
7
|
-
Documentation: https://gitlab.com/
|
7
|
+
Documentation: https://gitlab.com/os85/httpx/-/wikis/Sentry-Adapter
|
8
8
|
|
9
9
|
`httpx` ships with integration for `sentry-ruby` to provide HTTP request specific breadcrumbs and tracing. It can be enabled via:
|
10
10
|
|
data/doc/release_notes/0_21_0.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
### `:write_timeout`, `:read_timeout` and `:request_timeout`
|
6
6
|
|
7
|
-
https://gitlab.com/
|
7
|
+
https://gitlab.com/os85/httpx/-/wikis/Timeouts
|
8
8
|
|
9
9
|
The following timeouts are now supported:
|
10
10
|
|
@@ -22,7 +22,7 @@ None of them has a default value, in order not to break integrations, but that'l
|
|
22
22
|
|
23
23
|
### Circuit Breaker plugin
|
24
24
|
|
25
|
-
https://gitlab.com/
|
25
|
+
https://gitlab.com/os85/httpx/-/wikis/Circuit-Breaker
|
26
26
|
|
27
27
|
The `:circuit_breaker` plugin wraps around errors happening when performing HTTP requests, and support options for setting maximum number of attempts before circuit opens (`:circuit_breaker_max_attempts`), period after which attempts should be reset (`:circuit_breaker_reset_attempts_in`), timespan until circuit half-opens (`circuit_breaker_break_in`), respective half-open drip rate (`:circuit_breaker_half_open_drip_rate`), and a callback to do your own check on whether a response has failed, in case you want HTTP level errors to be marked as failed attempts (`:circuit_breaker_break_on`).
|
28
28
|
|
@@ -36,7 +36,7 @@ http.get(...
|
|
36
36
|
|
37
37
|
### WebDAV plugin
|
38
38
|
|
39
|
-
https://gitlab.com/
|
39
|
+
https://gitlab.com/os85/httpx/-/wikis/WebDav
|
40
40
|
|
41
41
|
The `:webdav` introduces some "convenience" methods to perform common WebDAV operations.
|
42
42
|
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# 0.22.0
|
2
|
+
|
3
|
+
## Improvements
|
4
|
+
|
5
|
+
### Happy Eyeballs v2 finalized
|
6
|
+
|
7
|
+
Until now, httpx was issuing concurrent DNS requests, but it'd only start connecting to the first, and then on the following by the right order, but sequentially.
|
8
|
+
|
9
|
+
`httpx` will now establish connections concurrently to both IPv6 and IPv4 addresses of a given domain; the first one to succeed terminates the other. Successful connection means completion of both TCP and TLS (when applicable) handshakes.
|
10
|
+
|
11
|
+
### HTTPX::Response::Body#encoding
|
12
|
+
|
13
|
+
A new method, `#encoding`, can be called on response bodies. It'll return the encoding of the response payload.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
if defined?(
|
3
|
+
if defined?(DDTrace) && DDTrace::VERSION::STRING >= "1.0.0"
|
4
4
|
require "datadog/tracing/contrib/integration"
|
5
5
|
require "datadog/tracing/contrib/configuration/settings"
|
6
6
|
require "datadog/tracing/contrib/patcher"
|
@@ -95,7 +95,7 @@ module HTTPX::Plugins
|
|
95
95
|
end
|
96
96
|
|
97
97
|
Sentry.register_patch do
|
98
|
-
sentry_session =
|
98
|
+
sentry_session = HTTPX.plugin(HTTPX::Plugins::Sentry)
|
99
99
|
|
100
100
|
HTTPX.send(:remove_const, :Session)
|
101
101
|
HTTPX.send(:const_set, :Session, sentry_session.class)
|
data/lib/httpx/connection.rb
CHANGED
@@ -76,6 +76,13 @@ module HTTPX
|
|
76
76
|
self.addresses = @options.addresses if @options.addresses
|
77
77
|
end
|
78
78
|
|
79
|
+
def clone_new_connection
|
80
|
+
new_conn = self.class.new(@type, @origin, @options)
|
81
|
+
once(:open, &new_conn.method(:reset))
|
82
|
+
new_conn.once(:open, &method(:close))
|
83
|
+
new_conn
|
84
|
+
end
|
85
|
+
|
79
86
|
# this is a semi-private method, to be used by the resolver
|
80
87
|
# to initiate the io object.
|
81
88
|
def addresses=(addrs)
|
data/lib/httpx/extensions.rb
CHANGED
@@ -55,6 +55,7 @@ module HTTPX
|
|
55
55
|
end
|
56
56
|
|
57
57
|
module NumericExtensions
|
58
|
+
# Ruby 2.4 backport
|
58
59
|
refine Numeric do
|
59
60
|
def infinite?
|
60
61
|
self == Float::INFINITY
|
@@ -64,6 +65,7 @@ module HTTPX
|
|
64
65
|
|
65
66
|
module StringExtensions
|
66
67
|
refine String do
|
68
|
+
# Ruby 2.5 backport
|
67
69
|
def delete_suffix!(suffix)
|
68
70
|
suffix = Backports.coerce_to_str(suffix)
|
69
71
|
chomp! if frozen?
|
@@ -80,6 +82,7 @@ module HTTPX
|
|
80
82
|
|
81
83
|
module HashExtensions
|
82
84
|
refine Hash do
|
85
|
+
# Ruby 2.4 backport
|
83
86
|
def compact
|
84
87
|
h = {}
|
85
88
|
each do |key, value|
|
@@ -93,7 +96,7 @@ module HTTPX
|
|
93
96
|
module ArrayExtensions
|
94
97
|
module FilterMap
|
95
98
|
refine Array do
|
96
|
-
|
99
|
+
# Ruby 2.7 backport
|
97
100
|
def filter_map
|
98
101
|
return to_enum(:filter_map) unless block_given?
|
99
102
|
|
@@ -107,6 +110,7 @@ module HTTPX
|
|
107
110
|
|
108
111
|
module Sum
|
109
112
|
refine Array do
|
113
|
+
# Ruby 2.6 backport
|
110
114
|
def sum(accumulator = 0, &block)
|
111
115
|
values = block_given? ? map(&block) : self
|
112
116
|
values.inject(accumulator, :+)
|
@@ -116,6 +120,7 @@ module HTTPX
|
|
116
120
|
|
117
121
|
module Intersect
|
118
122
|
refine Array do
|
123
|
+
# Ruby 3.1 backport
|
119
124
|
def intersect?(arr)
|
120
125
|
if size < arr.size
|
121
126
|
smaller = self
|
@@ -130,6 +135,7 @@ module HTTPX
|
|
130
135
|
|
131
136
|
module IOExtensions
|
132
137
|
refine IO do
|
138
|
+
# Ruby 2.3 backport
|
133
139
|
# provides a fallback for rubies where IO#wait isn't implemented,
|
134
140
|
# but IO#wait_readable and IO#wait_writable are.
|
135
141
|
def wait(timeout = nil, _mode = :read_write)
|
@@ -144,6 +150,7 @@ module HTTPX
|
|
144
150
|
|
145
151
|
module RegexpExtensions
|
146
152
|
refine(Regexp) do
|
153
|
+
# Ruby 2.4 backport
|
147
154
|
def match?(*args)
|
148
155
|
!match(*args).nil?
|
149
156
|
end
|
@@ -151,6 +158,7 @@ module HTTPX
|
|
151
158
|
end
|
152
159
|
|
153
160
|
module URIExtensions
|
161
|
+
# uri 0.11 backport, ships with ruby 3.1
|
154
162
|
refine URI::Generic do
|
155
163
|
def non_ascii_hostname
|
156
164
|
@non_ascii_hostname
|
@@ -6,7 +6,7 @@ module HTTPX
|
|
6
6
|
# This plugin adds a shim +authentication+ method to the session, which will fill
|
7
7
|
# the HTTP Authorization header.
|
8
8
|
#
|
9
|
-
# https://gitlab.com/
|
9
|
+
# https://gitlab.com/os85/httpx/wikis/Authentication#authentication
|
10
10
|
#
|
11
11
|
module Authentication
|
12
12
|
module InstanceMethods
|
@@ -7,7 +7,7 @@ module HTTPX
|
|
7
7
|
#
|
8
8
|
# https://docs.aws.amazon.com/general/latest/gr/signature-version-4.html
|
9
9
|
#
|
10
|
-
# https://gitlab.com/
|
10
|
+
# https://gitlab.com/os85/httpx/wikis/AWS-SigV4
|
11
11
|
#
|
12
12
|
module AWSSigV4
|
13
13
|
Credentials = Struct.new(:username, :password, :security_token)
|
@@ -115,7 +115,7 @@ module HTTPX
|
|
115
115
|
elsif value.respond_to?(:each)
|
116
116
|
digest = OpenSSL::Digest.new(@algorithm)
|
117
117
|
|
118
|
-
mb_buffer = value.each.
|
118
|
+
mb_buffer = value.each.with_object("".b) do |chunk, buffer|
|
119
119
|
buffer << chunk
|
120
120
|
break if buffer.bytesize >= 1024 * 1024
|
121
121
|
end
|
@@ -5,7 +5,7 @@ module HTTPX
|
|
5
5
|
#
|
6
6
|
# This plugin adds helper methods to implement HTTP Basic Auth (https://tools.ietf.org/html/rfc7617)
|
7
7
|
#
|
8
|
-
# https://gitlab.com/
|
8
|
+
# https://gitlab.com/os85/httpx/wikis/Authentication#basic-authentication
|
9
9
|
#
|
10
10
|
module BasicAuth
|
11
11
|
class << self
|
@@ -5,7 +5,7 @@ module HTTPX
|
|
5
5
|
#
|
6
6
|
# This plugin implements a circuit breaker around connection errors.
|
7
7
|
#
|
8
|
-
# https://gitlab.com/
|
8
|
+
# https://gitlab.com/os85/httpx/wikis/Circuit-Breaker
|
9
9
|
#
|
10
10
|
module CircuitBreaker
|
11
11
|
using URIExtensions
|
@@ -9,7 +9,7 @@ module HTTPX
|
|
9
9
|
#
|
10
10
|
# It also adds a *#cookies* helper, so that you can pre-fill the cookies of a session.
|
11
11
|
#
|
12
|
-
# https://gitlab.com/
|
12
|
+
# https://gitlab.com/os85/httpx/wikis/Cookies
|
13
13
|
#
|
14
14
|
module Cookies
|
15
15
|
def self.load_dependencies(*)
|
@@ -5,7 +5,7 @@ module HTTPX
|
|
5
5
|
#
|
6
6
|
# This plugin adds helper methods to implement HTTP Digest Auth (https://tools.ietf.org/html/rfc7616)
|
7
7
|
#
|
8
|
-
# https://gitlab.com/
|
8
|
+
# https://gitlab.com/os85/httpx/wikis/Authentication#authentication
|
9
9
|
#
|
10
10
|
module DigestAuth
|
11
11
|
DigestError = Class.new(Error)
|
data/lib/httpx/plugins/expect.rb
CHANGED
@@ -5,7 +5,7 @@ module HTTPX
|
|
5
5
|
#
|
6
6
|
# This plugin makes all HTTP/1.1 requests with a body send the "Expect: 100-continue".
|
7
7
|
#
|
8
|
-
# https://gitlab.com/
|
8
|
+
# https://gitlab.com/os85/httpx/wikis/Expect#expect
|
9
9
|
#
|
10
10
|
module Expect
|
11
11
|
EXPECT_TIMEOUT = 2
|
@@ -11,7 +11,7 @@ module HTTPX
|
|
11
11
|
#
|
12
12
|
# It also doesn't follow insecure redirects (https -> http) by default (see *follow_insecure_redirects*).
|
13
13
|
#
|
14
|
-
# https://gitlab.com/
|
14
|
+
# https://gitlab.com/os85/httpx/wikis/Follow-Redirects
|
15
15
|
#
|
16
16
|
module FollowRedirects
|
17
17
|
MAX_REDIRECTS = 3
|
data/lib/httpx/plugins/grpc.rb
CHANGED
data/lib/httpx/plugins/h2c.rb
CHANGED
@@ -6,7 +6,7 @@ module HTTPX
|
|
6
6
|
# This plugin adds support for upgrading a plaintext HTTP/1.1 connection to HTTP/2
|
7
7
|
# (https://tools.ietf.org/html/rfc7540#section-3.2)
|
8
8
|
#
|
9
|
-
# https://gitlab.com/
|
9
|
+
# https://gitlab.com/os85/httpx/wikis/Upgrade#h2c
|
10
10
|
#
|
11
11
|
module H2C
|
12
12
|
VALID_H2C_VERBS = %i[get options head].freeze
|
@@ -38,7 +38,7 @@ module HTTPX::Plugins
|
|
38
38
|
EXTENDED_OTHER_VALUE = /%[0-9a-fA-F]{2}|#{ATTRIBUTE_CHAR}/.freeze
|
39
39
|
EXTENDED_OTHER_PARAMETER = /(#{EXTENDED_OTHER_NAME})=(#{EXTENDED_OTHER_VALUE}*)/.freeze
|
40
40
|
EXTENDED_INITIAL_NAME = /#{ATTRIBUTE}(?:\*0)?\*/.freeze
|
41
|
-
EXTENDED_INITIAL_VALUE = /[a-zA-Z0-9
|
41
|
+
EXTENDED_INITIAL_VALUE = /[a-zA-Z0-9-]*'[a-zA-Z0-9-]*'#{EXTENDED_OTHER_VALUE}*/.freeze
|
42
42
|
EXTENDED_INITIAL_PARAMETER = /(#{EXTENDED_INITIAL_NAME})=(#{EXTENDED_INITIAL_VALUE})/.freeze
|
43
43
|
EXTENDED_PARAMETER = /#{EXTENDED_INITIAL_PARAMETER}|#{EXTENDED_OTHER_PARAMETER}/.freeze
|
44
44
|
DISPPARM = /;\s*(?:#{REGULAR_PARAMETER}|#{EXTENDED_PARAMETER})\s*/.freeze
|
@@ -7,7 +7,7 @@ module HTTPX
|
|
7
7
|
#
|
8
8
|
# HTTPX.post(URL, form: form: { image: HTTP::FormData::File.new("path/to/file")})
|
9
9
|
#
|
10
|
-
# https://gitlab.com/
|
10
|
+
# https://gitlab.com/os85/httpx/wikis/Multipart-Uploads
|
11
11
|
#
|
12
12
|
module Multipart
|
13
13
|
MULTIPART_VALUE_COND = lambda do |value|
|
@@ -29,7 +29,7 @@ module HTTPX
|
|
29
29
|
# in order not to break legacy code, we'll keep loading http/form_data for them.
|
30
30
|
require "http/form_data"
|
31
31
|
warn "httpx: http/form_data is no longer a requirement to use HTTPX :multipart plugin. See migration instructions under" \
|
32
|
-
"https://
|
32
|
+
"https://os85.gitlab.io/httpx/wiki/Multipart-Uploads.html#notes. \n\n" \
|
33
33
|
"If you'd like to stop seeing this message, require 'http/form_data' yourself."
|
34
34
|
end
|
35
35
|
rescue LoadError
|
@@ -15,7 +15,7 @@ module HTTPX
|
|
15
15
|
# This plugin is also not recommendable when connecting to >9000 (like, a lot) different origins.
|
16
16
|
# So when you use this, make sure that you don't fall into this trap.
|
17
17
|
#
|
18
|
-
# https://gitlab.com/
|
18
|
+
# https://gitlab.com/os85/httpx/wikis/Persistent
|
19
19
|
#
|
20
20
|
module Persistent
|
21
21
|
def self.load_dependencies(klass)
|
data/lib/httpx/plugins/proxy.rb
CHANGED
@@ -8,7 +8,7 @@ module HTTPX
|
|
8
8
|
# In order to benefit from this, requests are sent one at a time, so that
|
9
9
|
# no push responses are received after corresponding request has been sent.
|
10
10
|
#
|
11
|
-
# https://gitlab.com/
|
11
|
+
# https://gitlab.com/os85/httpx/wikis/Server-Push
|
12
12
|
#
|
13
13
|
module PushPromise
|
14
14
|
def self.extra_options(options)
|
@@ -9,7 +9,7 @@ module HTTPX
|
|
9
9
|
# * when the server is unavailable (503);
|
10
10
|
# * when a 3xx request comes with a "retry-after" value
|
11
11
|
#
|
12
|
-
# https://gitlab.com/
|
12
|
+
# https://gitlab.com/os85/httpx/wikis/RateLimiter
|
13
13
|
#
|
14
14
|
module RateLimiter
|
15
15
|
class << self
|
@@ -5,7 +5,7 @@ module HTTPX
|
|
5
5
|
#
|
6
6
|
# This plugin adds support for retrying requests when certain errors happen.
|
7
7
|
#
|
8
|
-
# https://gitlab.com/
|
8
|
+
# https://gitlab.com/os85/httpx/wikis/Response-Cache
|
9
9
|
#
|
10
10
|
module ResponseCache
|
11
11
|
CACHEABLE_VERBS = %i[get head].freeze
|
data/lib/httpx/pool.rb
CHANGED
data/lib/httpx/resolver/https.rb
CHANGED
@@ -69,7 +69,8 @@ module HTTPX
|
|
69
69
|
@building_connection = true
|
70
70
|
connection = @options.connection_class.new("ssl", @uri, @options.merge(ssl: { alpn_protocols: %w[h2] }))
|
71
71
|
@pool.init_connection(connection, @options)
|
72
|
-
|
72
|
+
# only explicity emit addresses if connection didn't pre-resolve, i.e. it's not an IP.
|
73
|
+
emit_addresses(connection, @family, @uri_addresses) unless connection.addresses
|
73
74
|
@building_connection = false
|
74
75
|
connection
|
75
76
|
end
|
@@ -63,20 +63,26 @@ module HTTPX
|
|
63
63
|
log { "resolver: A response, applying resolution delay..." }
|
64
64
|
@pool.after(0.05) do
|
65
65
|
# double emission check
|
66
|
-
unless connection.addresses && addresses.intersect?(connection.addresses)
|
67
|
-
|
68
|
-
connection.addresses = addresses
|
69
|
-
emit(:resolve, connection)
|
70
|
-
end
|
66
|
+
emit_resolved_connection(connection, addresses) unless connection.addresses && addresses.intersect?(connection.addresses)
|
71
67
|
end
|
72
68
|
else
|
73
|
-
connection
|
74
|
-
emit(:resolve, connection)
|
69
|
+
emit_resolved_connection(connection, addresses)
|
75
70
|
end
|
76
71
|
end
|
77
72
|
|
78
73
|
private
|
79
74
|
|
75
|
+
def emit_resolved_connection(connection, addresses)
|
76
|
+
if connection.io && connection.connecting? && @pool
|
77
|
+
new_connection = connection.clone_new_connection
|
78
|
+
@pool.init_connection(new_connection, connection.options)
|
79
|
+
connection = new_connection
|
80
|
+
end
|
81
|
+
connection.addresses = addresses
|
82
|
+
|
83
|
+
emit(:resolve, connection)
|
84
|
+
end
|
85
|
+
|
80
86
|
def early_resolve(connection, hostname: connection.origin.host)
|
81
87
|
addresses = @resolver_options[:cache] && (connection.addresses || HTTPX::Resolver.nolookup_resolve(hostname))
|
82
88
|
|
data/lib/httpx/response.rb
CHANGED
data/lib/httpx/transcoder/xml.rb
CHANGED
@@ -38,7 +38,6 @@ module HTTPX::Transcoder
|
|
38
38
|
begin
|
39
39
|
require "nokogiri"
|
40
40
|
|
41
|
-
# rubocop:disable Lint/DuplicateMethods
|
42
41
|
def decode(response)
|
43
42
|
content_type = response.content_type.mime_type
|
44
43
|
|
@@ -51,7 +50,6 @@ module HTTPX::Transcoder
|
|
51
50
|
raise HTTPX::Error, "\"nokogiri\" is required in order to decode XML"
|
52
51
|
end
|
53
52
|
end
|
54
|
-
# rubocop:enable Lint/DuplicateMethods
|
55
53
|
end
|
56
54
|
register "xml", Xml
|
57
55
|
end
|
data/lib/httpx/version.rb
CHANGED
data/sig/connection.rbs
CHANGED
data/sig/response.rbs
CHANGED
@@ -48,13 +48,14 @@ module HTTPX
|
|
48
48
|
include _ToS
|
49
49
|
include _ToStr
|
50
50
|
|
51
|
+
attr_reader encoding: String
|
52
|
+
|
51
53
|
@response: Response
|
52
54
|
@headers: Headers
|
53
55
|
@options: Options
|
54
56
|
@state: :idle | :memory | :buffer | :closed
|
55
57
|
@threshold_size: Integer
|
56
58
|
@window_size: Integer
|
57
|
-
@encoding: String
|
58
59
|
@length: Integer
|
59
60
|
@buffer: StringIO | Tempfile | nil
|
60
61
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httpx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.22.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|
@@ -88,6 +88,7 @@ extra_rdoc_files:
|
|
88
88
|
- doc/release_notes/0_20_5.md
|
89
89
|
- doc/release_notes/0_21_0.md
|
90
90
|
- doc/release_notes/0_21_1.md
|
91
|
+
- doc/release_notes/0_22_0.md
|
91
92
|
- doc/release_notes/0_2_0.md
|
92
93
|
- doc/release_notes/0_2_1.md
|
93
94
|
- doc/release_notes/0_3_0.md
|
@@ -168,6 +169,7 @@ files:
|
|
168
169
|
- doc/release_notes/0_20_5.md
|
169
170
|
- doc/release_notes/0_21_0.md
|
170
171
|
- doc/release_notes/0_21_1.md
|
172
|
+
- doc/release_notes/0_22_0.md
|
171
173
|
- doc/release_notes/0_2_0.md
|
172
174
|
- doc/release_notes/0_2_1.md
|
173
175
|
- doc/release_notes/0_3_0.md
|
@@ -355,15 +357,15 @@ files:
|
|
355
357
|
- sig/transcoder/json.rbs
|
356
358
|
- sig/transcoder/xml.rbs
|
357
359
|
- sig/utils.rbs
|
358
|
-
homepage: https://gitlab.com/
|
360
|
+
homepage: https://gitlab.com/os85/httpx
|
359
361
|
licenses:
|
360
362
|
- Apache 2.0
|
361
363
|
metadata:
|
362
|
-
bug_tracker_uri: https://gitlab.com/
|
363
|
-
changelog_uri: https://
|
364
|
-
documentation_uri: https://
|
365
|
-
source_code_uri: https://gitlab.com/
|
366
|
-
homepage_uri: https://
|
364
|
+
bug_tracker_uri: https://gitlab.com/os85/httpx/issues
|
365
|
+
changelog_uri: https://os85.gitlab.io/httpx/#release-notes
|
366
|
+
documentation_uri: https://os85.gitlab.io/httpx/rdoc/
|
367
|
+
source_code_uri: https://gitlab.com/os85/httpx
|
368
|
+
homepage_uri: https://os85.gitlab.io/httpx/
|
367
369
|
rubygems_mfa_required: 'true'
|
368
370
|
post_install_message:
|
369
371
|
rdoc_options: []
|
@@ -380,7 +382,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
380
382
|
- !ruby/object:Gem::Version
|
381
383
|
version: '0'
|
382
384
|
requirements: []
|
383
|
-
rubygems_version: 3.
|
385
|
+
rubygems_version: 3.3.7
|
384
386
|
signing_key:
|
385
387
|
specification_version: 4
|
386
388
|
summary: HTTPX, to the future, and beyond
|