async-http 0.43.0 → 0.43.1

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: e3bffeca561f19d6963c549eb6e3f0a570d9d858db4d10a925e7c04e6dbef562
4
- data.tar.gz: f366ca5851cd1f07b5d3339342206a8e141da9981664db29080952a30bfafb24
3
+ metadata.gz: 901472f2bea3d4389d6ac6adab0b2e78a86991e10da7a2e92a3fbae69f66e9a8
4
+ data.tar.gz: df036f736d8314edf42f784b159acfc2fd7c755294aae26130f23fcd5187a49b
5
5
  SHA512:
6
- metadata.gz: 7e5fb8fe9055183a638a51ba6565f7971ab796c5a4331b7ebfadf113b1f2da450613a6f7b7719d04eb23f75994b3c0b1508bd89f101f3322248cb7d4adbed581
7
- data.tar.gz: 7b18f8cad97b8f8264773134b90d2d74a4493898cf7a47c56b60ef1f343fe839c7e0b7352968f6d2da71249c2857e7ffad7c3a5ba65ba6b365a1460f46d5f353
6
+ metadata.gz: 379eb7bf5cb3ee6ee187989789869274e6f21fdf4fd5cfe60d0c492cec037898147675eac89b9974d7ecc99138664202628d330c66a00cddda4a3090b7285e2f
7
+ data.tar.gz: e1a8232a2f28032cc5ba057b0be010f4fc807e3e6f824dfa84507eb50272106d5d80d0f45b7e7f810ef4bac6c6d7d2be910280cc00f45487af42c8b1de194678
data/.gitignore CHANGED
@@ -1,5 +1,7 @@
1
+ .tags
2
+
1
3
  /.bundle/
2
- /.tags
4
+ /.yardoc
3
5
  /Gemfile.lock
4
6
  /_yardoc/
5
7
  /coverage/
@@ -8,5 +10,5 @@
8
10
  /spec/reports/
9
11
  /tmp/
10
12
 
11
- # rspec failure tracking
12
13
  .rspec_status
14
+ .covered.db
@@ -2,28 +2,30 @@ language: ruby
2
2
  dist: xenial
3
3
  cache: bundler
4
4
 
5
- before_install:
6
- - gem update --system
7
- - gem install bundler
8
-
9
5
  addons:
10
6
  apt:
11
7
  packages:
12
8
  - wrk
13
9
  - apache2-utils
10
+ homebrew:
11
+ packages:
12
+ - wrk
14
13
 
15
14
  matrix:
16
15
  include:
17
16
  - rvm: 2.4
18
17
  - rvm: 2.5
19
18
  - rvm: 2.6
19
+ - rvm: 2.6
20
+ env: COVERAGE=Summary,Coveralls
20
21
  - rvm: truffleruby
21
22
  - rvm: jruby-head
22
23
  env: JRUBY_OPTS="--debug -X+O"
23
24
  - rvm: ruby-head
24
- - rvm: rbx-3
25
+ - rvm: 2.6
26
+ os: osx
25
27
  allow_failures:
26
- - rvm: ruby-head
27
28
  - rvm: truffleruby
29
+ - rvm: ruby-head
28
30
  - rvm: jruby-head
29
- - rvm: rbx-3
31
+ - rvm: truffleruby
data/Gemfile CHANGED
@@ -6,8 +6,3 @@ gemspec
6
6
  group :development do
7
7
  gem 'pry'
8
8
  end
9
-
10
- group :test do
11
- gem 'simplecov'
12
- gem 'coveralls', require: false
13
- end
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency "async-rspec", "~> 1.10"
29
29
  spec.add_development_dependency "async-container", "~> 0.5.0"
30
30
 
31
+ spec.add_development_dependency "covered"
31
32
  spec.add_development_dependency "bundler"
32
33
  spec.add_development_dependency "rspec", "~> 3.6"
33
34
  spec.add_development_dependency "rake"
@@ -31,6 +31,7 @@ module Async
31
31
  end
32
32
  end
33
33
 
34
+ # @param reason [String] HTTP response line reason, ignored.
34
35
  def initialize(connection, version, status, reason, headers, body)
35
36
  @connection = connection
36
37
 
@@ -40,7 +40,6 @@ module Async
40
40
  }
41
41
 
