async-http 0.43.1 → 0.44.0

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: 901472f2bea3d4389d6ac6adab0b2e78a86991e10da7a2e92a3fbae69f66e9a8
4
- data.tar.gz: df036f736d8314edf42f784b159acfc2fd7c755294aae26130f23fcd5187a49b
3
+ metadata.gz: 2765c2877e0c9ee3f520b0a04a6c67f258abccee76500ebbd18028b279867cc9
4
+ data.tar.gz: '06969faca4325c0c2e1c41b503a6cd67900419eb7fcd84481eab24bb019eb1b0'
5
5
  SHA512:
6
- metadata.gz: 379eb7bf5cb3ee6ee187989789869274e6f21fdf4fd5cfe60d0c492cec037898147675eac89b9974d7ecc99138664202628d330c66a00cddda4a3090b7285e2f
7
- data.tar.gz: e1a8232a2f28032cc5ba057b0be010f4fc807e3e6f824dfa84507eb50272106d5d80d0f45b7e7f810ef4bac6c6d7d2be910280cc00f45487af42c8b1de194678
6
+ metadata.gz: df4f1e508e7f5f4ec112f24f092099189bbd767d3c0397d0544479ad2eb6fc8d94522443e8ef9a3cf01b6916763361742ff0d398a3a545395f5624399d28c6bd
7
+ data.tar.gz: 4291820ab6b83d9ab2a23359b689da70ec681f0e494f3832dfeb7bcdffb5a2406ad81c2bda0f9e472bd9e63fabd914e386190551de4be68340e779c8c7a4a09c
data/async-http.gemspec CHANGED
@@ -21,12 +21,12 @@ 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.3.0")
24
+ spec.add_dependency("protocol-http2", "~> 0.4.0")
25
25
 
26
26
  # spec.add_dependency("openssl")
27
27
 
28
28
  spec.add_development_dependency "async-rspec", "~> 1.10"
29
- spec.add_development_dependency "async-container", "~> 0.5.0"
29
+ spec.add_development_dependency "async-container", "~> 0.14"
30
30
 
31
31
  spec.add_development_dependency "covered"
32
32
  spec.add_development_dependency "bundler"
@@ -42,7 +42,9 @@ module Async
42
42
  super
43
43
 
44
44
  @streams.each do |id, stream|
45
- stream.stop_connection(error)
45
+ if stream.respond_to?(:stop_connection)
46
+ stream.stop_connection(error)
47
+ end
46
48
  end
47
49
  end
48
50
 
@@ -52,7 +54,10 @@ module Async
52
54
 
53
55
  @count += 1
54
56
 
55
- response = Response.new(self, next_stream_id)
57
+ stream_id = next_stream_id
58
+ response = Response.new(self, stream_id)
59
+ @streams[stream_id] = response.stream
60
+
56
61
  response.send_request(request)
57
62
  response.wait
58
63
 
@@ -80,6 +80,8 @@ module Async
80
80
  while !self.closed?
81
81
  self.read_frame
82
82
  end
83
+ rescue EOFError, Async::Wrapper::Cancelled
84
+ # Stream closed.
83
85
  ensure
84
86
  stop_connection($!)
85
87
  end
@@ -110,14 +112,6 @@ module Async
110
112
  def version
111
113
  VERSION
112
114
  end
113
-
114
- def close
115
- Async.logger.debug(self) {"Closing connection"}
116
-
117
- @reader.stop if @reader
118
-
119
- super
120
- end
121
115
  end
122
116
  end
123
117
  end
@@ -30,6 +30,8 @@ module Async
30
30
  super(nil, nil, nil, nil, VERSION, ::Protocol::HTTP::Headers.new)
31
31
 
32
32
  @input = nil
33
+ @length = nil
34
+
33
35
  @connection = connection
34
36
  @stream = Stream.new(self, connection, stream_id)
35
37
  end
@@ -46,12 +48,14 @@ module Async
46
48
 
47
49
  def create_promise_stream(headers, stream_id)
48
50
  request = self.class.new(@connection, stream_id)
51
+ @connection.streams[stream_id] = request.stream
52
+
49
53
  request.receive_headers(self, headers, false)
50
54
 
51
55
  return request.stream
52
56
  end
53
57
 
54
- def close!(state)
58
+ def close
55
59
  end
56
60
 
57
61
  # @return [Stream] the promised stream, on which to send data.
