async-http 0.46.2 → 0.46.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fcfa84f957c4231842d3558f00cdf5cf75792d19950260d5868422e758f6b684
4
- data.tar.gz: a412a95c99838202bfd1f6c941697716da093d24d2859177868950ae8a331482
3
+ metadata.gz: 1ba8a8a466d5347cf27a55b523dfa0b8faec5dbd88f0ddbd977c053333762bb9
4
+ data.tar.gz: 2675f68f80ee0ec638d5922de49710291208eb610f202b37595b5cc64a382465
5
5
  SHA512:
6
- metadata.gz: 94bfd0b556a3e217b9c296c23fa07bf02e3cc60ea6e60f9006806be7b7b82fcf6ba2cc82ed4b1adbd5e14b0a35ddd32e0ce80253df58e340c8fada96af78d791
7
- data.tar.gz: b19981853471653da1ea94bdb95e022770fdc829bc1172cae9d2409ae6cbae442b58dfd2f5347d27d91107e09a26936272fddbd03de6d3624d7458c460249868
6
+ metadata.gz: 627f99a4575491bf2141851f4873735ae4a4df76f50c54500e790df5a8f0b939b4e43c78088d148b43d2ea63be26f9941f6bdbe3be37175d0452ffdb4dcd40a4
7
+ data.tar.gz: 0be194518b6c9470037f0a1443fbd93669da82afb99392cd7e016c277f5c91f8cbecd3a24502b54f3d5f6b14a4bb13e1c16297a3087959e965d5b3621befcbed
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
21
21
 
22
22
  spec.add_dependency("protocol-http", "~> 0.8.0")
23
23
  spec.add_dependency("protocol-http1", "~> 0.8.0")
24
- spec.add_dependency("protocol-http2", "~> 0.8.0")
24
+ spec.add_dependency("protocol-http2", "~> 0.9.0")
25
25
 
26
26
  # spec.add_dependency("openssl")
27
27
 
@@ -34,14 +34,14 @@ module Async
34
34
  CLIENT_SETTINGS = {
35
35
  ::Protocol::HTTP2::Settings::ENABLE_PUSH => 0,
36
36
  ::Protocol::HTTP2::Settings::MAXIMUM_FRAME_SIZE => 0x100000,
37
- ::Protocol::HTTP2::Settings::INITIAL_WINDOW_SIZE => 0x7FFFFFFF,
37
+ ::Protocol::HTTP2::Settings::INITIAL_WINDOW_SIZE => 0xF00000,
38
38
  }
39
39
 
40
40
  SERVER_SETTINGS = {
41
41
  # We choose a lower maximum concurrent streams to avoid overloading a single connection/thread.
42
- ::Protocol::HTTP2::Settings::MAXIMUM_CONCURRENT_STREAMS => 10,
42
+ ::Protocol::HTTP2::Settings::MAXIMUM_CONCURRENT_STREAMS => 128,
43
43
  ::Protocol::HTTP2::Settings::MAXIMUM_FRAME_SIZE => 0x100000,
44
- ::Protocol::HTTP2::Settings::INITIAL_WINDOW_SIZE => 0x7FFFFFFF,
44
+ ::Protocol::HTTP2::Settings::INITIAL_WINDOW_SIZE => 0xF00000,
45
45
  ::Protocol::HTTP2::Settings::ENABLE_CONNECT_PROTOCOL => 1,
46
46
  }
47
47
 
@@ -123,26 +123,6 @@ module Async
123
123
  def version
124
124
  VERSION
125
125
  end
126
-
127
- # def encode_headers(headers, buffer = String.new.b)
128
- # super.tap do |data|
129
- # Async.logger.debug(self) do |buffer|
130
- # buffer.puts "Encode headers: #{headers.inspect}"
131
- # buffer.puts "-> #{data.inspect}"
132
- # buffer.puts "@encoder: #{@encoder.inspect}"
133
- # end
134
- # end
135
- # end
136
- #
137
- # def decode_headers(data)
138
- # super.tap do |headers|
139
- # Async.logger.debug(self) do |buffer|
140
- # buffer.puts "Decode headers: #{data.inspect}"
141
- # buffer.puts "-> #{headers.inspect}"
142
- # buffer.puts "@decoder: #{@decoder.inspect}"
143
- # end
144
- # end
145
- # end
146
126
  end
