httpx 0.21.1 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +8 -8
  3. data/doc/release_notes/0_10_0.md +2 -2
  4. data/doc/release_notes/0_11_0.md +3 -5
  5. data/doc/release_notes/0_12_0.md +5 -5
  6. data/doc/release_notes/0_13_0.md +4 -4
  7. data/doc/release_notes/0_14_0.md +2 -2
  8. data/doc/release_notes/0_16_0.md +3 -3
  9. data/doc/release_notes/0_17_0.md +1 -1
  10. data/doc/release_notes/0_18_0.md +4 -4
  11. data/doc/release_notes/0_18_2.md +1 -1
  12. data/doc/release_notes/0_19_0.md +1 -1
  13. data/doc/release_notes/0_20_0.md +1 -1
  14. data/doc/release_notes/0_21_0.md +3 -3
  15. data/doc/release_notes/0_22_0.md +13 -0
  16. data/lib/httpx/adapters/datadog.rb +1 -1
  17. data/lib/httpx/adapters/sentry.rb +1 -1
  18. data/lib/httpx/connection.rb +7 -0
  19. data/lib/httpx/extensions.rb +9 -1
  20. data/lib/httpx/plugins/authentication.rb +1 -1
  21. data/lib/httpx/plugins/aws_sigv4.rb +2 -2
  22. data/lib/httpx/plugins/basic_authentication.rb +1 -1
  23. data/lib/httpx/plugins/circuit_breaker.rb +1 -1
  24. data/lib/httpx/plugins/compression.rb +1 -1
  25. data/lib/httpx/plugins/cookies.rb +1 -1
  26. data/lib/httpx/plugins/digest_authentication.rb +1 -1
  27. data/lib/httpx/plugins/expect.rb +1 -1
  28. data/lib/httpx/plugins/follow_redirects.rb +1 -1
  29. data/lib/httpx/plugins/grpc.rb +1 -1
  30. data/lib/httpx/plugins/h2c.rb +1 -1
  31. data/lib/httpx/plugins/multipart/decoder.rb +1 -1
  32. data/lib/httpx/plugins/multipart.rb +2 -2
  33. data/lib/httpx/plugins/ntlm_authentication.rb +1 -1
  34. data/lib/httpx/plugins/persistent.rb +1 -1
  35. data/lib/httpx/plugins/proxy.rb +1 -1
  36. data/lib/httpx/plugins/push_promise.rb +1 -1
  37. data/lib/httpx/plugins/rate_limiter.rb +1 -1
  38. data/lib/httpx/plugins/response_cache.rb +1 -1
  39. data/lib/httpx/plugins/retries.rb +1 -1
  40. data/lib/httpx/pool.rb +1 -0
  41. data/lib/httpx/resolver/https.rb +2 -1
  42. data/lib/httpx/resolver/resolver.rb +13 -7
  43. data/lib/httpx/response.rb +2 -0
  44. data/lib/httpx/transcoder/xml.rb +0 -2
  45. data/lib/httpx/version.rb +1 -1
  46. data/sig/connection.rbs +2 -0
  47. data/sig/response.rbs +2 -1
  48. metadata +11 -9
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1195773336c2fb0b92ed10abfafa8a99c7cfd19af31b932dbfff72d073ed3f47
4
- data.tar.gz: 634e9e62edcd8184d014b1870cbc303cdfcc8035e0c76431b10c1e9143bdbb23
3
+ metadata.gz: 193a22f95b5e48159faf27f4bd060abae29fe5c22dcddc3c462177a57aff7a2c
4
+ data.tar.gz: 3574cb0a3392127275872186db0ef4cbef139573710a093d61c420544f359a7e
5
5
  SHA512:
