async-http 0.50.13 → 0.51.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: 2cecbbc1a65dc4e0697fab222184c9a310bdaccfb5673f2200c3686f77ab7b9e
4
- data.tar.gz: 88a4d5a5b7c10f48033f78ac838c0b75d969f85a33e9ccca07bd0f587865d8ab
3
+ metadata.gz: 62fe3621934ee594b2c2d2b2056208a4298b6df2f1f9f831560df9d14263d220
4
+ data.tar.gz: d6af75111b6085d3c7df5643290486a81b2c99b69506310b80849f44fbaec24a
5
5
  SHA512:
6
- metadata.gz: 9f1bb76e135ec8d00508c5c1625d017e79ba87a19552ea4968b3a206f65fb3702623b2f1d96f80a88948ccbf959e3aac8a959dcc5c86a3cd65cd9159a9b6ac15
7
- data.tar.gz: b8ea5b50c9a4b76ddf9cd21484eba947674c590410e7335b10c24823997fa9d9c7235e160ee9d804905083e31ee51dca83faea02265421734da35227a9bf7bb0
6
+ metadata.gz: 60b2c696a4396dd5058413436666b37acf112eeda5da8c66c7182285e6587478869b90850a2328115146e2008ac9008c526a08c519a6f74b1167f5390c82246f
7
+ data.tar.gz: af80653e3cb7e9619b56b7d40a098b252ae1749b0c1a2a1d733d85204492c73d274f604484e6de5703c0c9e3278a34b94ffc338478b38d9b5a4db21619b77204
@@ -21,8 +21,8 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency("async-io", "~> 1.28")
22
22
  spec.add_dependency("async-pool", "~> 0.2")
23
23
 
24
- spec.add_dependency("protocol-http", "~> 0.17.0")
25
- spec.add_dependency("protocol-http1", "~> 0.11.0")
24
+ spec.add_dependency("protocol-http", "~> 0.18.0")
25
+ spec.add_dependency("protocol-http1", "~> 0.12.0")
26
26
  spec.add_dependency("protocol-http2", "~> 0.13.0")
27
27
 
28
28
  # spec.add_dependency("openssl")
@@ -121,7 +121,7 @@ module Async
121
121
  else
122
122
  raise
123
123
  end
124
- rescue IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE
124
+ rescue SocketError, IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE
125
125
  if connection
126
126
  @pool.release(connection)
127
127
  connection = nil
@@ -33,7 +33,7 @@ module Async
33
33
  @options = options
34
34
  end
35
35
 
36
- def call(method, url, headers = [], body = nil)
36
+ def call(method, url, headers = nil, body = nil)
37
37
  endpoint = Endpoint.parse(url)
38
38
  key = host_key(endpoint)
39
39
 
@@ -42,6 +42,7 @@ module Async
42
42
  end
43
43
 
44
44
  body = Body::Buffered.wrap(body)
45
+ headers = ::Protocol::HTTP::Headers[headers]
45
46
 
46
47
  request = ::Protocol::HTTP::Request.new(client.scheme, endpoint.authority, method, endpoint.path, nil, headers, body)
47
48
 
@@ -58,7 +59,7 @@ module Async
58
59
  end
59
60
 
60
61
  ::Protocol::HTTP::Methods.each do |name, verb|
61
- define_method(verb.downcase) do |url, headers = [], body = nil|
62
+ define_method(verb.downcase) do |url, headers = nil, body = nil|
62
63
  self.call(verb, url.to_str, headers, body)
63
64
  end
64
65
  end
@@ -31,6 +31,8 @@ module Async
31
31
  def call(request, task: Task.current)
32
32
  Async.logger.debug(self) {"#{request.method} #{request.path} #{request.headers.inspect}"}
33
33
 
34
+ trailers = request.headers.trailers!
35
+
34
36
  # We carefully interpret https://tools.ietf.org/html/rfc7230#section-6.3.1 to implement this correctly.
35
37
  begin
36
38
  write_request(request.authority, request.method, request.path, @version, request.headers)
@@ -39,8 +41,6 @@ module Async
39
41
  raise RequestFailed
40
42
  end
41
43
 
42
- request.headers.trailers!
43
-
44
44
  if request.body?
45
45
  body = request.body
46
46
 
@@ -63,7 +63,7 @@ module Async
63
63
  subtask.annotate("Streaming body.")
64
64
 
65
65
  # Once we start writing the body, we can't recover if the request fails. That's because the body might be generated dynamically, streaming, etc.
66
- write_body(@version, body, false, request.trailers)
66
+ write_body(@version, body, false, trailers)
67
67
  end
68
68
  end
69
69
  elsif protocol = request.protocol
@@ -60,8 +60,9 @@ module Async
60
60
  return if @stream.nil? or @stream.closed?
61
61
 
62
62
  if response
63
+ trailers = response.headers.trailers!
64
+
63
65
  write_response(@version, response.status, response.headers)
64
- response.headers.trailers!
65
66
 
66
67
  body = response.body
67
68
 
@@ -85,7 +86,6 @@ module Async
85
86
  body.call(stream)
86
87
  else
87
88
  head = request.head?
88
- trailers = response.trailers
89
89
 
90
90
  request = nil unless body
91
91
  response = nil
@@ -101,7 +101,7 @@ module Async
101
101
  self.consume_window
102
102
  self.read_frame
103
103
  end
104
- rescue IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE, Async::Wrapper::Cancelled
104
+ rescue SocketError, IOError, EOFError, Errno::ECONNRESET, Errno::EPIPE, Async::Wrapper::Cancelled
105
105
  # Ignore.