147
127
  end
148
128
  end
@@ -94,8 +94,7 @@ module Async
94
94
  else
95
95
  # We only construct the input/body if data is coming.
96
96
  unless end_stream
97
- @input = Body::Writable.new(@length)
98
- @request.body = @input
97
+ @request.body = prepare_input(@length)
99
98
  end
100
99
 
101
100
  # We are ready for processing:
@@ -70,8 +70,7 @@ module Async
70
70
  else
71
71
  # We only construct the input/body if data is coming.
72
72
  unless end_stream
73
- @input = Body::Writable.new(@length)
74
- @response.body = @input
73
+ @response.body = prepare_input(@length)
75
74
  end
76
75
  end
77
76
 
@@ -19,13 +19,31 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  require 'protocol/http2/stream'
22
+ require_relative '../../body/writable'
22
23
 
23
24
  module Async
24
25
  module HTTP
25
26
  module Protocol
26
27
  module HTTP2
27
28
  class Stream < ::Protocol::HTTP2::Stream
28
- class Buffer
29
+ class Input < Body::Writable
30
+ def initialize(stream, length)
31
+ super(length)
32
+
33
+ @stream = stream
34
+ end
35
+
36
+ def read
37
+ if chunk = super
38
+ # If we read a chunk fron the stream, we want to extend the window if required so more data will be provided.
39
+ @stream.request_window_update
40
+ end
41
+
42
+ return chunk
43
+ end
44
+ end
45
+
46
+ class Output
29
47
  def initialize(stream, body, task: Task.current)
30
48
  @stream = stream
31
49
 
@@ -37,6 +55,7 @@ module Async
37
55
  @task = task.async(&self.method(:passthrough))
38
56
  end
39
57
 
58
+ # Reads chunks from the given body and writes them to the stream as fast as possible.
40
59
  def passthrough(task)
41
60
  while chunk = self.read
42
61
  maximum_size = @stream.available_frame_size
@@ -113,11 +132,11 @@ module Async
113
132
  @headers = nil
114
133
  @trailers = nil
115
134
 
116
- # Input buffer (receive_data):
135
+ # Input buffer, reading request body, or response body (receive_data):
117
136
  @length = nil
118
137
  @input = nil
119
138
 
120
- # Output buffer (window_updated):
139
+ # Output buffer, writing request body or response body (window_updated):
121
140
  @output = nil
122
141
  end
123
142
 
@@ -165,6 +184,21 @@ module Async
165
184
  send_reset_stream(error.code)
166
185
  end
167
186
 
187
+ def prepare_input(length)
188
+ if @input.nil?
189
+ @input = Input.new(self, length)
190
+ else
191
+ raise ArgumentError, "Input body already prepared!"
192
+ end
193
+ end
194
+
195
+ def update_local_window(frame)
196
+ consume_local_window(frame)
197
+
198
+ # This is done on demand.
199
+ # request_window_update
200
+ end
201
+
168
202
  def process_data(frame)
169
203
  data = frame.unpack
170
204
 
@@ -188,7 +222,7 @@ module Async
188
222
 
189
223
  # Set the body and begin sending it.
190
224
  def send_body(body)
191
- @output = Buffer.new(self, body)
225
+ @output = Output.new(self, body)
192
226
  end
193
227
 
194
228
  def window_updated(size)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.46.2"
23
+ VERSION = "0.46.3"
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.2
4
+ version: 0.46.3
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-06-23 00:00:00.000000000 Z
11
+ date: 2019-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.8.0
75
+ version: 0.9.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.8.0
82
+ version: 0.9.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: async-rspec
85
85
  requirement: !ruby/object:Gem::Requirement