async-http 0.50.4 → 0.50.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/async-http.gemspec +1 -1
- data/bake/async/http.rb +0 -1
- data/examples/compare/Gemfile +9 -0
- data/examples/compare/benchmark.rb +78 -0
- data/examples/fetch/Gemfile.lock +52 -32
- data/lib/async/http/protocol/http1/request.rb +4 -0
- data/lib/async/http/protocol/http1/response.rb +4 -0
- data/lib/async/http/protocol/http2/connection.rb +4 -0
- data/lib/async/http/protocol/http2/request.rb +10 -0
- data/lib/async/http/protocol/http2/response.rb +10 -4
- data/lib/async/http/protocol/http2/stream.rb +4 -1
- data/lib/async/http/protocol/request.rb +5 -3
- data/lib/async/http/protocol/response.rb +5 -3
- data/lib/async/http/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: fe10cc184257f0419dda2ec007872f881b6e9755b3bc9c16ffc98e530bf303a6
|
4
|
+
data.tar.gz: 680a47bf8bfe1bfbdc394834bbaf9dc441f394c19aebedc50c68aa86517f6bc7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d3855acb1b0dbcb71b4ffb1fef53197657706cd9bc83a7cb30d347181976c2ff7b6b70b97b58a0ee505a69c16944766c2dc2c4596525c1b53de1bf01281dabe
|
7
|
+
data.tar.gz: 62b71cb26b87fa38958ef7e1e524ad5ea9bf385bee4f4698b9b97f09d64b80a4f5787a9a9f03f4ce56179e74b75b548ee51154c8c93856a7ee2ab3990a88896b
|
data/async-http.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
|
24
24
|
spec.add_dependency("protocol-http", "~> 0.14.1")
|
25
25
|
spec.add_dependency("protocol-http1", "~> 0.10.0")
|
26
|
-
spec.add_dependency("protocol-http2", "~> 0.
|
26
|
+
spec.add_dependency("protocol-http2", "~> 0.11.0")
|
27
27
|
|
28
28
|
# spec.add_dependency("openssl")
|
29
29
|
|
data/bake/async/http.rb
CHANGED
@@ -0,0 +1,78 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'benchmark'
|
4
|
+
|
5
|
+
require 'httpx'
|
6
|
+
|
7
|
+
require 'async'
|
8
|
+
require 'async/barrier'
|
9
|
+
require 'async/semaphore'
|
10
|
+
require 'async/http/internet'
|
11
|
+
|
12
|
+
URL = "https://www.codeotaku.com/index"
|
13
|
+
REPEATS = 10
|
14
|
+
|
15
|
+
Benchmark.bmbm do |x|
|
16
|
+
x.report("async-http") do
|
17
|
+
Async do
|
18
|
+
internet = Async::HTTP::Internet.new
|
19
|
+
|
20
|
+
i = 0
|
21
|
+
while i < REPEATS
|
22
|
+
response = internet.get(URL)
|
23
|
+
response.read
|
24
|
+
|
25
|
+
i += 1
|
26
|
+
end
|
27
|
+
ensure
|
28
|
+
internet&.close
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
x.report("async-http (pipelined)") do
|
33
|
+
Async do |task|
|
34
|
+
internet = Async::HTTP::Internet.new
|
35
|
+
semaphore = Async::Semaphore.new(100, parent: task)
|
36
|
+
barrier = Async::Barrier.new(parent: semaphore)
|
37
|
+
|
38
|
+
# Warm up the connection pool...
|
39
|
+
response = internet.get(URL)
|
40
|
+
response.read
|
41
|
+
|
42
|
+
i = 0
|
43
|
+
while i < REPEATS
|
44
|
+
barrier.async do
|
45
|
+
response = internet.get(URL)
|
46
|
+
|
47
|
+
response.read
|
48
|
+
end
|
49
|
+
|
50
|
+
i += 1
|
51
|
+
end
|
52
|
+
|
53
|
+
barrier.wait
|
54
|
+
ensure
|
55
|
+
internet&.close
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
x.report("httpx") do
|
60
|
+
i = 0
|
61
|
+
while i < REPEATS
|
62
|
+
response = HTTPX.get(URL)
|
63
|
+
|
64
|
+
response.read
|
65
|
+
|
66
|
+
i += 1
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
x.report("httpx (pipelined)") do
|
71
|
+
urls = [URL] * REPEATS
|
72
|
+
responses = HTTPX.get(*urls)
|
73
|
+
|
74
|
+
responses.each do |response|
|
75
|
+
response.read
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/examples/fetch/Gemfile.lock
CHANGED
@@ -1,46 +1,66 @@
|
|
1
1
|
GEM
|
2
2
|
specs:
|
3
|
-
async (1.
|
3
|
+
async (1.24.2)
|
4
|
+
console (~> 1.0)
|
4
5
|
nio4r (~> 2.3)
|
5
6
|
timers (~> 4.1)
|
6
|
-
async-container (0.
|
7
|
+
async-container (0.16.2)
|
7
8
|
async (~> 1.0)
|
8
|
-
async-io (~> 1.
|
9
|
-
|
10
|
-
|
11
|
-
async
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
async-io (~> 1.26)
|
10
|
+
process-group
|
11
|
+
async-http (0.50.5)
|
12
|
+
async (~> 1.23)
|
13
|
+
async-io (~> 1.27.0)
|
14
|
+
async-pool (~> 0.2)
|
15
|
+
protocol-http (~> 0.14.1)
|
16
|
+
protocol-http1 (~> 0.10.0)
|
17
|
+
protocol-http2 (~> 0.11.0)
|
18
|
+
async-http-cache (0.1.2)
|
19
|
+
async-http
|
20
|
+
protocol-http (~> 0.14.4)
|
21
|
+
async-io (1.27.4)
|
22
|
+
async (~> 1.14)
|
23
|
+
async-pool (0.2.0)
|
24
|
+
async (~> 1.8)
|
25
|
+
build-environment (1.13.0)
|
15
26
|
coderay (1.1.2)
|
16
|
-
|
17
|
-
|
18
|
-
async
|
19
|
-
async-
|
20
|
-
http
|
27
|
+
console (1.8.2)
|
28
|
+
falcon (0.35.6)
|
29
|
+
async (~> 1.13)
|
30
|
+
async-container (~> 0.16.0)
|
31
|
+
async-http (~> 0.50.4)
|
32
|
+
async-http-cache (~> 0.1.0)
|
33
|
+
async-io (~> 1.22)
|
34
|
+
build-environment (~> 1.13)
|
21
35
|
localhost (~> 1.1)
|
36
|
+
process-metrics (~> 0.1.0)
|
22
37
|
rack (>= 1.0)
|
23
|
-
samovar (~> 1
|
24
|
-
|
25
|
-
|
26
|
-
http-protocol (0.6.0)
|
27
|
-
http-hpack (~> 0.1.0)
|
28
|
-
localhost (1.1.4)
|
38
|
+
samovar (~> 2.1)
|
39
|
+
ffi (1.12.2)
|
40
|
+
localhost (1.1.6)
|
29
41
|
mapping (1.1.1)
|
30
|
-
method_source (0.9.
|
31
|
-
nio4r (2.
|
32
|
-
|
42
|
+
method_source (0.9.2)
|
43
|
+
nio4r (2.5.2)
|
44
|
+
process-group (1.2.1)
|
45
|
+
process-terminal (~> 0.2.0)
|
46
|
+
process-metrics (0.1.1)
|
47
|
+
process-terminal (0.2.0)
|
48
|
+
ffi
|
49
|
+
protocol-hpack (1.4.2)
|
50
|
+
protocol-http (0.14.4)
|
51
|
+
protocol-http1 (0.10.2)
|
52
|
+
protocol-http (~> 0.13)
|
53
|
+
protocol-http2 (0.11.1)
|
54
|
+
protocol-hpack (~> 1.4)
|
55
|
+
protocol-http (~> 0.2)
|
56
|
+
pry (0.12.2)
|
33
57
|
coderay (~> 1.1.0)
|
34
58
|
method_source (~> 0.9.0)
|
35
|
-
rack (2.
|
36
|
-
|
37
|
-
|
38
|
-
rake (12.3.1)
|
39
|
-
samovar (1.9.0)
|
59
|
+
rack (2.2.2)
|
60
|
+
samovar (2.1.4)
|
61
|
+
console (~> 1.0)
|
40
62
|
mapping (~> 1.0)
|
41
|
-
|
42
|
-
timers (4.1.2)
|
43
|
-
hitimes
|
63
|
+
timers (4.3.0)
|
44
64
|
|
45
65
|
PLATFORMS
|
46
66
|
ruby
|
@@ -51,4 +71,4 @@ DEPENDENCIES
|
|
51
71
|
rack
|
52
72
|
|
53
73
|
BUNDLED WITH
|
54
|
-
1.
|
74
|
+
1.17.3
|
@@ -105,6 +105,12 @@ module Async
|
|
105
105
|
|
106
106
|
return headers
|
107
107
|
end
|
108
|
+
|
109
|
+
def close(error)
|
110
|
+
@request = nil
|
111
|
+
|
112
|
+
super
|
113
|
+
end
|
108
114
|
end
|
109
115
|
|
110
116
|
def initialize(stream)
|
@@ -115,6 +121,10 @@ module Async
|
|
115
121
|
|
116
122
|
attr :stream
|
117
123
|
|
124
|
+
def connection
|
125
|
+
@stream.connection
|
126
|
+
end
|
127
|
+
|
118
128
|
def valid?
|
119
129
|
@scheme and @method and @path
|
120
130
|
end
|
@@ -27,7 +27,7 @@ module Async
|
|
27
27
|
module HTTP
|
28
28
|
module Protocol
|
29
29
|
module HTTP2
|
30
|
-
# Typically used on the client side
|
30
|
+
# Typically used on the client side for writing a request and reading the incoming response.
|
31
31
|
class Response < Protocol::Response
|
32
32
|
class Stream < HTTP2::Stream
|
33
33
|
def initialize(*)
|
@@ -50,7 +50,7 @@ module Async
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def accept_push_promise_stream(promised_stream_id, headers)
|
53
|
-
stream = @connection.accept_push_promise_stream(promised_stream_id, &Stream.method(:
|
53
|
+
stream = @connection.accept_push_promise_stream(promised_stream_id, &Stream.method(:create))
|
54
54
|
|
55
55
|
stream.response.build_request(headers)
|
56
56
|
|
@@ -110,7 +110,10 @@ module Async
|
|
110
110
|
def close(error)
|
111
111
|
super
|
112
112
|
|
113
|
-
@response
|
113
|
+
if @response
|
114
|
+
@response.promises.enqueue nil
|
115
|
+
@response = nil
|
116
|
+
end
|
114
117
|
|
115
118
|
@exception = error
|
116
119
|
|
@@ -127,9 +130,12 @@ module Async
|
|
127
130
|
end
|
128
131
|
|
129
132
|
attr :stream
|
130
|
-
|
131
133
|
attr :request
|
132
134
|
|
135
|
+
def connection
|
136
|
+
@stream.connection
|
137
|
+
end
|
138
|
+
|
133
139
|
def wait
|
134
140
|
@stream.wait
|
135
141
|
end
|
@@ -129,6 +129,9 @@ module Async
|
|
129
129
|
|
130
130
|
while chunk = @body&.read
|
131
131
|
self.write(chunk)
|
132
|
+
# TODO this reduces memory usage?
|
133
|
+
# chunk.clear unless chunk.frozen?
|
134
|
+
# GC.start
|
132
135
|
end
|
133
136
|
|
134
137
|
self.close_write
|
@@ -201,7 +204,7 @@ module Async
|
|
201
204
|
end
|
202
205
|
end
|
203
206
|
|
204
|
-
def
|
207
|
+
def process_headers(frame)
|
205
208
|
if @headers.nil?
|
206
209
|
@headers = ::Protocol::HTTP::Headers.new
|
207
210
|
self.receive_initial_headers(super, frame.end_stream?)
|
@@ -34,7 +34,9 @@ module Async
|
|
34
34
|
|
35
35
|
# This is generated by server protocols.
|
36
36
|
class Request < ::Protocol::HTTP::Request
|
37
|
-
|
37
|
+
def connection
|
38
|
+
nil
|
39
|
+
end
|
38
40
|
|
39
41
|
def hijack?
|
40
42
|
false
|
@@ -45,8 +47,8 @@ module Async
|
|
45
47
|
end
|
46
48
|
|
47
49
|
def peer
|
48
|
-
if
|
49
|
-
|
50
|
+
if connection = self.connection
|
51
|
+
connection.peer
|
50
52
|
end
|
51
53
|
end
|
52
54
|
|
@@ -29,15 +29,17 @@ module Async
|
|
29
29
|
module Protocol
|
30
30
|
# This is generated by client protocols.
|
31
31
|
class Response < ::Protocol::HTTP::Response
|
32
|
-
|
32
|
+
def connection
|
33
|
+
nil
|
34
|
+
end
|
33
35
|
|
34
36
|
def hijack?
|
35
37
|
false
|
36
38
|
end
|
37
39
|
|
38
40
|
def peer
|
39
|
-
if
|
40
|
-
|
41
|
+
if connection = self.connection
|
42
|
+
connection.peer
|
41
43
|
end
|
42
44
|
end
|
43
45
|
|
data/lib/async/http/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: async-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.50.
|
4
|
+
version: 0.50.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.
|
89
|
+
version: 0.11.0
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.
|
96
|
+
version: 0.11.0
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: async-rspec
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -222,6 +222,8 @@ files:
|
|
222
222
|
- Rakefile
|
223
223
|
- async-http.gemspec
|
224
224
|
- bake/async/http.rb
|
225
|
+
- examples/compare/Gemfile
|
226
|
+
- examples/compare/benchmark.rb
|
225
227
|
- examples/fetch/Gemfile
|
226
228
|
- examples/fetch/Gemfile.lock
|
227
229
|
- examples/fetch/README.md
|