async-http 0.28.0 → 0.28.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: b0902e29085dc6e9908afb45613d5a8d923f60767fb111b2a1ef5d8a549b75dd
4
- data.tar.gz: ff5f7aaf1141e192d95b53a197ef12b5ad4404fad761d09201367d0f029decf5
3
+ metadata.gz: 16e5b6f4cbf9aa5955ae132734d5055076ee5dce533f0aafd4a71ec3812d422a
4
+ data.tar.gz: 4e0aade981100c1bf1e1b7a1ec71fb72894a60f729262e7090010ca2b7d7f05a
5
5
  SHA512:
6
- metadata.gz: a70f1bb712b485d3aeae3cc374f4c430f628ac3e8db194757f4b83233e1fc91937d8b13ad04d7d22e0ee3ff8cb95d9515063211e98ff0d796beced993c52a282
7
- data.tar.gz: '04821bd0c538d1df175152e3591cef5603a4ab593f57313378bb87a088a98784f40e0f5fc05ebeb988f3fd710329b0859fdec560c7b0048ab17b8efd3115f649'
6
+ metadata.gz: ee421022248aa197ef31e1a3b4d7b26c04bbeaea88585ddf628305e2b0736df86035e8f0f980434ec7202af235a00bdce7cb4a6dbcb3469286c41a256acb6aac
7
+ data.tar.gz: 6385e47d16633c5f183b582951e3f5c4dc454473155c8fb407e7e475f142422a4f0164d60dd8d5090a023bebad9e039ee26e3bc95eff7a1e422167260a817fed
data/async-http.gemspec CHANGED
@@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ["lib"]
18
18
 
19
19
  spec.add_dependency("async", "~> 1.6")
20
- spec.add_dependency("async-io", "~> 1.14")
20
+ spec.add_dependency("async-io", "~> 1.15")
21
21
 
22
- spec.add_dependency("http-protocol", "~> 0.1.0")
22
+ spec.add_dependency("http-protocol", "~> 0.2.0")
23
23
 
24
24
  # spec.add_dependency("openssl")
25
25
 
@@ -29,7 +29,7 @@ module Async
29
29
  METHOD = ':method'.freeze
30
30
  PATH = ':path'.freeze
31
31
  AUTHORITY = ':authority'.freeze
32
- REASON = ':reason'.freeze
32
+ REASON = 'reason'.freeze
33
33
  STATUS = ':status'.freeze
34
34
  VERSION = 'HTTP/2.0'.freeze
35
35
 
@@ -77,18 +77,21 @@ module Async
77
77
  def receive_reset_stream(stream, error_code)
78
78
  end
79
79
 
80
- NO_RESPONSE = [[STATUS, '500'], [REASON, "No response generated"]]
80
+ NO_RESPONSE = [
81
+ [STATUS, '500'],
82
+ [REASON, "No response generated"]
83
+ ]
81
84
 
82
85
  def send_response(response)
83
86
  if response.nil?
84
87
  @stream.send_headers(nil, NO_RESPONSE, ::HTTP::Protocol::HTTP2::END_STREAM)
85
88
  else
86
- headers = Headers::Merged.new({
87
- STATUS => response.status,
88
- REASON => response.reason,
89
- }, response.headers)
89
+ headers = Headers::Merged.new([
90
+ [STATUS, response.status],
91
+ [REASON, response.reason],
92
+ ], response.headers)
90
93
 
91
- if response.body.nil?
94
+ if response.body.nil? or response.body.empty?
92
95
  @stream.send_headers(nil, headers, ::HTTP::Protocol::HTTP2::END_STREAM)
93
96
  else
94
97
  @stream.send_headers(nil, headers)
@@ -54,35 +54,37 @@ module Async
54
54
  chunk = @remainder
55
55
  @remainder = nil
56
56
  elsif chunk = @body.read
57
+ # There was a new chunk of data to send
57
58
  else
58
59
  @body = nil
59
60
 
60
61
  # @body.read above might take a while and a stream reset might be received in the mean time.
