httpx 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/httpx/connection.rb +21 -8
- data/lib/httpx/connection/http1.rb +2 -0
- data/lib/httpx/connection/http2.rb +7 -2
- data/lib/httpx/extensions.rb +4 -3
- data/lib/httpx/io/ssl.rb +1 -1
- data/lib/httpx/pool.rb +1 -0
- data/lib/httpx/resolver/resolver_mixin.rb +1 -1
- data/lib/httpx/session.rb +10 -14
- data/lib/httpx/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b31d47dee309cce01caf25b3bc2f9fe51f602e9e2b07318c0903dee4b6d5b0c2
|
4
|
+
data.tar.gz: 18d8eb569ef7b5cf989ee61a85ed747cf9ceb1098d37e102fe7a721ae00675d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2fd3831074357bc36389c299f257f1b14cd70f94d3491125bc54ef67e485dac66f9f2457b013a25c7b298a6926cb0bb92436cf07f3e9bd1d9f5e850f63fa443
|
7
|
+
data.tar.gz: 498440a319ff97e08236dde05cd6413723e17f6be9b4d4ce110b59fe88e4da0a9254cbd639adc28a6c81a6183eb70fbd7dd38719716c480d00addfed409ca446
|
data/lib/httpx/connection.rb
CHANGED
@@ -80,7 +80,16 @@ module HTTPX
|
|
80
80
|
def match?(uri, options)
|
81
81
|
return false if @state == :closing || @state == :closed
|
82
82
|
|
83
|
-
(
|
83
|
+
(
|
84
|
+
(
|
85
|
+
@origins.include?(uri.origin) &&
|
86
|
+
# if there is more than one origin to match, it means that this connection
|
87
|
+
# was the result of coalescing. To prevent blind trust in the case where the
|
88
|
+
# origin came from an ORIGIN frame, we're going to verify the hostname with the
|
89
|
+
# SSL certificate
|
90
|
+
(@origins.size == 1 || @origin == uri.origin || (@io && @io.verify_hostname(uri.host)))
|
91
|
+
) || match_altsvcs?(uri)
|
92
|
+
) && @options == options
|
84
93
|
end
|
85
94
|
|
86
95
|
def mergeable?(connection)
|
@@ -102,8 +111,8 @@ module HTTPX
|
|
102
111
|
def merge(connection)
|
103
112
|
@origins += connection.instance_variable_get(:@origins)
|
104
113
|
pending = connection.instance_variable_get(:@pending)
|
105
|
-
pending.each do |req
|
106
|
-
send(req
|
114
|
+
pending.each do |req|
|
115
|
+
send(req)
|
107
116
|
end
|
108
117
|
end
|
109
118
|
|
@@ -121,7 +130,7 @@ module HTTPX
|
|
121
130
|
def purge_pending
|
122
131
|
[@parser.pending, @pending].each do |pending|
|
123
132
|
pending.reject! do |request, *args|
|
124
|
-
yield(request, args)
|
133
|
+
yield(request, args) if block_given?
|
125
134
|
end
|
126
135
|
end
|
127
136
|
end
|
@@ -129,10 +138,11 @@ module HTTPX
|
|
129
138
|
# checks if this is connection is an alternative service of
|
130
139
|
# +uri+
|
131
140
|
def match_altsvcs?(uri)
|
132
|
-
|
133
|
-
origin
|
134
|
-
|
135
|
-
|
141
|
+
@origins.any? { |origin| uri.altsvc_match?(origin) } ||
|
142
|
+
AltSvc.cached_altsvc(@origin).any? do |altsvc|
|
143
|
+
origin = altsvc["origin"]
|
144
|
+
origin.altsvc_match?(uri.origin)
|
145
|
+
end
|
136
146
|
end
|
137
147
|
|
138
148
|
def connecting?
|
@@ -274,6 +284,9 @@ module HTTPX
|
|
274
284
|
parser.on(:promise) do |request, stream|
|
275
285
|
request.emit(:promise, parser, stream)
|
276
286
|
end
|
287
|
+
parser.on(:origin) do |origin|
|
288
|
+
@origins << origin
|
289
|
+
end
|
277
290
|
parser.on(:close) do
|
278
291
|
transition(:closing)
|
279
292
|
end
|
@@ -41,7 +41,7 @@ module HTTPX
|
|
41
41
|
|
42
42
|
def send(request, **)
|
43
43
|
if !@handshake_completed ||
|
44
|
-
@
|
44
|
+
@streams.size >= @max_concurrent_requests
|
45
45
|
@pending << request
|
46
46
|
return
|
47
47
|
end
|
@@ -107,6 +107,7 @@ module HTTPX
|
|
107
107
|
@connection.on(:frame, &method(:on_frame))
|
108
108
|
@connection.on(:frame_sent, &method(:on_frame_sent))
|
109
109
|
@connection.on(:frame_received, &method(:on_frame_received))
|
110
|
+
@connection.on(:origin, &method(:on_origin))
|
110
111
|
@connection.on(:promise, &method(:on_promise))
|
111
112
|
@connection.on(:altsvc) { |frame| on_altsvc(frame[:origin], frame) }
|
112
113
|
@connection.on(:settings_ack, &method(:on_settings))
|
@@ -224,7 +225,7 @@ module HTTPX
|
|
224
225
|
emit(:error, request, ex)
|
225
226
|
end
|
226
227
|
end
|
227
|
-
return unless @connection.state == :closed && @
|
228
|
+
return unless @connection.state == :closed && @streams.size.zero?
|
228
229
|
|
229
230
|
emit(:close)
|
230
231
|
end
|
@@ -265,6 +266,10 @@ module HTTPX
|
|
265
266
|
emit(:promise, @streams.key(stream.parent), stream)
|
266
267
|
end
|
267
268
|
|
269
|
+
def on_origin(origin)
|
270
|
+
emit(:origin, origin)
|
271
|
+
end
|
272
|
+
|
268
273
|
def respond_to_missing?(meth, *args)
|
269
274
|
@connection.respond_to?(meth, *args) || super
|
270
275
|
end
|
data/lib/httpx/extensions.rb
CHANGED
@@ -67,10 +67,11 @@ module HTTPX
|
|
67
67
|
|
68
68
|
def altsvc_match?(uri)
|
69
69
|
uri = URI.parse(uri)
|
70
|
-
|
70
|
+
|
71
|
+
origin == uri.origin || begin
|
71
72
|
case scheme
|
72
|
-
when
|
73
|
-
uri.scheme == "https" &&
|
73
|
+
when "h2"
|
74
|
+
(uri.scheme == "https" || uri.scheme == "h2") &&
|
74
75
|
host == uri.host &&
|
75
76
|
(port || default_port) == (uri.port || uri.default_port)
|
76
77
|
else
|
data/lib/httpx/io/ssl.rb
CHANGED
@@ -30,7 +30,7 @@ module HTTPX
|
|
30
30
|
|
31
31
|
def verify_hostname(host)
|
32
32
|
return false if @ctx.verify_mode == OpenSSL::SSL::VERIFY_NONE
|
33
|
-
return false if @io.peer_cert.nil?
|
33
|
+
return false if !@io.respond_to?(:peer_cert) || @io.peer_cert.nil?
|
34
34
|
|
35
35
|
OpenSSL::SSL.verify_certificate_identity(@io.peer_cert, host)
|
36
36
|
end
|
data/lib/httpx/pool.rb
CHANGED
@@ -32,7 +32,7 @@ module HTTPX
|
|
32
32
|
end
|
33
33
|
log(label: "resolver: ") { "answer #{connection.origin.host}: #{addresses.inspect}" }
|
34
34
|
connection.addresses = addresses
|
35
|
-
emit(:resolve, connection)
|
35
|
+
catch(:coalesced) { emit(:resolve, connection) }
|
36
36
|
end
|
37
37
|
|
38
38
|
def early_resolve(connection, hostname: connection.origin.host)
|
data/lib/httpx/session.rb
CHANGED
@@ -93,15 +93,12 @@ module HTTPX
|
|
93
93
|
# incidentally, all requests will be re-routed to the first
|
94
94
|
# advertised alt-svc, which incidentally follows the spec.
|
95
95
|
existing_connection.purge_pending do |request|
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
if is_idle
|
100
|
-
log(level: 1) { "#{origin} alt-svc: sending #{request.uri} to #{alt_origin}" }
|
101
|
-
connection.send(request)
|
102
|
-
end
|
103
|
-
is_idle
|
96
|
+
request.origin == origin &&
|
97
|
+
request.state == :idle &&
|
98
|
+
!request.headers.key?("alt-used")
|
104
99
|
end
|
100
|
+
|
101
|
+
connection.merge(existing_connection)
|
105
102
|
rescue UnsupportedSchemeError
|
106
103
|
altsvc["noop"] = true
|
107
104
|
end
|
@@ -137,18 +134,17 @@ module HTTPX
|
|
137
134
|
case uri.scheme
|
138
135
|
when "http"
|
139
136
|
"tcp"
|
140
|
-
when "https"
|
141
|
-
"ssl"
|
142
|
-
when "h2"
|
143
|
-
options = options.merge(ssl: { alpn_protocols: %w[h2] })
|
137
|
+
when "https", "h2"
|
144
138
|
"ssl"
|
145
139
|
else
|
146
140
|
raise UnsupportedSchemeError, "#{uri}: #{uri.scheme}: unsupported URI scheme"
|
147
141
|
end
|
148
142
|
end
|
149
143
|
connection = options.connection_class.new(type, uri, options)
|
150
|
-
|
151
|
-
|
144
|
+
catch(:coalesced) do
|
145
|
+
pool.init_connection(connection, options)
|
146
|
+
connection
|
147
|
+
end
|
152
148
|
end
|
153
149
|
|
154
150
|
def send_requests(*requests, options)
|
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: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2-next
|