106
106
  ensure
107
107
  # Don't call #close twice.
@@ -183,8 +183,12 @@ module Async
183
183
  headers = ::Protocol::HTTP::Headers::Merged.new(protocol_headers, response.headers)
184
184
 
185
185
  if body = response.body and !self.head?
186
+ # This function informs the headers object that any subsequent headers are going to be trailers. Therefore, it must be called *before* sending the headers, to avoid any race conditions.
187
+ trailers = response.headers.trailers!
188
+
186
189
  @stream.send_headers(nil, headers)
187
- @stream.send_body(body, response.trailers)
190
+
191
+ @stream.send_body(body, trailers)
188
192
  else
189
193
  # Ensure the response body is closed if we are ending the stream:
190
194
  response.close
@@ -215,13 +215,16 @@ module Async
215
215
  if request.body.nil?
216
216
  @stream.send_headers(nil, headers, ::Protocol::HTTP2::END_STREAM)
217
217
  else
218
+ # This function informs the headers object that any subsequent headers are going to be trailers. Therefore, it must be called *before* sending the headers, to avoid any race conditions.
219
+ trailers = request.headers.trailers!
220
+
218
221
  begin
219
222
  @stream.send_headers(nil, headers)
220
223
  rescue
221
224
  raise RequestFailed
222
225
  end
223
226
 
224
- @stream.send_body(request.body, request.trailers)
227
+ @stream.send_body(request.body, trailers)
225
228
  end
226
229
  end
227
230
  end
@@ -61,8 +61,6 @@ module Async
61
61
  end
62
62
 
63
63
  def receive_trailing_headers(headers, end_stream)
64
- @headers.trailers!
65
-
66
64
  headers.each do |key, value|
67
65
  if @trailers.include?(key)
68
66
  add_header(key, value)
@@ -76,6 +74,7 @@ module Async
76
74
  if @headers.nil?
77
75
  @headers = ::Protocol::HTTP::Headers.new
78
76
  self.receive_initial_headers(super, frame.end_stream?)
77
+
79
78
  @trailers = @headers[TRAILERS]
80
79
  elsif @trailers and frame.end_stream?
81
80
  self.receive_trailing_headers(super, frame.end_stream?)
@@ -31,18 +31,18 @@ module Async
31
31
  # Behaves like a TCP endpoint for the purposes of connecting to a remote host.
32
32
  class Proxy
33
33
  module Client
34
- def proxy(endpoint, headers = [])
34
+ def proxy(endpoint, headers = nil)
35
35
  Proxy.new(self, endpoint.authority(false), headers)
36
36
  end
37
37
 
38
38
  # Create a client that will proxy requests through the current client.
39
- def proxied_client(endpoint, headers = [])
39
+ def proxied_client(endpoint, headers = nil)
40
40
  proxy = self.proxy(endpoint, headers)
41
41
 
42
42
  return self.class.new(proxy.wrap_endpoint(endpoint))
43
43
  end
44
44
 
45
- def proxied_endpoint(endpoint, headers = [])
45
+ def proxied_endpoint(endpoint, headers = nil)
46
46
  proxy = self.proxy(endpoint, headers)
47
47
 
48
48
  return proxy.wrap_endpoint(endpoint)
@@ -55,7 +55,7 @@ module Async
55
55
  # @param port [String] the port number to connect to.
56
56
  # @param headers [Array] an optional list of headers to use when establishing the connection.
57
57
  # @see Async::IO::Endpoint#tcp
58
- def self.tcp(client, host, port, headers = [])
58
+ def self.tcp(client, host, port, headers = nil)
59
59
  self.new(client, "#{host}:#{port}", headers)
60
60
  end
61
61
 
@@ -63,7 +63,7 @@ module Async
63
63
  # @param client [Async::HTTP::Client] the client which will be used as a proxy server.
64
64
  # @param endpoint [Async::HTTP::Endpoint] the endpoint to connect to.
65
65
  # @param headers [Array] an optional list of headers to use when establishing the connection.
66
- def self.endpoint(client, endpoint, headers = [])
66
+ def self.endpoint(client, endpoint, headers = nil)
67
67
  proxy = self.new(client, endpoint.authority(false), headers)
68
68
 
69
69
  return proxy.endpoint(endpoint.url)
@@ -72,10 +72,10 @@ module Async
72
72
  # @param client [Async::HTTP::Client] the client which will be used as a proxy server.
73
73
  # @param address [String] the address to connect to.
74
74
  # @param headers [Array] an optional list of headers to use when establishing the connection.
75
- def initialize(client, address, headers = [])
75
+ def initialize(client, address, headers = nil)
76
76
  @client = client
77
77
  @address = address
78
- @headers = headers
78
+ @headers = ::Protocol::HTTP::Headers[headers].freeze
79
79
  end
80
80
 
81
81
  attr :client
@@ -22,6 +22,6 @@
22
22
 
23
23
  module Async
24
24
  module HTTP
25
- VERSION = "0.50.13"
25
+ VERSION = "0.51.0"
26
26
  end
27
27
  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.50.13
4
+ version: 0.51.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: 2020-04-07 00:00:00.000000000 Z
11
+ date: 2020-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -58,28 +58,28 @@ dependencies:
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.17.0
61
+ version: 0.18.0
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.17.0
68
+ version: 0.18.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: protocol-http1
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.11.0
75
+ version: 0.12.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.11.0
82
+ version: 0.12.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: protocol-http2
85
85
  requirement: !ruby/object:Gem::Requirement