async-http 0.46.5 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b9fb9d8fd91de95c63e2a7fc133902457a812394c80bb37773ddd04a74592cda
4
- data.tar.gz: 460f4a0505a7fe53ee91246728ed601464f86c85eb01db3bc1f3c1ee322b7834
3
+ metadata.gz: 27b6378ebb80f14051f9869d2409de28292dac437c14d7b4188edcd45c7d9971
4
+ data.tar.gz: a52c8f9553effe5e0e1bdf0e90a9eaa529e3f4cc1e1c53d06e7606fe16966e16
5
5
  SHA512:
6
- metadata.gz: f356561f16a0829428ca4733cb9af6cde0f871ce2df662871e0c78b299d16d4a25be5f562719e752037f64dbaba3ab2328a1deb7579e66c06c4452a9269462aa
7
- data.tar.gz: 914b845234e8c98eac84ee45dbc9f5e745bc07e61f23bbaf6017cab898b8455e70b978e31735a5b898cb22b7e4918fb3705d51e258ac5632c7a4f2f5e1cb8cc3
6
+ metadata.gz: 4ed7257439e6e3829c88cedefc78df137551b9c0183abaa76e59a7d39d0ae399af9a5fec7b66ece4a22648099ef6e29abe9d1c2f93ba83d80622c17edf0f604d
7
+ data.tar.gz: 35906d4412cf80f45a3ef074b0f29ec9076f40f73b74c542353d60a2dfb1509aba95c27e5b8fe340d49c0e6a873998adbc49920622f28439b9a4f360f0f4350c
data/async-http.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.add_dependency("async", "~> 1.19")
20
20
  spec.add_dependency("async-io", "~> 1.24")
21
21
 
22
- spec.add_dependency("protocol-http", "~> 0.11.0")
22
+ spec.add_dependency("protocol-http", "~> 0.12.0")
23
23
  spec.add_dependency("protocol-http1", "~> 0.8.0")
24
24
  spec.add_dependency("protocol-http2", "~> 0.9.0")
25
25
 
@@ -68,12 +68,17 @@ module Async
68
68
 
69
69
  write_response(@version, response.status, response.headers)
70
70
 
71
- if body = response.body and protocol = response.protocol
71
+ body = response.body
72
+
73
+ if body and protocol = response.protocol
72
74
  stream = write_upgrade_body(protocol)
73
75
 
74
76
  # At this point, the request body is hijacked, so we don't want to call #finish below.
75
77
  request = nil
76
78
 
79
+ # We also don't want to hold on to the response object:
80
+ response = nil
81
+
77
82
  body.call(stream)
78
83
  else
79
84
  write_body(@version, body, head)
@@ -25,7 +25,7 @@ module Async
25
25
  module HTTP
26
26
  module Protocol
27
27
  module HTTP2
28
- # Typically used on the client side to represent a request and the incoming response.
28
+ # Typically used on the client side for writing a request and reading the incoming response.
29
29
  class Response < Protocol::Response
30
30
  class Stream < HTTP2::Stream
31
31
  def initialize(*)
@@ -39,6 +39,14 @@ module Async
39
39
 
40
40
  attr :response
41
41
 
42
+ def wait_for_input
43
+ # The input isn't ready until the response headers have been received:
44
+ @response.wait
45
+
46
+ # There is a possible race condition if you try to access @input - it might already be closed and nil.
47
+ return @response.body
48
+ end
49
+
42
50
  def accept_push_promise_stream(promised_stream_id, headers)
43
51
  stream = @connection.accept_push_promise_stream(promised_stream_id, &Stream.method(:accept))
44
52
 
@@ -81,9 +89,9 @@ module Async
81
89
 
82
90
  # Notify anyone waiting on the response headers to be received (or failure).
83
91
  def notify!
84
- if @notification
85
- @notification.signal
92
+ if notification = @notification
86
93
  @notification = nil
94
+ notification.signal
87
95
  end
88
96
  end
89
97
 
@@ -165,7 +173,7 @@ module Async
165
173
  end
166
174
 
167
175
  # Send a request and read it into this response.
168
- def send_request(request, task: Async::Task.current)
176
+ def send_request(request)
169
177
  @request = request
170
178
 
171
179
  # https://http2.github.io/http2-spec/#rfc.section.8.1.2.3
@@ -26,6 +26,7 @@ module Async
26
26
  module Protocol
27
27
  module HTTP2
28
28
  class Stream < ::Protocol::HTTP2::Stream
29
+ # A writable body which requests window updates when data is read from it.
29
30
  class Input < Body::Writable
30
31
  def initialize(stream, length)
31
32
  super(length)
@@ -113,7 +114,9 @@ module Async
113
114
  def stream(task)
114
115
  task.annotate("Streaming #{@body} to #{@stream}.")
115
116
 
116
- @body.call(Body::Stream.new(@stream.input, self))
117
+ input = @stream.wait_for_input
118
+
119
+ @body.call(Body::Stream.new(input, self))
117
120
  rescue Async::Stop
118
121
  # Ignore.
119
122
  end
@@ -212,6 +215,12 @@ module Async
212
215
  send_reset_stream(error.code)
213
216
  end
214
217
 
218
+ def wait_for_input
219
+ return @input
220
+ end
221
+
222
+ # Prepare the input stream which will be used for incoming data frames.
223
+ # @return [Input] the input body.
215
224
  def prepare_input(length)
216
225
  if @input.nil?
217
226
  @input = Input.new(self, length)
@@ -223,7 +232,7 @@ module Async
223
232
  def update_local_window(frame)
224
233
  consume_local_window(frame)
225
234
 
226
- # This is done on demand.
235
+ # This is done on demand in `Input#read`:
227
236
  # request_window_update
228
237
  end
229
238
 
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.46.5"
23
+ VERSION = "0.47.0"
24
24
  end
25
25
  end
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.46.5
4
+ version: 0.47.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: 2019-07-19 00:00:00.000000000 Z
11
+ date: 2019-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.11.0
47
+ version: 0.12.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.11.0
54
+ version: 0.12.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: protocol-http1
57
57
  requirement: !ruby/object:Gem::Requirement