61
- unless @state == :closed
62
+ unless closed?
62
63
  send_data(nil, ::HTTP::Protocol::HTTP2::END_STREAM)
63
64
  end
64
65
 
65
66
  return false
66
67
  end
67
68
 
68
- return false if @state == :closed
69
+ return false if closed?
69
70
 
70
71
  if chunk.bytesize <= maximum_size
71
72
  send_data(chunk, maximum_size: maximum_size)
72
-
73
- return true
74
73
  else
75
- send_data(chunk.byteslice(0, maximum_size), padding_size: 0)
76
- @remainder = chunk.byteslice(maximum_size, chunk.bytesize - maximum_size)
74
+ send_data(chunk.byteslice(0, maximum_size), maximum_size: maximum_size)
77
75
 
78
- return false
76
+ @remainder = chunk.byteslice(maximum_size, chunk.bytesize - maximum_size)
79
77
  end
78
+
79
+ return true
80
80
  end
81
81
 
82
82
  def window_updated
83
83
  return unless @body
84
84
 
85
- while send_chunk; end
85
+ while send_chunk
86
+ # There could be more data to send...
87
+ end
86
88
  end
87
89
 
88
90
  def receive_headers(frame)
@@ -108,6 +110,7 @@ module Async
108
110
 
109
111
  if @body
110
112
  @body.stop(EOFError.new(error_code))
113
+ @body = nil
111
114
  end
112
115
 
113
116
  delegate.receive_reset_stream(self, error_code)
@@ -71,17 +71,17 @@ module Async
71
71
  end
72
72
 
73
73
  def port
74
- @url.port || default_port
74
+ @options[:port] || @url.port || default_port
75
75
  end
76
76
 
77
77
  def hostname
78
- @options.fetch(:hostname, @url.hostname)
78
+ @options[:hostname] || @url.hostname
79
79
  end
80
80
 
81
81
  DEFAULT_ALPN_PROTOCOLS = ['h2', 'http/1.1'].freeze
82
82
 
83
83
  def alpn_protocols
84
- @options.fetch(:alpn_protocols, DEFAULT_ALPN_PROTOCOLS)
84
+ @options[:alpn_protocols] || DEFAULT_ALPN_PROTOCOLS
85
85
  end
86
86
 
87
87
  def ssl_context
@@ -98,20 +98,22 @@ module Async
98
98
  {reuse_port: @options[:reuse_port] ? true : false}
99
99
  end
100
100
 
101
- def endpoint
102
- unless @endpoint
103
- @endpoint = Async::IO::Endpoint.tcp(hostname, port, tcp_options)
104
-
105
- if secure?
106
- # Wrap it in SSL:
107
- @endpoint = Async::IO::SSLEndpoint.new(@endpoint,
108
- ssl_context: ssl_context,
109
- hostname: self.hostname
110
- )
111
- end
101
+ def build_endpoint(endpoint = nil)
102
+ endpoint ||= Async::IO::Endpoint.tcp(hostname, port, tcp_options)
103
+
104
+ if secure?
105
+ # Wrap it in SSL:
106
+ return Async::IO::SSLEndpoint.new(endpoint,
107
+ ssl_context: self.ssl_context,
108
+ hostname: self.hostname
109
+ )
112
110
  end
113
111
 
114
- return @endpoint
112
+ return endpoint
113
+ end
114
+
115
+ def endpoint
116
+ @endpoint ||= build_endpoint
115
117
  end
116
118
 
117
119
  def bind(*args, &block)
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module HTTP
23
- VERSION = "0.28.0"
23
+ VERSION = "0.28.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.28.0
4
+ version: 0.28.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: 2018-07-31 00:00:00.000000000 Z
11
+ date: 2018-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '1.14'
33
+ version: '1.15'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '1.14'
40
+ version: '1.15'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: http-protocol
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.0
47
+ version: 0.2.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.1.0
54
+ version: 0.2.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: async-rspec
57
57
  requirement: !ruby/object:Gem::Requirement