async-http 0.52.5 → 0.53.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/async/http/body/hijack.rb +5 -0
- data/lib/async/http/body/pipe.rb +15 -7
- data/lib/async/http/body/stream.rb +1 -1
- data/lib/async/http/client.rb +2 -2
- data/lib/async/http/protocol/http1/connection.rb +0 -5
- data/lib/async/http/protocol/http1/server.rb +1 -1
- data/lib/async/http/protocol/http2/output.rb +1 -1
- data/lib/async/http/proxy.rb +24 -8
- data/lib/async/http/version.rb +1 -1
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bc8de85da015e7e82aa4c9d5b74a8beb8eb7ad9703cb5e12ce26562afbf6536
|
4
|
+
data.tar.gz: 1aed8b966a3c63de7b6b5504a99eb89599dcb54fd0f8879c7712425cb83eff96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b13c0d84ff2d98a361c08c9e0a853a0cc09d06e394375d9b4abb768328e308c0c1e02d8e964fa05e8d1169c6f0c844ad0f527ea298ba84acc16082d4eff2670
|
7
|
+
data.tar.gz: 24b43624c98754808ced1e5721442a2f9e98b7edcae8a7fb0fd258ca83b962dbd4f368ae8c5addbee130e95bf76f14ac8cac6d16a52048bf47f5f87c6696cea6
|
data/lib/async/http/body/pipe.rb
CHANGED
@@ -20,6 +20,9 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
+
require 'async/io/socket'
|
24
|
+
require 'async/io/stream'
|
25
|
+
|
23
26
|
require_relative 'writable'
|
24
27
|
|
25
28
|
module Async
|
@@ -39,8 +42,8 @@ module Async
|
|
39
42
|
@reader = nil
|
40
43
|
@writer = nil
|
41
44
|
|
42
|
-
task.async(&self.method(:reader))
|
43
|
-
task.async(&self.method(:writer))
|
45
|
+
task.async(transient: true, &self.method(:reader))
|
46
|
+
task.async(transient: true, &self.method(:writer))
|
44
47
|
end
|
45
48
|
|
46
49
|
def to_io
|
@@ -69,10 +72,9 @@ module Async
|
|
69
72
|
|
70
73
|
@head.close_write
|
71
74
|
ensure
|
72
|
-
@reader = nil
|
73
75
|
@input.close($!)
|
74
76
|
|
75
|
-
|
77
|
+
close_head if @writer&.finished?
|
76
78
|
end
|
77
79
|
|
78
80
|
# Read from the head of the pipe and write to the @output stream.
|
@@ -86,11 +88,17 @@ module Async
|
|
86
88
|
@output.write(chunk)
|
87
89
|
end
|
88
90
|
ensure
|
89
|
-
@writer = nil
|
90
|
-
|
91
91
|
@output.close($!)
|
92
92
|
|
93
|
-
|
93
|
+
close_head if @reader&.finished?
|
94
|
+
end
|
95
|
+
|
96
|
+
def close_head
|
97
|
+
@head.close
|
98
|
+
|
99
|
+
# Both tasks are done, don't keep references:
|
100
|
+
@reader = nil
|
101
|
+
@writer = nil
|
94
102
|
end
|
95
103
|
end
|
96
104
|
end
|
data/lib/async/http/client.rb
CHANGED
@@ -25,7 +25,7 @@ require 'async/io/stream'
|
|
25
25
|
|
26
26
|
require 'async/pool/controller'
|
27
27
|
|
28
|
-
require 'protocol/http/body/
|
28
|
+
require 'protocol/http/body/completable'
|
29
29
|
require 'protocol/http/methods'
|
30
30
|
|
31
31
|
require_relative 'protocol'
|
@@ -143,7 +143,7 @@ module Async
|
|
143
143
|
response = request.call(connection)
|
144
144
|
|
145
145
|
# The connection won't be released until the body is completely read/released.
|
146
|
-
::Protocol::HTTP::Body::
|
146
|
+
::Protocol::HTTP::Body::Completable.wrap(response) do
|
147
147
|
@pool.release(connection)
|
148
148
|
end
|
149
149
|
|
data/lib/async/http/proxy.rb
CHANGED
@@ -30,6 +30,15 @@ module Async
|
|
30
30
|
# Wraps a client, address and headers required to initiate a connectio to a remote host using the CONNECT verb.
|
31
31
|
# Behaves like a TCP endpoint for the purposes of connecting to a remote host.
|
32
32
|
class Proxy
|
33
|
+
class ConnectFailure < StandardError
|
34
|
+
def initialize(response)
|
35
|
+
super "Failed to connect: #{response.status}"
|
36
|
+
@response = response
|
37
|
+
end
|
38
|
+
|
39
|
+
attr :response
|
40
|
+
end
|
41
|
+
|
33
42
|
module Client
|
34
43
|
def proxy(endpoint, headers = nil)
|
35
44
|
Proxy.new(self, endpoint.authority(false), headers)
|
@@ -92,14 +101,21 @@ module Async
|
|
92
101
|
|
93
102
|
response = @client.connect(@address.to_s, @headers, input)
|
94
103
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
104
|
+
if response.success?
|
105
|
+
pipe = Body::Pipe.new(response.body, input)
|
106
|
+
|
107
|
+
return pipe.to_io unless block_given?
|
108
|
+
|
109
|
+
begin
|
110
|
+
yield pipe.to_io
|
111
|
+
ensure
|
112
|
+
pipe.close
|
113
|
+
end
|
114
|
+
else
|
115
|
+
# This ensures we don't leave a response dangling:
|
116
|
+
response.close
|
117
|
+
|
118
|
+
raise ConnectFailure, response
|
103
119
|
end
|
104
120
|
end
|
105
121
|
|
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.
|
4
|
+
version: 0.53.0
|
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-
|
11
|
+
date: 2020-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.21.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.21.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: protocol-http1
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,6 +164,20 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: '3.6'
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: localhost
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - ">="
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '0'
|
174
|
+
type: :development
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
167
181
|
description:
|
168
182
|
email:
|
169
183
|
executables: []
|
@@ -229,7 +243,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
229
243
|
- !ruby/object:Gem::Version
|
230
244
|
version: '0'
|
231
245
|
requirements: []
|
232
|
-
rubygems_version: 3.
|
246
|
+
rubygems_version: 3.1.2
|
233
247
|
signing_key:
|
234
248
|
specification_version: 4
|
235
249
|
summary: A HTTP client and server library.
|