6
- metadata.gz: bee27d21eef64771e054b4517e99371462cc28fb1c5cad4353137e111e96a4d22131d573aa5c31fe6b86c7007466feec5d1181ae6787a3a6ef87459468d911c8
7
- data.tar.gz: 15fa97c4456ce2d8f875590075c9ceb778096aca70d27a793c5cafa026f038331439ac62fd823210290013c0466c072a2eff5c1a0a06b1c880254e542d3f9e16
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/honeyryderchuck/httpx/badges/master/pipeline.svg)](https://gitlab.com/honeyryderchuck/httpx/pipelines?page=1&scope=all&ref=master)
5
- [![coverage report](https://gitlab.com/honeyryderchuck/httpx/badges/master/coverage.svg?job=coverage)](https://honeyryderchuck.gitlab.io/httpx/coverage/#_AllFiles)
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://honeyryderchuck.gitlab.io/httpx/ |
145
- | Documentation | https://honeyryderchuck.gitlab.io/httpx/rdoc/ |
146
- | Wiki | https://honeyryderchuck.gitlab.io/httpx/wiki/home.html |
147
- | CI | https://gitlab.com/honeyryderchuck/httpx/pipelines |
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/honeyryderchuck/httpx/issues/36)).
159
- * Using `total_timeout` along with the `:persistent` plugin [does not work as you might expect](https://gitlab.com/honeyryderchuck/httpx/-/wikis/Timeouts#total_timeout).
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
 
@@ -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/honeyryderchuck/httpx/-/wikis/Stream
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/honeyryderchuck/httpx/-/wikis/Rate-Limiter
30
+ https://gitlab.com/os85/httpx/-/wikis/Rate-Limiter
31
31
 
32
32
  ### Ruby 3
33
33
 
@@ -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://honeyryderchuck.gitlab.io/httpx/wiki/Webmock-Adapter).
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://honeyryderchuck.gitlab.io/httpx/wiki/Datadog-Adapter).
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://honeyryderchuck.gitlab.io/httpx/wiki/Multipart-Uploads), including also about why this was made.
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
-
@@ -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/honeyryderchuck/httpx/-/wikis/AWS-Sigv4#sessionaws_sigv4_authentication
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/honeyryderchuck/httpx/-/wikis/AWS-Sigv4#sessionaws_sdk_authentication
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/honeyryderchuck/httpx/-/wikis/AWS-Sigv4#faqs
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/honeyryderchuck/httpx/-/wikis/JRuby-Truffleruby-Other-Rubies#http2
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
+ *
@@ -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/honeyryderchuck/httpx/-/blob/master/test/support/requests/plugins/upgrade.rb))
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://honeyryderchuck.gitlab.io/httpx/wiki/Connection-Upgrade).
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://honeyryderchuck.gitlab.io/httpx/wiki/Connection-Upgrade#h2c
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://honeyryderchuck.gitlab.io/httpx/wiki/Connection-Upgrade#h2
23
+ https://os85.gitlab.io/httpx/wiki/Connection-Upgrade#h2
24
24
 
25
25
  ### `:addresses` option
26
26
 
@@ -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://honeyryderchuck.gitlab.io/httpx/wiki/GRPC).
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
@@ -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/honeyryderchuck/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).
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/honeyryderchuck/httpx/-/wikis/Custom-Plugins
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/honeyryderchuck/httpx/-/blob/master/test/support/requests/plugins/cookies.rb .
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
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### Response mime type decoders (#json, #form)
6
6
 
7
- https://gitlab.com/honeyryderchuck/httpx/-/wikis/Response-Handling#response-decoding
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
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### Response Cache
6
6
 
7
- https://gitlab.com/honeyryderchuck/httpx/-/wikis/Response-Cache
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/honeyryderchuck/httpx/-/wikis/Retries#retry_jitter) option:
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/honeyryderchuck/httpx/-/merge_requests/165).
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/honeyryderchuck/httpx/-/merge_requests/166).
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.
@@ -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/honeyryderchuck/httpx/-/wikis/Timeouts#total_timeout.
10
+ The quirk of using the `:persistent` plugin with `:total_timeout` has been documented: https://gitlab.com/os85/httpx/-/wikis/Timeouts#total_timeout.
@@ -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://honeyryderchuck.gitlab.io/httpx/) to turn curl commands into the equivalent `httpx` code.
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
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### Sentry integration
6
6
 
7
- Documentation: https://gitlab.com/honeyryderchuck/httpx/-/wikis/Sentry-Adapter
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
 
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### `:write_timeout`, `:read_timeout` and `:request_timeout`
6
6
 
7
- https://gitlab.com/honeyryderchuck/httpx/-/wikis/Timeouts
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/honeyryderchuck/httpx/-/wikis/Circuit-Breaker
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/honeyryderchuck/httpx/-/wikis/WebDav
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?(::DDTrace) && ::DDTrace::VERSION::STRING >= "1.0.0"
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 = ::HTTPX.plugin(HTTPX::Plugins::Sentry)
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)
@@ -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)
@@ -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/honeyryderchuck/httpx/wikis/Authentication#authentication
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/honeyryderchuck/httpx/wikis/AWS-SigV4
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.each_with_object("".b) do |chunk, buffer|
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/honeyryderchuck/httpx/wikis/Authentication#basic-authentication
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/honeyryderchuck/httpx/wikis/Circuit-Breaker
8
+ # https://gitlab.com/os85/httpx/wikis/Circuit-Breaker
9
9
  #
10
10
  module CircuitBreaker
11
11
  using URIExtensions
@@ -10,7 +10,7 @@ module HTTPX
10
10
  #
11
11
  # It supports both *gzip* and *deflate*.
12
12
  #
13
- # https://gitlab.com/honeyryderchuck/httpx/wikis/Compression
13
+ # https://gitlab.com/os85/httpx/wikis/Compression
14
14
  #
15
15
  module Compression
16
16
  class << self
@@ -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/honeyryderchuck/httpx/wikis/Cookies
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/honeyryderchuck/httpx/wikis/Authentication#authentication
8
+ # https://gitlab.com/os85/httpx/wikis/Authentication#authentication
9
9
  #
