httpx 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/doc/release_notes/1_1_1.md +2 -2
- data/doc/release_notes/1_2_0.md +2 -2
- data/doc/release_notes/1_2_1.md +6 -0
- data/lib/httpx/buffer.rb +8 -0
- data/lib/httpx/chainable.rb +8 -0
- data/lib/httpx/connection.rb +11 -6
- data/lib/httpx/options.rb +1 -1
- data/lib/httpx/plugins/proxy.rb +2 -2
- data/lib/httpx/resolver/https.rb +7 -2
- data/lib/httpx/response/body.rb +3 -0
- data/lib/httpx/response.rb +3 -2
- data/lib/httpx/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e5ee54988be76a44ae512da359d83c502f8a43073f244a116a8fdc45fa7b87d
|
4
|
+
data.tar.gz: e3c08652a8d08eadbd1ef14b20005f93ff4131a712f8234c3eab94c7fce07167
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58f16e523d23215d89a8c873a5ce12491b52726073c334c4d9800e17e40dca8111ad43ab2467c37939a19bebbaa000c8db144fdbba87cc3d22cb699687df6699
|
7
|
+
data.tar.gz: 64dd9bb70af4173339019b62fa9f54fdf3f22c4bf593b51fb3de624844ac8a599a51b49cae10623aee8b8cff24af4dee69e39bedfec7da3d1ae229d733632e9c
|
data/README.md
CHANGED
@@ -136,7 +136,7 @@ The test suite runs against [httpbin proxied over nghttp2](https://nghttp2.org/h
|
|
136
136
|
|
137
137
|
All Rubies greater or equal to 2.7, and always latest JRuby and Truffleruby.
|
138
138
|
|
139
|
-
**Note**: This gem is tested against all latest patch versions, i.e. if you're using 3.
|
139
|
+
**Note**: This gem is tested against all latest patch versions, i.e. if you're using 3.3.0 and you experience some issue, please test it against 3.3.$latest before creating an issue.
|
140
140
|
|
141
141
|
## Resources
|
142
142
|
| | |
|
data/doc/release_notes/1_1_1.md
CHANGED
@@ -2,13 +2,13 @@
|
|
2
2
|
|
3
3
|
## improvements
|
4
4
|
|
5
|
-
* (Re-)enabling default retries in DNS name queries; this had been disabled as a result of revamping
|
5
|
+
* (Re-)enabling default retries in DNS name queries; this had been disabled as a result of revamping timeouts, and resulted in queries only being sent once, which is very little for UDP-related traffic, and breaks if using DNs rate-limiting software. Retries the query just once, for now.
|
6
6
|
|
7
7
|
## bugfixes
|
8
8
|
|
9
9
|
* reset timers when adding new intervals, as these may be added as a result on after-select connection handling, and must wait for the next tick cycle (before the patch, they were triggering too soon).
|
10
10
|
* fixed "on close" callback leak on connection reuse, which caused linear performance regression in benchmarks performing one request per connection.
|
11
|
-
* fixed hanging connection
|
11
|
+
* fixed hanging connection when an HTTP/1.1 emitted a "connection: close" header but the server would not emit one (it closes the connection now).
|
12
12
|
* fixed recursive dns cached lookups which may have already expired, and created nil entries in the returned address list.
|
13
13
|
* dns system resolver is now able to retry on failure.
|
14
14
|
|
data/doc/release_notes/1_2_0.md
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
### `:ssrf_filter` plugin
|
6
6
|
|
7
|
-
The `:ssrf_filter`
|
7
|
+
The `:ssrf_filter` plugin prevents server-side request forgery attacks, by blocking requests to the internal network. This is useful when the URLs used to perform requests aren’t under the developer control (such as when they are inserted via a web application form).
|
8
8
|
|
9
9
|
```ruby
|
10
10
|
http = HTTPX.plugin(:ssrf_filter)
|
@@ -31,7 +31,7 @@ More info under https://honeyryderchuck.gitlab.io/httpx/wiki/Callbacks
|
|
31
31
|
This option allows passing a callback which, when returning `false`, can interrupt the redirect loop.
|
32
32
|
|
33
33
|
```ruby
|
34
|
-
http = HTTPX.plugin(:follow_redirects).with(redirect_on: ->(location_uri) { BLACKLIST_HOSTS.include?(location_uri.host)
|
34
|
+
http = HTTPX.plugin(:follow_redirects).with(redirect_on: ->(location_uri) { BLACKLIST_HOSTS.include?(location_uri.host) })
|
35
35
|
```
|
36
36
|
|
37
37
|
### `:close_on_handshake_timeout` timeout
|
data/lib/httpx/buffer.rb
CHANGED
@@ -3,6 +3,14 @@
|
|
3
3
|
require "forwardable"
|
4
4
|
|
5
5
|
module HTTPX
|
6
|
+
# Internal class to abstract a string buffer, by wrapping a string and providing the
|
7
|
+
# minimum possible API and functionality required.
|
8
|
+
#
|
9
|
+
# buffer = Buffer.new(640)
|
10
|
+
# buffer.full? #=> false
|
11
|
+
# buffer << "aa"
|
12
|
+
# buffer.capacity #=> 638
|
13
|
+
#
|
6
14
|
class Buffer
|
7
15
|
extend Forwardable
|
8
16
|
|
data/lib/httpx/chainable.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module HTTPX
|
4
|
+
# Session mixin, implements most of the APIs that the users call.
|
5
|
+
# delegates to a default session when extended.
|
4
6
|
module Chainable
|
5
7
|
%w[head get post put delete trace options connect patch].each do |meth|
|
6
8
|
class_eval(<<-MOD, __FILE__, __LINE__ + 1)
|
@@ -10,6 +12,7 @@ module HTTPX
|
|
10
12
|
MOD
|
11
13
|
end
|
12
14
|
|
15
|
+
# delegates to the default session (see HTTPX::Session#request).
|
13
16
|
def request(*args, **options)
|
14
17
|
branch(default_options).request(*args, **options)
|
15
18
|
end
|
@@ -18,10 +21,12 @@ module HTTPX
|
|
18
21
|
with(headers: { "accept" => String(type) })
|
19
22
|
end
|
20
23
|
|
24
|
+
# delegates to the default session (see HTTPX::Session#wrap).
|
21
25
|
def wrap(&blk)
|
22
26
|
branch(default_options).wrap(&blk)
|
23
27
|
end
|
24
28
|
|
29
|
+
# returns a new instance loaded with the +pl+ plugin and +options+.
|
25
30
|
def plugin(pl, options = nil, &blk)
|
26
31
|
klass = is_a?(S) ? self.class : Session
|
27
32
|
klass = Class.new(klass)
|
@@ -29,16 +34,19 @@ module HTTPX
|
|
29
34
|
klass.plugin(pl, options, &blk).new
|
30
35
|
end
|
31
36
|
|
37
|
+
# returns a new instance loaded with +options+.
|
32
38
|
def with(options, &blk)
|
33
39
|
branch(default_options.merge(options), &blk)
|
34
40
|
end
|
35
41
|
|
36
42
|
private
|
37
43
|
|
44
|
+
# returns default instance of HTTPX::Options.
|
38
45
|
def default_options
|
39
46
|
@options || Session.default_options
|
40
47
|
end
|
41
48
|
|
49
|
+
# returns a default instance of HTTPX::Session.
|
42
50
|
def branch(options, &blk)
|
43
51
|
return self.class.new(options, &blk) if is_a?(S)
|
44
52
|
|
data/lib/httpx/connection.rb
CHANGED
@@ -228,11 +228,7 @@ module HTTPX
|
|
228
228
|
return if @state == :closing || @state == :closed
|
229
229
|
|
230
230
|
transition(:closing)
|
231
|
-
|
232
|
-
# handshakes, try sending
|
233
|
-
consume
|
234
|
-
@write_buffer.clear
|
235
|
-
end
|
231
|
+
|
236
232
|
transition(:closed)
|
237
233
|
end
|
238
234
|
|
@@ -566,6 +562,15 @@ module HTTPX
|
|
566
562
|
when :closing
|
567
563
|
return unless @state == :idle || @state == :open
|
568
564
|
|
565
|
+
unless @write_buffer.empty?
|
566
|
+
# preset state before handshake, as error callbacks
|
567
|
+
# may take it back here.
|
568
|
+
@state = nextstate
|
569
|
+
# handshakes, try sending
|
570
|
+
consume
|
571
|
+
@write_buffer.clear
|
572
|
+
return
|
573
|
+
end
|
569
574
|
when :closed
|
570
575
|
return unless @state == :closing
|
571
576
|
return unless @write_buffer.empty?
|
@@ -700,7 +705,7 @@ module HTTPX
|
|
700
705
|
interval = @timers.after(timeout, callback)
|
701
706
|
|
702
707
|
Array(finish_events).each do |event|
|
703
|
-
# clean up
|
708
|
+
# clean up request timeouts if the connection errors out
|
704
709
|
request.once(event) do
|
705
710
|
if @intervals.include?(interval)
|
706
711
|
interval.delete(callback)
|
data/lib/httpx/options.rb
CHANGED
@@ -99,7 +99,7 @@ module HTTPX
|
|
99
99
|
# :compress_request_body :: whether to auto-decompress response body (defaults to <tt>true</tt>)
|
100
100
|
# :timeout :: hash of timeout configurations (supports <tt>:connect_timeout</tt>, <tt>:settings_timeout</tt>,
|
101
101
|
# <tt>:operation_timeout</tt>, <tt>:keep_alive_timeout</tt>, <tt>:read_timeout</tt>, <tt>:write_timeout</tt>
|
102
|
-
#
|
102
|
+
# and <tt>:request_timeout</tt>
|
103
103
|
# :headers :: hash of HTTP headers (ex: <tt>{ "x-custom-foo" => "bar" }</tt>)
|
104
104
|
# :window_size :: number of bytes to read from a socket
|
105
105
|
# :buffer_size :: internal read and write buffer size in bytes
|
data/lib/httpx/plugins/proxy.rb
CHANGED
data/lib/httpx/resolver/https.rb
CHANGED
@@ -138,9 +138,14 @@ module HTTPX
|
|
138
138
|
# Indicates no such domain was found.
|
139
139
|
|
140
140
|
host = @requests.delete(request)
|
141
|
-
connection = reset_hostname(host)
|
141
|
+
connection = reset_hostname(host, reset_candidates: false)
|
142
142
|
|
143
|
-
|
143
|
+
unless @queries.value?(connection)
|
144
|
+
emit_resolve_error(connection)
|
145
|
+
return
|
146
|
+
end
|
147
|
+
|
148
|
+
resolve
|
144
149
|
when :dns_error
|
145
150
|
host = @requests.delete(request)
|
146
151
|
connection = reset_hostname(host)
|
data/lib/httpx/response/body.rb
CHANGED
@@ -166,6 +166,7 @@ module HTTPX
|
|
166
166
|
|
167
167
|
private
|
168
168
|
|
169
|
+
# prepares inflaters for the advertised encodings in "content-encoding" header.
|
169
170
|
def initialize_inflaters
|
170
171
|
@inflaters = nil
|
171
172
|
|
@@ -187,6 +188,7 @@ module HTTPX
|
|
187
188
|
end
|
188
189
|
end
|
189
190
|
|
191
|
+
# passes the +chunk+ through all inflaters to decode it.
|
190
192
|
def decode_chunk(chunk)
|
191
193
|
@inflaters.reverse_each do |inflater|
|
192
194
|
chunk = inflater.call(chunk)
|
@@ -195,6 +197,7 @@ module HTTPX
|
|
195
197
|
chunk
|
196
198
|
end
|
197
199
|
|
200
|
+
# tries transitioning the body STM to the +nextstate+.
|
198
201
|
def transition(nextstate)
|
199
202
|
case nextstate
|
200
203
|
when :open
|
data/lib/httpx/response.rb
CHANGED
@@ -70,9 +70,10 @@ module HTTPX
|
|
70
70
|
@body.write(data)
|
71
71
|
end
|
72
72
|
|
73
|
-
# returns the
|
73
|
+
# returns the HTTPX::ContentType for the response, as per what's declared in the content-type header.
|
74
74
|
#
|
75
|
-
# response.content_type #=> "text/plain"
|
75
|
+
# response.content_type #=> #<HTTPX::ContentType:xxx @header_value="text/plain">
|
76
|
+
# response.content_type.mime_type #=> "text/plain"
|
76
77
|
def content_type
|
77
78
|
@content_type ||= ContentType.new(@headers["content-type"])
|
78
79
|
end
|
data/lib/httpx/version.rb
CHANGED
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: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.0.
|
19
|
+
version: 1.0.3
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.0.
|
26
|
+
version: 1.0.3
|
27
27
|
description: A client library for making HTTP requests from Ruby.
|
28
28
|
email:
|
29
29
|
- cardoso_tiago@hotmail.com
|
@@ -138,6 +138,7 @@ extra_rdoc_files:
|
|
138
138
|
- doc/release_notes/1_1_4.md
|
139
139
|
- doc/release_notes/1_1_5.md
|
140
140
|
- doc/release_notes/1_2_0.md
|
141
|
+
- doc/release_notes/1_2_1.md
|
141
142
|
files:
|
142
143
|
- LICENSE.txt
|
143
144
|
- README.md
|
@@ -247,6 +248,7 @@ files:
|
|
247
248
|
- doc/release_notes/1_1_4.md
|
248
249
|
- doc/release_notes/1_1_5.md
|
249
250
|
- doc/release_notes/1_2_0.md
|
251
|
+
- doc/release_notes/1_2_1.md
|
250
252
|
- lib/httpx.rb
|
251
253
|
- lib/httpx/adapters/datadog.rb
|
252
254
|
- lib/httpx/adapters/faraday.rb
|