httpx 0.21.0 → 0.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +51 -33
  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 +7 -5
  15. data/doc/release_notes/0_21_1.md +12 -0
  16. data/doc/release_notes/0_22_0.md +13 -0
  17. data/lib/httpx/adapters/datadog.rb +1 -1
  18. data/lib/httpx/adapters/sentry.rb +1 -1
  19. data/lib/httpx/connection.rb +13 -1
  20. data/lib/httpx/extensions.rb +9 -1
  21. data/lib/httpx/plugins/authentication.rb +1 -1
  22. data/lib/httpx/plugins/aws_sigv4.rb +2 -2
  23. data/lib/httpx/plugins/basic_authentication.rb +1 -1
  24. data/lib/httpx/plugins/circuit_breaker/circuit.rb +1 -1
  25. data/lib/httpx/plugins/circuit_breaker.rb +1 -1
  26. data/lib/httpx/plugins/compression.rb +1 -1
  27. data/lib/httpx/plugins/cookies.rb +1 -1
  28. data/lib/httpx/plugins/digest_authentication.rb +1 -1
  29. data/lib/httpx/plugins/expect.rb +1 -1
  30. data/lib/httpx/plugins/follow_redirects.rb +1 -1
  31. data/lib/httpx/plugins/grpc.rb +1 -1
  32. data/lib/httpx/plugins/h2c.rb +1 -1
  33. data/lib/httpx/plugins/multipart/decoder.rb +1 -1
  34. data/lib/httpx/plugins/multipart.rb +2 -2
  35. data/lib/httpx/plugins/ntlm_authentication.rb +1 -1
  36. data/lib/httpx/plugins/persistent.rb +1 -1
  37. data/lib/httpx/plugins/proxy.rb +1 -1
  38. data/lib/httpx/plugins/push_promise.rb +1 -1
  39. data/lib/httpx/plugins/rate_limiter.rb +1 -1
  40. data/lib/httpx/plugins/response_cache.rb +1 -1
  41. data/lib/httpx/plugins/retries.rb +1 -1
  42. data/lib/httpx/pool.rb +1 -0
  43. data/lib/httpx/resolver/https.rb +2 -1
  44. data/lib/httpx/resolver/native.rb +17 -7
  45. data/lib/httpx/resolver/resolver.rb +13 -7
  46. data/lib/httpx/response.rb +2 -0
  47. data/lib/httpx/transcoder/xml.rb +0 -2
  48. data/lib/httpx/version.rb +1 -1
  49. data/sig/connection.rbs +2 -0
  50. data/sig/response.rbs +2 -1
  51. metadata +12 -8
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c62cb1d027ee7e62770de459b00411614372578117ea56354df0d9114cf4397b
4
- data.tar.gz: 18275725fc8adeac596f02f83f034dfcfe24a7e4c96ec34bc11400e8ca0e9567
3
+ metadata.gz: 193a22f95b5e48159faf27f4bd060abae29fe5c22dcddc3c462177a57aff7a2c
4
+ data.tar.gz: 3574cb0a3392127275872186db0ef4cbef139573710a093d61c420544f359a7e
5
5
  SHA512:
6
- metadata.gz: 840bf59a4cbbb45d26a836ccd4060007470d380314b4aedea58e49cb434b050a8252f7db3823daf9c2dfdb5d54075215e4ee1216c80852afbb7abfd57e1dfea2
7
- data.tar.gz: 35a666b92236240e8ccd09b1dc29a2ccf83061222b0511d35eee6fb7f3794dc737ca86ac9ca7d87ba01e03d8e648b07e6e52290b02b25674bd783b7f9d2cfbce
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
 
@@ -19,13 +19,17 @@ And also:
19
19
 
20
20
  * Compression (gzip, deflate, brotli)
21
21
  * Streaming Requests
22
- * Authentication (Basic Auth, Digest Auth)
22
+ * Authentication (Basic Auth, Digest Auth, NTLM)
23
23
  * Expect 100-continue
