async-http 0.50.12 → 0.50.13
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 +2 -2
- data/bake/async/http.rb +9 -0
- data/lib/async/http/protocol/http1.rb +4 -0
- data/lib/async/http/protocol/http1/client.rb +3 -1
- data/lib/async/http/protocol/http1/server.rb +3 -1
- data/lib/async/http/protocol/http10.rb +4 -0
- data/lib/async/http/protocol/http11.rb +4 -0
- data/lib/async/http/protocol/http2.rb +4 -0
- data/lib/async/http/protocol/http2/output.rb +5 -9
- data/lib/async/http/protocol/http2/request.rb +1 -1
- data/lib/async/http/protocol/http2/response.rb +1 -1
- data/lib/async/http/protocol/http2/stream.rb +28 -12
- data/lib/async/http/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cecbbc1a65dc4e0697fab222184c9a310bdaccfb5673f2200c3686f77ab7b9e
|
4
|
+
data.tar.gz: 88a4d5a5b7c10f48033f78ac838c0b75d969f85a33e9ccca07bd0f587865d8ab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f1bb76e135ec8d00508c5c1625d017e79ba87a19552ea4968b3a206f65fb3702623b2f1d96f80a88948ccbf959e3aac8a959dcc5c86a3cd65cd9159a9b6ac15
|
7
|
+
data.tar.gz: b8ea5b50c9a4b76ddf9cd21484eba947674c590410e7335b10c24823997fa9d9c7235e160ee9d804905083e31ee51dca83faea02265421734da35227a9bf7bb0
|
data/async-http.gemspec
CHANGED
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_dependency("async-io", "~> 1.28")
|
22
22
|
spec.add_dependency("async-pool", "~> 0.2")
|
23
23
|
|
24
|
-
spec.add_dependency("protocol-http", "~> 0.
|
25
|
-
spec.add_dependency("protocol-http1", "~> 0.
|
24
|
+
spec.add_dependency("protocol-http", "~> 0.17.0")
|
25
|
+
spec.add_dependency("protocol-http1", "~> 0.11.0")
|
26
26
|
spec.add_dependency("protocol-http2", "~> 0.13.0")
|
27
27
|
|
28
28
|
# spec.add_dependency("openssl")
|
data/bake/async/http.rb
CHANGED
@@ -67,6 +67,15 @@ def fetch(url, method:)
|
|
67
67
|
end
|
68
68
|
|
69
69
|
response.finish
|
70
|
+
|
71
|
+
if trailers = response.headers.trailers
|
72
|
+
trailers.each do |key, value|
|
73
|
+
terminal.print_line(
|
74
|
+
:key, key.rjust(align), :reset, ": ", :value, value.inspect
|
75
|
+
)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
70
79
|
internet.close
|
71
80
|
end
|
72
81
|
end
|
@@ -39,6 +39,8 @@ module Async
|
|
39
39
|
raise RequestFailed
|
40
40
|
end
|
41
41
|
|
42
|
+
request.headers.trailers!
|
43
|
+
|
42
44
|
if request.body?
|
43
45
|
body = request.body
|
44
46
|
|
@@ -61,7 +63,7 @@ module Async
|
|
61
63
|
subtask.annotate("Streaming body.")
|
62
64
|
|
63
65
|
# Once we start writing the body, we can't recover if the request fails. That's because the body might be generated dynamically, streaming, etc.
|
64
|
-
write_body(@version, body)
|
66
|
+
write_body(@version, body, false, request.trailers)
|
65
67
|
end
|
66
68
|
end
|
67
69
|
elsif protocol = request.protocol
|
@@ -61,6 +61,7 @@ module Async
|
|
61
61
|
|
62
62
|
if response
|
63
63
|
write_response(@version, response.status, response.headers)
|
64
|
+
response.headers.trailers!
|
64
65
|
|
65
66
|
body = response.body
|
66
67
|
|
@@ -84,11 +85,12 @@ module Async
|
|
84
85
|
body.call(stream)
|
85
86
|
else
|
86
87
|
head = request.head?
|
88
|
+
trailers = response.trailers
|
87
89
|
|
88
90
|
request = nil unless body
|
89
91
|
response = nil
|
90
92
|
|
91
|
-
write_body(@version, body, head)
|
93
|
+
write_body(@version, body, head, trailers)
|
92
94
|
end
|
93
95
|
else
|
94
96
|
# If the request failed to generate a response, it was an internal server error:
|
@@ -27,22 +27,18 @@ module Async
|
|
27
27
|
module Protocol
|
28
28
|
module HTTP2
|
29
29
|
class Output
|
30
|
-
def
|
31
|
-
output = self.new(stream, body)
|
32
|
-
|
33
|
-
output.start
|
34
|
-
|
35
|
-
return output
|
36
|
-
end
|
37
|
-
|
38
|
-
def initialize(stream, body)
|
30
|
+
def initialize(stream, body, trailers = nil)
|
39
31
|
@stream = stream
|
40
32
|
@body = body
|
33
|
+
@trailers = trailers
|
34
|
+
|
41
35
|
@task = nil
|
42
36
|
|
43
37
|
@window_updated = Async::Condition.new
|
44
38
|
end
|
45
39
|
|
40
|
+
attr :trailers
|
41
|
+
|
46
42
|
def start(parent: Task.current)
|
47
43
|
raise "Task already started!" if @task
|
48
44
|
|
@@ -184,7 +184,7 @@ module Async
|
|
184
184
|
|
185
185
|
if body = response.body and !self.head?
|
186
186
|
@stream.send_headers(nil, headers)
|
187
|
-
@stream.send_body(body)
|
187
|
+
@stream.send_body(body, response.trailers)
|
188
188
|
else
|
189
189
|
# Ensure the response body is closed if we are ending the stream:
|
190
190
|
response.close
|
@@ -60,17 +60,15 @@ module Async
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
def add_trailer(key, value)
|
64
|
-
if @trailers.include(key)
|
65
|
-
add_header(key, value)
|
66
|
-
else
|
67
|
-
raise ::Protocol::HTTP2::HeaderError, "Cannot add trailer #{key} as it was not specified in trailers!"
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
63
|
def receive_trailing_headers(headers, end_stream)
|
64
|
+
@headers.trailers!
|
65
|
+
|
72
66
|
headers.each do |key, value|
|
73
|
-
|
67
|
+
if @trailers.include?(key)
|
68
|
+
add_header(key, value)
|
69
|
+
else
|
70
|
+
raise ::Protocol::HTTP2::HeaderError, "Cannot add trailer #{key} as it was not specified as a trailer!"
|
71
|
+
end
|
74
72
|
end
|
75
73
|
end
|
76
74
|
|
@@ -84,6 +82,12 @@ module Async
|
|
84
82
|
else
|
85
83
|
raise ::Protocol::HTTP2::HeaderError, "Unable to process headers!"
|
86
84
|
end
|
85
|
+
|
86
|
+
# TODO this might need to be in an ensure block:
|
87
|
+
if @input and frame.end_stream?
|
88
|
+
@input.close($!)
|
89
|
+
@input = nil
|
90
|
+
end
|
87
91
|
rescue ::Protocol::HTTP2::HeaderError => error
|
88
92
|
Async.logger.error(self, error)
|
89
93
|
|
@@ -133,18 +137,27 @@ module Async
|
|
133
137
|
end
|
134
138
|
|
135
139
|
# Set the body and begin sending it.
|
136
|
-
def send_body(body)
|
137
|
-
@output = Output.
|
140
|
+
def send_body(body, trailers = nil)
|
141
|
+
@output = Output.new(self, body, trailers)
|
142
|
+
|
143
|
+
@output.start
|
138
144
|
end
|
139
145
|
|
140
146
|
# Called when the output terminates normally.
|
141
147
|
def finish_output(error = nil)
|
148
|
+
trailers = @output&.trailers
|
149
|
+
|
142
150
|
@output = nil
|
143
151
|
|
144
152
|
if error
|
145
153
|
send_reset_stream(::Protocol::HTTP2::Error::INTERNAL_ERROR)
|
146
154
|
else
|
147
|
-
|
155
|
+
# Write trailers?
|
156
|
+
if trailers
|
157
|
+
send_headers(nil, trailers, ::Protocol::HTTP2::END_STREAM)
|
158
|
+
else
|
159
|
+
send_data(nil, ::Protocol::HTTP2::END_STREAM)
|
160
|
+
end
|
148
161
|
end
|
149
162
|
end
|
150
163
|
|
@@ -168,6 +181,9 @@ module Async
|
|
168
181
|
|
169
182
|
if @output
|
170
183
|
@output.stop(error)
|
184
|
+
|
185
|
+
Async.logger.warn(self) {"Closed output: #{@output}"}
|
186
|
+
|
171
187
|
@output = nil
|
172
188
|
end
|
173
189
|
|
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.13
|
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-04-
|
11
|
+
date: 2020-04-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: async
|
@@ -58,28 +58,28 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.17.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.17.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: protocol-http1
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
75
|
+
version: 0.11.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
82
|
+
version: 0.11.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: protocol-http2
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|