10
10
  module DigestAuth
11
11
  DigestError = Class.new(Error)
@@ -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/honeyryderchuck/httpx/wikis/Expect#expect
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/honeyryderchuck/httpx/wikis/Follow-Redirects
14
+ # https://gitlab.com/os85/httpx/wikis/Follow-Redirects
15
15
  #
16
16
  module FollowRedirects
17
17
  MAX_REDIRECTS = 3
@@ -16,7 +16,7 @@ module HTTPX
16
16
  #
17
17
  # This plugin adds DSL to build GRPC interfaces.
18
18
  #
19
- # https://gitlab.com/honeyryderchuck/httpx/wikis/GRPC
19
+ # https://gitlab.com/os85/httpx/wikis/GRPC
20
20
  #
21
21
  module GRPC
22
22
  unless String.method_defined?(:underscore)
@@ -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/honeyryderchuck/httpx/wikis/Upgrade#h2c
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\-]*'[a-zA-Z0-9\-]*'#{EXTENDED_OTHER_VALUE}*/.freeze
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/honeyryderchuck/httpx/wikis/Multipart-Uploads
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://honeyryderchuck.gitlab.io/httpx/wiki/Multipart-Uploads.html#notes. \n\n" \
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
@@ -3,7 +3,7 @@
3
3
  module HTTPX
4
4
  module Plugins
5
5
  #
6
- # https://gitlab.com/honeyryderchuck/httpx/wikis/Authentication#ntlm-authentication
6
+ # https://gitlab.com/os85/httpx/wikis/Authentication#ntlm-authentication
7
7
  #
8
8
  module NTLMAuth
9
9
  class << self
@@ -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/honeyryderchuck/httpx/wikis/Persistent
18
+ # https://gitlab.com/os85/httpx/wikis/Persistent
19
19
  #
20
20
  module Persistent
21
21
  def self.load_dependencies(klass)
@@ -12,7 +12,7 @@ module HTTPX
12
12
  # * Socks4/4a proxies
13
13
  # * Socks5 proxies
14
14
  #
15
- # https://gitlab.com/honeyryderchuck/httpx/wikis/Proxy
15
+ # https://gitlab.com/os85/httpx/wikis/Proxy
16
16
  #
17
17
  module Proxy
18
18
  Error = HTTPProxyError
@@ -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/honeyryderchuck/httpx/wikis/Server-Push
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/honeyryderchuck/httpx/wikis/RateLimiter
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/honeyryderchuck/httpx/wikis/Response-Cache
8
+ # https://gitlab.com/os85/httpx/wikis/Response-Cache
9
9
  #
10
10
  module ResponseCache
11
11
  CACHEABLE_VERBS = %i[get head].freeze
@@ -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/honeyryderchuck/httpx/wikis/Retries
8
+ # https://gitlab.com/os85/httpx/wikis/Retries
9
9
  #
10
10
  module Retries
11
11
  MAX_RETRIES = 3
data/lib/httpx/pool.rb CHANGED
@@ -129,6 +129,7 @@ module HTTPX
129
129
  end
130
130
 
131
131
  def on_resolver_connection(connection)
132
+ @connections << connection unless @connections.include?(connection)
132
133
  found_connection = @connections.find do |ch|
133
134
  ch != connection && ch.mergeable?(connection)
134
135
  end
@@ -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
- emit_addresses(connection, @family, @uri_addresses)
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.addresses = addresses
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
 
@@ -128,6 +128,8 @@ module HTTPX
128
128
  end
129
129
 
130
130
  class Body
131
+ attr_reader :encoding
132
+
131
133
  def initialize(response, options)
132
134
  @response = response
133
135
  @headers = response.headers
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTPX
4
- VERSION = "0.21.1"
4
+ VERSION = "0.22.0"
5
5
  end
data/sig/connection.rbs CHANGED
@@ -36,6 +36,8 @@ module HTTPX
36
36
  @keep_alive_timeout: Numeric?
37
37
  @total_timeout: Numeric?
38
38
 
39
+ def clone_new_connection: () -> instance
40
+
39
41
  def addresses: () -> Array[ipaddr]?
40
42
 
41
43
  def addresses=: (Array[ipaddr]) -> void
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.21.1
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-10-03 00:00:00.000000000 Z
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/honeyryderchuck/httpx
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/honeyryderchuck/httpx/issues
363
- changelog_uri: https://honeyryderchuck.gitlab.io/httpx/#release-notes
364
- documentation_uri: https://honeyryderchuck.gitlab.io/httpx/rdoc/
365
- source_code_uri: https://gitlab.com/honeyryderchuck/httpx
366
- homepage_uri: https://honeyryderchuck.gitlab.io/httpx/
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.2.32
385
+ rubygems_version: 3.3.7
384
386
  signing_key:
385
387
  specification_version: 4
386
388
  summary: HTTPX, to the future, and beyond