24
24
  * Multipart Requests
25
- * Cookies
25
+ * Advanced Cookie handling
26
26
  * HTTP/2 Server Push
27
- * H2C Upgrade
27
+ * HTTP/1.1 Upgrade (support for "h2c", "h2")
28
28
  * Automatic follow redirects
29
+ * GRPC
30
+ * WebDAV
31
+ * Circuit Breaker
32
+ * HTTP-based response cache
29
33
  * International Domain Names
30
34
 
31
35
  ## How
@@ -36,7 +40,14 @@ Here are some simple examples:
36
40
  HTTPX.get("https://nghttp2.org").to_s #=> "<!DOCT...."
37
41
  ```
38
42
 
39
- And that's the simplest one there is.
43
+ And that's the simplest one there is. But you can also do:
44
+
45
+ ```ruby
46
+ HTTPX.post("http://example.com", form: { user: "john", password: "pass" })
47
+
48
+ http = HTTPX.with(headers: { "x-my-name" => "joe" })
49
+ http.patch(("http://example.com/file", body: File.open("path/to/file")) # request body is streamed
50
+ ```
40
51
 
41
52
  If you want to do some more things with the response, you can get an `HTTPX::Response`:
42
53
 
@@ -50,7 +61,7 @@ puts body #=> #<HTTPX::Response ...
50
61
  You can also send as many requests as you want simultaneously:
51
62
 
52
63
  ```ruby
53
- page1, page2, page3 = HTTPX.get("https://news.ycombinator.com/news", "https://news.ycombinator.com/news?p=2", "https://news.ycombinator.com/news?p=3")
64
+ page1, page2, page3 =`HTTPX.get("https://news.ycombinator.com/news", "https://news.ycombinator.com/news?p=2", "https://news.ycombinator.com/news?p=3")
54
65
  ```
55
66
 
56
67
  ## Installation
@@ -73,43 +84,53 @@ and then just require it in your program:
73
84
  require "httpx"
74
85
  ```
75
86
 
76
- ## Why Should I care?
87
+ ## What makes it the best ruby HTTP client
77
88
 
78
- In Ruby, HTTP client implementations are a known cheap commodity. Why this one?
79
89
 
80
- ### Concurrency
90
+ ### Concurrency, HTTP/2 support
81
91
 
82
- This library supports HTTP/2 seamlessly (which means, if the request is secure, and the server support ALPN negotiation AND HTTP/2, the request will be made through HTTP/2). If you pass multiple URIs, and they can utilize the same connection, they will run concurrently in it.
92
+ `httpx` supports HTTP/2 (for "https" requests, it'll automatically do ALPN negotiation). However if the server supports HTTP/1.1, it will use HTTP pipelining, falling back to 1 request at a time if the server doesn't support it either (and it'll use Keep-Alive connections, unless the server does not support).
83
93
 
84
- However if the server supports HTTP/1.1, it will try to use HTTP pipelining, falling back to 1 request at a time if the server doesn't support it (if the server support Keep-Alive connections, it will reuse the same connection).
94
+ If you passed multiple URIs, it'll perform all of the requests concurrently, by mulitplexing on the necessary sockets (and it'll batch requests to the same socket when the origin is the same):
95
+
96
+ ```ruby
97
+ HTTPX.get(
98
+ "https://news.ycombinator.com/news",
99
+ "https://news.ycombinator.com/news?p=2",
100
+ "https://google.com/q=me"
101
+ ) # first two requests will be multiplexed on the same socket.
102
+ ```
85
103
 
86
104
  ### Clean API
87
105
 
88
106
  `httpx` builds all functions around the `HTTPX` module, so that all calls can compose of each other. Here are a few examples:
89
107
 
90
108
  ```ruby
91
- response = HTTPX.get("https://www.google.com")
92
- response = HTTPX.post("https://www.nghttp2.org/httpbin/post", params: {name: "John", age: "22"})
109
+ response = HTTPX.get("https://www.google.com", params: { q: "me" })
110
+ response = HTTPX.post("https://www.nghttp2.org/httpbin/post", form: {name: "John", age: "22"})
93
111
  response = HTTPX.plugin(:basic_authentication)
94
112
  .basic_authentication("user", "pass")
95
113
  .get("https://www.google.com")
114
+
115
+ # more complex client objects can be cached, and are thread-safe
116
+ http = HTTPX.plugin(:compression).plugin(:expect).with(headers: { "x-pvt-token" => "TOKEN"})
117
+ http.get("https://example.com") # the above options will apply
118
+ http.post("https://example2.com", form: {name: "John", age: "22"}) # same, plus the form POST body
96
119
  ```
97
120
 
98
121
  ### Lightweight
99
122
 
100
- It ships with a plugin system similar to the ones used by [sequel](https://github.com/jeremyevans/sequel), [roda](https://github.com/jeremyevans/roda) or [shrine](https://github.com/janko-m/shrine).
101
-
102
- It means that it loads the bare minimum to perform requests, and the user has to explicitly load the plugins, in order to get the features he/she needs.
123
+ It ships with most features published as a plugin, making vanilla `httpx` lightweight and dependency-free, while allowing you to "pay for what you use"
103
124
 
104
- It also means that it ships with the minimum amount of dependencies.
125
+ The plugin system is similar to the ones used by [sequel](https://github.com/jeremyevans/sequel), [roda](https://github.com/jeremyevans/roda) or [shrine](https://github.com/janko-m/shrine).
105
126
 
106
- ### DNS-over-HTTPS
127
+ ### Advanced DNS features
107
128
 
108
- `HTTPX` ships with custom DNS resolver implementations, including a DNS-over-HTTPS resolver.
129
+ `HTTPX` ships with custom DNS resolver implementations, including a native Happy Eyeballs resolver immplementation, and a DNS-over-HTTPS resolver.
109
130
 
110
- ## Easy to test
131
+ ## User-driven test suite
111
132
 
112
- The test suite runs against [httpbin proxied over nghttp2](https://nghttp2.org/httpbin/), so there are no mocking/stubbing false positives. The test suite uses [minitest](https://github.com/seattlerb/minitest), but its matchers usage is (almost) limited to `#assert` (`assert` is all you need).
133
+ The test suite runs against [httpbin proxied over nghttp2](https://nghttp2.org/httpbin/), so actual requests are performed during tests.
113
134
 
114
135
  ## Supported Rubies
115
136
 
@@ -120,25 +141,22 @@ All Rubies greater or equal to 2.1, and always latest JRuby and Truffleruby.
120
141
  ## Resources
121
142
  | | |
122
143
  | ------------- | --------------------------------------------------- |
123
- | Website | https://honeyryderchuck.gitlab.io/httpx/ |
124
- | Documentation | https://honeyryderchuck.gitlab.io/httpx/rdoc/ |
125
- | Wiki | https://gitlab.com/honeyryderchuck/httpx/wikis/home |
126
- | 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
+ | Rubygems | https://rubygems.org/gems/httpx |
127
149
 
128
150
  ## Caveats
129
151
 
130
152
  ### ALPN support
131
153
 
132
- `HTTPS` TLS backend is ruby's own `openssl` gem.
133
-
134
- If your requirement is to run requests over HTTP/2 and TLS, make sure you run a version of the gem which compiles OpenSSL 1.0.2 (Ruby 2.3 and higher are guaranteed to).
135
-
136
- In order to use HTTP/2 under JRuby, [check this link](https://gitlab.com/honeyryderchuck/httpx/-/wikis/JRuby-Truffleruby-Other-Rubies) to know what to do.
154
+ ALPN negotiation is required for "auto" HTTP/2 "https" requests. This is available in ruby since version 2.3 .
137
155
 
138
156
  ### Known bugs
139
157
 
140
- * Doesn't work with ruby 2.4.0 for Windows (see [#36](https://gitlab.com/honeyryderchuck/httpx/issues/36)).
141
- * 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).
142
160
 
143
161
  ## Versioning Policy
144
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,12 +4,12 @@
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
 
11
11
  * `:write_timeout`: total time (in seconds) to write a request to the server;
12
- * `:read_timeout`: total time (in seconds) to read aa response from the server;
12
+ * `:read_timeout`: total time (in seconds) to read a response from the server;
13
13
  * `:request_timeout`: tracks both of the above (time to write the request and read a response);
14
14
 
15
15
  ```ruby
@@ -22,10 +22,12 @@ 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
 
29
+ Read the wiki for more info about the defaults.
30
+
29
31
  ```ruby
30
32
  http = HTTPX.plugin(:circuit_breaker)
31
33
  # that's it!
@@ -34,7 +36,7 @@ http.get(...
34
36
 
35
37
  ### WebDAV plugin
36
38
 
37
- https://gitlab.com/honeyryderchuck/httpx/-/wikis/WebDav
39
+ https://gitlab.com/os85/httpx/-/wikis/WebDav
38
40
 
39
41
  The `:webdav` introduces some "convenience" methods to perform common WebDAV operations.
40
42
 
@@ -49,7 +51,7 @@ res = webdav.copy("/file.html", "/newdir/copy.html")
49
51
 
50
52
  ### XML transcoder, `:xml` option and `response.xml`
51
53
 
52
- A new transcoder was added fot the XML mime type, which requires `"nokogiri"` to be installed; it can both serialize Nokogiri nodes in a request, and parse response content into nokogiri nodes:
54
+ A new transcoder was added fot the XML mime type, which requires `"nokogiri"` to be installed. It can both serialize Nokogiri nodes in a request, and parse response content into nokogiri nodes:
53
55
 
54
56
  ```ruby
55
57
  response = HTTPX.post("https://xml-server.com", xml: Nokogiri::XML("<xml ..."))
@@ -0,0 +1,12 @@
1
+ # 0.21.1
2
+
3
+ ## Bugfixes
4
+
5
+ * fix: protecting tcp connect phase against low-level syscall errors
6
+ * such as network unreachable, which can happen if connectivity is lost meanwhile.
7
+ * native resolver: fix for nameserver switch not happening in case of DNS timeout.
8
+ * when more than a nameserver was advertised by the system.
9
+
10
+ ## Chore
11
+
12
+ * Removing usage of deprecated `Random::DEFAULT.rand` (using `Random.rand` instead)-
@@ -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)
@@ -512,9 +519,14 @@ module HTTPX
512
519
 
513
520
  def transition(nextstate)
514
521
  handle_transition(nextstate)
515
- rescue Errno::ECONNREFUSED,
522
+ rescue Errno::ECONNABORTED,
523
+ Errno::ECONNREFUSED,
524
+ Errno::ECONNRESET,
516
525
  Errno::EADDRNOTAVAIL,
517
526
  Errno::EHOSTUNREACH,
527
+ Errno::EINVAL,
528
+ Errno::ENETUNREACH,
529
+ Errno::EPIPE,
518
530
  TLSError => e
519
531
  # connect errors, exit gracefully
520
532
  handle_error(e)
@@ -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
@@ -28,7 +28,7 @@ module HTTPX
28
28
  nil
29
29
  when :half_open
30
30
  # return nothing or smth based on ratio
31
- return if Random::DEFAULT.rand >= @circuit_breaker_half_open_drip_rate
31
+ return if Random.rand >= @circuit_breaker_half_open_drip_rate
32
32
 
33
33
  @response
34
34
  when :open
@@ -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
@@ -13,14 +13,14 @@ module HTTPX
13
13
  **Resolv::DNS::Config.default_config_hash,
14
14
  packet_size: 512,
15
15
  timeouts: Resolver::RESOLVE_TIMEOUT,
16
- }.freeze
16
+ }
17
17
  else
18
18
  {
19
19
  nameserver: nil,
20
20
  **Resolv::DNS::Config.default_config_hash,
21
21
  packet_size: 512,
22
22
  timeouts: Resolver::RESOLVE_TIMEOUT,
23
- }.freeze
23
+ }
24
24
  end
25
25
 
26
26
  # nameservers for ipv6 are misconfigured in certain systems;
@@ -35,6 +35,8 @@ module HTTPX
35
35
  end
36
36
  end if DEFAULTS[:nameserver]
37
37
 
38
+ DEFAULTS.freeze
39
+
38
40
  DNS_PORT = 53
39
41
 
40
42
  def_delegator :@connections, :empty?
@@ -152,10 +154,21 @@ module HTTPX
152
154
  host = connection.origin.host
153
155
  timeout = (@timeouts[host][0] -= loop_time)
154
156
 
155
- return unless timeout.negative?
157
+ return unless timeout <= 0
156
158
 
157
159
  @timeouts[host].shift
158
- if @timeouts[host].empty?
160
+
161
+ if !@timeouts[host].empty?
162
+ log { "resolver: timeout after #{timeout}s, retry(#{@timeouts[host].first}) #{host}..." }
163
+ resolve(connection)
164
+ elsif @ns_index + 1 < @nameserver.size
165
+ # try on the next nameserver
166
+ @ns_index += 1
167
+ log { "resolver: failed resolving #{host} on nameserver #{@nameserver[@ns_index - 1]} (timeout error)" }
168
+ transition(:idle)
169
+ resolve(connection)
170
+ else
171
+
159
172
  @timeouts.delete(host)
160
173
  @queries.delete(h)
161
174
 
@@ -165,9 +178,6 @@ module HTTPX
165
178
  # This loop_time passed to the exception is bogus. Ideally we would pass the total
166
179
  # resolve timeout, including from the previous retries.
167
180
  raise ResolveTimeoutError.new(loop_time, "Timed out while resolving #{connection.origin.host}")
168
- else
169
- log { "resolver: timeout after #{timeout}s, retry(#{@timeouts[host].first}) #{host}..." }
170
- resolve(connection)
171
181
  end
172
182
  end
173
183
 
@@ -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.0"
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.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-08-14 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
@@ -87,6 +87,8 @@ extra_rdoc_files:
87
87
  - doc/release_notes/0_20_4.md
88
88
  - doc/release_notes/0_20_5.md
89
89
  - doc/release_notes/0_21_0.md
90
+ - doc/release_notes/0_21_1.md
91
+ - doc/release_notes/0_22_0.md
90
92
  - doc/release_notes/0_2_0.md
91
93
  - doc/release_notes/0_2_1.md
92
94
  - doc/release_notes/0_3_0.md
@@ -166,6 +168,8 @@ files:
166
168
  - doc/release_notes/0_20_4.md
167
169
  - doc/release_notes/0_20_5.md
168
170
  - doc/release_notes/0_21_0.md
171
+ - doc/release_notes/0_21_1.md
172
+ - doc/release_notes/0_22_0.md
169
173
  - doc/release_notes/0_2_0.md
170
174
  - doc/release_notes/0_2_1.md
171
175
  - doc/release_notes/0_3_0.md
@@ -353,15 +357,15 @@ files:
353
357
  - sig/transcoder/json.rbs
354
358
  - sig/transcoder/xml.rbs
355
359
  - sig/utils.rbs
356
- homepage: https://gitlab.com/honeyryderchuck/httpx
360
+ homepage: https://gitlab.com/os85/httpx
357
361
  licenses:
358
362
  - Apache 2.0
359
363
  metadata:
360
- bug_tracker_uri: https://gitlab.com/honeyryderchuck/httpx/issues
361
- changelog_uri: https://honeyryderchuck.gitlab.io/httpx/#release-notes
362
- documentation_uri: https://honeyryderchuck.gitlab.io/httpx/rdoc/
363
- source_code_uri: https://gitlab.com/honeyryderchuck/httpx
364
- 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/
365
369
  rubygems_mfa_required: 'true'
366
370
  post_install_message:
367
371
  rdoc_options: []