async-http 0.35.0 → 0.35.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: 283968834f142ba97aa8ef79178b2e3c2d9b98da219af3936375f32ce153a792
4
- data.tar.gz: cbdb2828dc188ee52058ec498f829d1ee858696ff012b252ec7d6eefd1244898
3
+ metadata.gz: 38d3e8fe6b2bedcd8dfc48956ba07e2f70f9be363e419887baaad5c9dab3fab5
4
+ data.tar.gz: c924a3f88353066264b12d485a50ef894bd8c00f574a86d9fc7884519e00e366
5
5
  SHA512:
6
- metadata.gz: dfe240b6cf2f0a17e188df8809043be64fa8efca9abd49ea687979d6e371ecb818e50f1b70763694366560a9a6c24b5a4203e6afd8bd53fd38b5016159e39219
7
- data.tar.gz: b29a55a5d4409a531d79209432a1cb1ddbfe97dbdbb2c96db5d16269aa9335d9923ed81dcab3053ef0138f2cea6da284ac148d24db11093aadca98d1f1c61a55
6
+ metadata.gz: 7c930d3851d96957c9fc905c0b00ca0e0bb4e9ffc011f66f7e38763cc6293292e2442e7d67205c8c67934dbab82828b54735a3dce3855af3be9dd221828f5684
7
+ data.tar.gz: b6c3e1521e69ff048ba0dd5e8b89951d360eea7881f3df7488b66f48aad1b6e35562b9d91e7f1ecffb64cf130868b639596dcc52b05404d5fbf3e2a0f6e10534
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.add_dependency("async", "~> 1.6")
20
20
  spec.add_dependency("async-io", "~> 1.16")
21
21
 
22
- spec.add_dependency("http-protocol", "~> 0.6.0")
22
+ spec.add_dependency("http-protocol", "~> 0.7.0")
23
23
 
24
24
  # spec.add_dependency("openssl")
25
25
 
@@ -26,8 +26,8 @@ module Async
26
26
  # Invokes a callback once the body has finished reading.
27
27
  class Streamable < Wrapper
28
28
  def self.wrap(message, &block)
29
- if message and message.body
30
- if remaining = message.headers['content-length']
29
+ if message and body = message.body
30
+ if remaining = body.length
31
31
  remaining = Integer(remaining)
32
32
  end
33
33
 
@@ -30,9 +30,11 @@ module Async
30
30
  class Closed < StandardError
31
31
  end
32
32
 
33
- def initialize
33
+ def initialize(length = nil)
34
34
  @queue = Async::Queue.new
35
35
 
36
+ @length = length
37
+
36
38
  @count = 0
37
39
 
38
40
  @finished = false
@@ -41,6 +43,10 @@ module Async
41
43
  @error = nil
42
44
  end
43
45
 
46
+ def length
47
+ @length
48
+ end
49
+
44
50
  # Stop generating output; cause the next call to write to fail with the given error.
45
51
  def close(error = nil)
46
52
  unless @closed
@@ -33,6 +33,8 @@ module Async
33
33
  STATUS = ':status'.freeze
34
34
  VERSION = 'HTTP/2.0'.freeze
35
35
 
36
+ CONTENT_LENGTH = 'content-length'
37
+
36
38
  module Connection
37
39
  def initialize(*)
38
40
  super
@@ -86,15 +86,18 @@ module Async
86
86
  if response.nil?
87
87
  @stream.send_headers(nil, NO_RESPONSE, ::HTTP::Protocol::HTTP2::END_STREAM)
88
88
  elsif response.body?
89
- headers = Headers::Merged.new([
89
+ pseudo_headers = [
90
90
  [STATUS, response.status],
91
- ])
91
+ ]
92
92
 
93
93
  if length = response.body.length
94
- headers << [[::HTTP::Protocol::CONTENT_LENGTH, length]]
94
+ pseudo_headers << [CONTENT_LENGTH, length]
95
95
  end
96
96
 
97
- headers << response.headers
97
+ headers = Headers::Merged.new(
98
+ pseudo_headers,
99
+ response.headers
100
+ )
98
101
 
99
102
  @stream.send_headers(nil, headers)
100
103
  @stream.send_body(response.body)
@@ -27,6 +27,7 @@ module Async
27
27
  class Response < Protocol::Response
28
28
  def initialize(protocol, stream_id)
29
29
  @input = nil
30
+ @length = nil
30
31
 
31
32
  super(protocol.version, nil, nil, Headers.new, nil)
32
33
 
@@ -52,16 +53,18 @@ module Async
52
53
  def receive_headers(stream, headers, end_stream)
53
54
  headers.each do |key, value|
54
55
  if key == STATUS
55
- @status = value.to_i
56
+ @status = Integer(value)
56
57
  elsif key == REASON
57
58
  @reason = value
59
+ elsif key == CONTENT_LENGTH
60
+ @length = Integer(value)
58
61
  else
59
62
  @headers[key] = value
60
63
  end
61
64
  end
62
65
 
63
66
  unless end_stream
64
- @body = @input = Body::Writable.new
67
+ @body = @input = Body::Writable.new(@length)
65
68
  end
66
69
 
67
70
  # We are ready for processing:
@@ -91,6 +94,7 @@ module Async
91
94
  @notification.signal
92
95
  end
93
96
 
97
+ # Send a request and read it into this response.
94
98
  def send_request(request)
95
99
  # https://http2.github.io/http2-spec/#rfc.section.8.1.2.3
96
100
  # All HTTP/2 requests MUST include exactly one valid value for the :method, :scheme, and :path pseudo-header fields, unless it is a CONNECT request (Section 8.3). An HTTP request that omits mandatory pseudo-header fields is malformed (Section 8.1.2.6).
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.35.0"
23
+ VERSION = "0.35.1"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.35.0
4
+ version: 0.35.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.6.0
47
+ version: 0.7.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.6.0
54
+ version: 0.7.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: async-rspec
57
57
  requirement: !ruby/object:Gem::Requirement