@@ -95,18 +99,26 @@ module Async
95
99
  return @stream.send_failure(400, "Request protocol already specified") if @protocol
96
100
 
97
101
  @protocol = value
102
+ elsif key == CONTENT_LENGTH
103
+ return @stream.send_failure(400, "Request protocol already content length") if @length
104
+
105
+ @length = Integer(value)
98
106
  else
99
107
  @headers[key] = value
100
108
  end
101
109
  end
102
110
 
103
- # We only construct the input/body if data is coming.
104
- unless end_stream
105
- @body = @input = Body::Writable.new
111
+ unless @scheme and @method and @path
112
+ send_reset_stream(PROTOCOL_ERROR)
113
+ else
114
+ # We only construct the input/body if data is coming.
115
+ unless end_stream
116
+ @body = @input = Body::Writable.new(@length)
117
+ end
118
+
119
+ # We are ready for processing:
120
+ @connection.requests.enqueue self
106
121
  end
107
-
108
- # We are ready for processing:
109
- @connection.requests.enqueue self
110
122
  end
111
123
 
112
124
  def receive_data(stream, data, end_stream)
@@ -40,19 +40,22 @@ module Async
40
40
  @promises = nil
41
41
  end
42
42
 
43
+ attr :stream
44
+
43
45
  def promises
44
46
  @promises ||= Async::Queue.new
45
47
  end
46
48
 
47
49
  def create_promise_stream(headers, stream_id)
48
50
  promise = Promise.new(@connection, headers, stream_id)
51
+ @connection.streams[stream_id] = promise.stream
49
52
 
50
53
  self.promises.enqueue(promise)
51
54
 
52
55
  return promise.stream
53
56
  end
54
57
 
55
- def close!(state)
58
+ def close
56
59
  self.promises.enqueue(nil)
57
60
  end
58
61
 
@@ -46,6 +46,8 @@ module Async
46
46
  def create_stream(stream_id)
47
47
  request = Request.new(self, stream_id)
48
48
 
49
+ @streams[stream_id] = request.stream
50
+
49
51
  return request.stream
50
52
  end
51
53
 
@@ -43,10 +43,10 @@ module Async
43
43
  @delegate.create_promise_stream(headers, stream_id)
44
44
  end
45
45
 
46
- def close!(state = :closed)
46
+ def close(state = :closed)
47
47
  super
48
48
 
49
- @delegate.close!(state)
49
+ @delegate.close
50
50
  end
51
51
 
52
52
  def send_body(body, task: Async::Task.current)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.43.1"
23
+ VERSION = "0.44.0"
24
24
  end
25
25
  end
data/tasks/server.rake CHANGED
@@ -47,7 +47,9 @@ task :server do
47
47
  return Protocol::HTTP::Response[200, {'content-type' => 'text/plain'}, ["Hello World"]]
48
48
  end
49
49
 
50
- container = Async::Container::Forked.new(concurrency: 1) do
50
+ container = Async::Container.new
51
+
52
+ container.run(count: 1) do
51
53
  #GC.disable
52
54
 
53
55
  server.run
@@ -86,7 +88,9 @@ task :wrk do
86
88
 
87
89
  concurrency = 1
88
90
 
89
- container = Async::Container::Forked.new(concurrency: concurrency) do
91
+ container = Async::Container.new
92
+
93
+ container.run(count: concurrency) do
90
94
  server.run
91
95
  end
92
96
 
@@ -96,5 +100,5 @@ task :wrk do
96
100
  system("wrk", "-c", concurrency.to_s, "-d", "10", "-t", concurrency.to_s, url)
97
101
  end
98
102
 
99
- container.stop
103
+ container.stop(false)
100
104
  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.43.1
4
+ version: 0.44.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-06-10 00:00:00.000000000 Z
11
+ date: 2019-06-12 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.3.0
75
+ version: 0.4.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.3.0
82
+ version: 0.4.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: async-rspec
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: 0.5.0
103
+ version: '0.14'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: 0.5.0
110
+ version: '0.14'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: covered
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -247,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
247
247
  - !ruby/object:Gem::Version
248
248
  version: '0'
249
249
  requirements: []
250
- rubygems_version: 3.0.2
250
+ rubygems_version: 3.0.3
251
251
  signing_key:
252
252
  specification_version: 4
253
253
  summary: A HTTP client and server library.