httpx 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/httpx/channel.rb +13 -2
- data/lib/httpx/channel/http1.rb +7 -2
- data/lib/httpx/channel/http2.rb +12 -3
- data/lib/httpx/client.rb +1 -5
- data/lib/httpx/connection.rb +6 -5
- data/lib/httpx/io.rb +5 -1
- data/lib/httpx/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3fd5760406dc7a2cb5abb040160144fb8a788a19
|
4
|
+
data.tar.gz: 2fcf4228f1ff06b7621b7e688e9fe2a173e39096
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: adc85e755255e5e460bce9a84c5e5c3c03a8271702eed4373aded5002d71b28d99787bc4f4837d3bee4634f58fbe5541cf6f3a0282c54e4b3c5d86233f7b581c
|
7
|
+
data.tar.gz: 58f6d7c64c527bb654a8ab7107eff77315ad4c3d6f17da06b081be0d25345169736b78082b9e4335373dde707e071823d2bafa74102336535f9af07234bbd3d6
|
data/lib/httpx/channel.rb
CHANGED
@@ -66,6 +66,7 @@ module HTTPX
|
|
66
66
|
@write_buffer = Buffer.new(BUFFER_SIZE)
|
67
67
|
@pending = []
|
68
68
|
@state = :idle
|
69
|
+
on(:error) { |ex| on_error(ex) }
|
69
70
|
end
|
70
71
|
|
71
72
|
def match?(uri)
|
@@ -204,6 +205,10 @@ module HTTPX
|
|
204
205
|
transition(:open)
|
205
206
|
end
|
206
207
|
end
|
208
|
+
parser.on(:error) do |request, ex|
|
209
|
+
response = ErrorResponse.new(ex, 0, @options)
|
210
|
+
emit(:response, request, response)
|
211
|
+
end
|
207
212
|
parser
|
208
213
|
end
|
209
214
|
|
@@ -230,12 +235,18 @@ module HTTPX
|
|
230
235
|
Errno::EADDRNOTAVAIL,
|
231
236
|
OpenSSL::SSL::SSLError => e
|
232
237
|
# connect errors, exit gracefully
|
233
|
-
|
238
|
+
handle_error(e)
|
234
239
|
@state = :closed
|
235
240
|
emit(:close)
|
236
241
|
end
|
237
242
|
|
238
|
-
def
|
243
|
+
def on_error(ex)
|
244
|
+
handle_error(ex)
|
245
|
+
reset
|
246
|
+
end
|
247
|
+
|
248
|
+
def handle_error(e)
|
249
|
+
parser.handle_error(e)
|
239
250
|
response = ErrorResponse.new(e, 0, @options)
|
240
251
|
@pending.each do |request, _|
|
241
252
|
emit(:response, request, response)
|
data/lib/httpx/channel/http1.rb
CHANGED
@@ -12,7 +12,6 @@ module HTTPX
|
|
12
12
|
def initialize(buffer, options)
|
13
13
|
@options = Options.new(options)
|
14
14
|
@max_concurrent_requests = @options.max_concurrent_requests
|
15
|
-
@retries = options.max_retries
|
16
15
|
@parser = HTTP::Parser.new(self)
|
17
16
|
@parser.header_value_type = :arrays
|
18
17
|
@buffer = buffer
|
@@ -141,13 +140,19 @@ module HTTPX
|
|
141
140
|
response << @parser.upgrade_data
|
142
141
|
throw(:called)
|
143
142
|
end
|
144
|
-
|
143
|
+
reset
|
145
144
|
send(@pending.shift) unless @pending.empty?
|
146
145
|
return unless response.headers["connection"] == "close"
|
147
146
|
disable_concurrency
|
148
147
|
emit(:reset)
|
149
148
|
end
|
150
149
|
|
150
|
+
def handle_error(ex)
|
151
|
+
@requests.each do |request|
|
152
|
+
emit(:error, request, ex)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
151
156
|
private
|
152
157
|
|
153
158
|
def disable_concurrency
|
data/lib/httpx/channel/http2.rb
CHANGED
@@ -13,7 +13,6 @@ module HTTPX
|
|
13
13
|
@options = Options.new(options)
|
14
14
|
@max_concurrent_requests = @options.max_concurrent_requests
|
15
15
|
init_connection
|
16
|
-
@retries = options.max_retries
|
17
16
|
@pending = []
|
18
17
|
@streams = {}
|
19
18
|
@drains = {}
|
@@ -60,6 +59,12 @@ module HTTPX
|
|
60
59
|
end
|
61
60
|
end
|
62
61
|
|
62
|
+
def handle_error(ex)
|
63
|
+
@streams.each_key do |request|
|
64
|
+
emit(:error, request, ex)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
63
68
|
private
|
64
69
|
|
65
70
|
def headline_uri(request)
|
@@ -151,8 +156,12 @@ module HTTPX
|
|
151
156
|
|
152
157
|
def on_stream_close(stream, request, error)
|
153
158
|
return handle(request, stream) if request.expects?
|
154
|
-
|
155
|
-
|
159
|
+
if error
|
160
|
+
emit(:error, request, error)
|
161
|
+
else
|
162
|
+
response = request.response
|
163
|
+
emit(:response, request, response)
|
164
|
+
end
|
156
165
|
log(level: 2, label: "#{stream.id}: ") { "closing stream" }
|
157
166
|
|
158
167
|
@streams.delete(request)
|
data/lib/httpx/client.rb
CHANGED
@@ -111,11 +111,7 @@ module HTTPX
|
|
111
111
|
responses << response
|
112
112
|
requests.shift
|
113
113
|
|
114
|
-
break if requests.empty?
|
115
|
-
rescue TimeoutError => e
|
116
|
-
responses << ErrorResponse.new(e, 0, @options) while requests.shift
|
117
|
-
@connection.reset
|
118
|
-
break
|
114
|
+
break if requests.empty? || !@connection.running?
|
119
115
|
end
|
120
116
|
end
|
121
117
|
responses
|
data/lib/httpx/connection.rb
CHANGED
@@ -16,13 +16,18 @@ module HTTPX
|
|
16
16
|
!@channels.empty?
|
17
17
|
end
|
18
18
|
|
19
|
-
def next_tick
|
19
|
+
def next_tick
|
20
|
+
timeout = @timeout.timeout
|
20
21
|
@selector.select(timeout) do |monitor|
|
21
22
|
if (channel = monitor.value)
|
22
23
|
channel.call
|
23
24
|
end
|
24
25
|
monitor.interests = channel.interests
|
25
26
|
end
|
27
|
+
rescue TimeoutError => ex
|
28
|
+
@channels.each do |ch|
|
29
|
+
ch.emit(:error, ex)
|
30
|
+
end
|
26
31
|
end
|
27
32
|
|
28
33
|
def close
|
@@ -30,10 +35,6 @@ module HTTPX
|
|
30
35
|
next_tick until @channels.empty?
|
31
36
|
end
|
32
37
|
|
33
|
-
def reset
|
34
|
-
@channels.each(&:reset)
|
35
|
-
end
|
36
|
-
|
37
38
|
def build_channel(uri, **options)
|
38
39
|
channel = Channel.by(uri, @options.merge(options))
|
39
40
|
register_channel(channel)
|
data/lib/httpx/io.rb
CHANGED
@@ -137,6 +137,10 @@ module HTTPX
|
|
137
137
|
when :closed
|
138
138
|
return unless @state == :connected
|
139
139
|
end
|
140
|
+
do_transition(nextstate)
|
141
|
+
end
|
142
|
+
|
143
|
+
def do_transition(nextstate)
|
140
144
|
log(level: 1, label: "#{inspect}: ") { nextstate.to_s }
|
141
145
|
@state = nextstate
|
142
146
|
end
|
@@ -240,7 +244,7 @@ module HTTPX
|
|
240
244
|
return unless @state == :negotiated ||
|
241
245
|
@state == :connected
|
242
246
|
end
|
243
|
-
|
247
|
+
do_transition(nextstate)
|
244
248
|
end
|
245
249
|
end
|
246
250
|
module IO
|
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.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-03
|
11
|
+
date: 2018-04-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-2
|
@@ -145,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
147
|
rubyforge_project:
|
148
|
-
rubygems_version: 2.6.14
|
148
|
+
rubygems_version: 2.6.14.1
|
149
149
|
signing_key:
|
150
150
|
specification_version: 4
|
151
151
|
summary: HTTPX, to the future, and beyond
|