42
42
  SERVER_SETTINGS = {
43
- ::Protocol::HTTP2::Settings::ENABLE_PUSH => 1,
44
43
  # We choose a lower maximum concurrent streams to avoid overloading a single connection/thread.
45
44
  ::Protocol::HTTP2::Settings::MAXIMUM_CONCURRENT_STREAMS => 32,
46
45
  ::Protocol::HTTP2::Settings::MAXIMUM_FRAME_SIZE => 0x100000,
@@ -48,12 +48,12 @@ module Async
48
48
 
49
49
  # Used by the client to send requests to the remote server.
50
50
  def call(request)
51
+ raise ::Protocol::HTTP2::Error, "Connection closed!" if self.closed?
52
+
51
53
  @count += 1
52
54
 
53
55
  response = Response.new(self, next_stream_id)
54
-
55
56
  response.send_request(request)
56
-
57
57
  response.wait
58
58
 
59
59
  return response
@@ -20,6 +20,8 @@
20
20
 
21
21
  require_relative 'stream'
22
22
 
23
+ require 'async/semaphore'
24
+
23
25
  module Async
24
26
  module HTTP
25
27
  module Protocol
@@ -29,7 +31,6 @@ module Async
29
31
  METHOD = ':method'.freeze
30
32
  PATH = ':path'.freeze
31
33
  AUTHORITY = ':authority'.freeze
32
- REASON = 'reason'.freeze
33
34
  STATUS = ':status'.freeze
34
35
  PROTOCOL = ':protocol'.freeze
35
36
 
@@ -41,6 +42,9 @@ module Async
41
42
 
42
43
  @count = 0
43
44
  @reader = nil
45
+
46
+ # Writing multiple frames at the same time can cause odd problems if frames are only partially written. So we use a semaphore to ensure frames are written in their entirety.
47
+ @write_frame_guard = Async::Semaphore.new(1)
44
48
  end
45
49
 
46
50
  attr :stream
@@ -61,13 +65,19 @@ module Async
61
65
  @reader = nil
62
66
  end
63
67
 
68
+ def write_frame(frame)
69
+ # We don't want to write multiple frames at the same time.
70
+ @write_frame_guard.acquire do
71
+ super
72
+ end
73
+ end
74
+
64
75
  def read_in_background(task: Task.current)
65
76
  task.async do |nested_task|
66
77
  nested_task.annotate("#{version} reading data for #{self.class}")
67
78
 
68
79
  begin
69
- # Even thought the connection might be logically closed, we are not done until all HTTP/2 streams are closed or the underlying I/O is closed.
70
- while !@stream.closed?
80
+ while !self.closed?
71
81
  self.read_frame
72
82
  end
73
83
  ensure
@@ -127,7 +127,6 @@ module Async
127
127
 
128
128
  NO_RESPONSE = [
129
129
  [STATUS, '500'],
130
- [REASON, "No response generated"]
131
130
  ]
132
131
 
133
132
  def send_response(response)
@@ -138,14 +137,14 @@ module Async
138
137
  [STATUS, response.status],
139
138
  ]
140
139
 
141
- if length = response.body.length
142
- pseudo_headers << [CONTENT_LENGTH, length]
143
- end
144
-
145
140
  if protocol = response.protocol
146
141
  pseudo_headers << [PROTOCOL, protocol]
147
142
  end
148
143
 
144
+ if length = response.body.length
145
+ pseudo_headers << [CONTENT_LENGTH, length]
146
+ end
147
+
149
148
  headers = ::Protocol::HTTP::Headers::Merged.new(
150
149
  pseudo_headers,
151
150
  response.headers
@@ -154,7 +153,7 @@ module Async
154
153
  @stream.send_headers(nil, headers)
155
154
  @stream.send_body(response.body)
156
155
  else
157
- headers = Headers::Merged.new([
156
+ headers = ::Protocol::HTTP::Headers::Merged.new([
158
157
  [STATUS, response.status],
159
158
  ], response.headers)
160
159
 
@@ -85,8 +85,6 @@ module Async
85
85
  headers.each do |key, value|
86
86
  if key == STATUS
87
87
  @status = Integer(value)
88
- elsif key == REASON
89
- @reason = value
90
88
  elsif key == CONTENT_LENGTH
91
89
  @length = Integer(value)
92
90
  elsif key == PROTOCOL
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.43.0"
23
+ VERSION = "0.43.1"
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.43.0
4
+ version: 0.43.1
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-06 00:00:00.000000000 Z
11
+ date: 2019-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: 0.5.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: covered
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: bundler
113
127
  requirement: !ruby/object:Gem::Requirement