async-http 0.66.2 → 0.67.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: 426d98af60ca71ce586cf31e6d29c186e5e9618a514ded1558e408178b1595b8
4
- data.tar.gz: de7562bb9d073c686f5f7fcf3d067aa5a78d866644d9fbc6892d42acdd3ed1e3
3
+ metadata.gz: 4d9e1951137e7368743ddac827130a025c96c2671dddca5db49efb19059b3fa9
4
+ data.tar.gz: fbb66667dc3b3af39b88772c54ddbbbe6db1f571bca5b79b10bda1ad8fc147cf
5
5
  SHA512:
6
- metadata.gz: 80066306c74ed642e63b5c904bfea116fdbe435f71b180e7c0d9421eb0402110c31f2a9c32e1fab099ffe64282314afaec2917f7c6ebf49d7ee3d676361d0e62
7
- data.tar.gz: edcc44c5dfadc2f08d84fff4b142d75cbbca1599bf21af9e92a75353a9c73fd6cd5986dbdb6fb928ca5e145a89e278ba38a7231e0559c11e6f1c2dfe49e590fc
6
+ metadata.gz: 975fbddeead95f0f551429fb60a82cd967bf65f96bc2bb03338cf574141adb7ae98299619ee90fb23adbc47593df1e212bc646cec1bdb591e70d51a9e0ec6053
7
+ data.tar.gz: 8febecdc099a30aa99f9d9541f570687ee751fe051fa2c2c46e8cdbabe362877a0d8006d10eabae29a61eb5fcbad8c26248de00af752746d9fa17945e000e2e2
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- ilh!Y
2
- �[��HR�*5�8�UV(�cL�+���w �j�P��7�w����d�`Ǧqnj���O�F7e�5�j����U!JULf���
1
+ �u���D�������<���%�����!pV�.��Wz(}na�3q��U)+b@���]�p�v����V/��q*�f�F:,�'�q��aQ}�{}Te���_Ja������&��@��c������f�M�`s��V��˳������D2��_�Y%i6B�9~�"��c��΍I��H
2
+ ����}3��M�b�����D+��T8��}h�7��W�k1k�B)�ٕ���vs&$���ۂ��I����D�H,��@������U� w�ȕw7�sǓ��ף���dD��$U?�ȕA��׼�<�\
@@ -8,7 +8,7 @@ require 'io/endpoint'
8
8
  require 'io/endpoint/host_endpoint'
9
9
  require 'io/endpoint/ssl_endpoint'
10
10
 
11
- require_relative 'protocol/http1'
11
+ require_relative 'protocol/http'
12
12
  require_relative 'protocol/https'
13
13
 
14
14
  module Async
@@ -84,7 +84,7 @@ module Async
84
84
  if secure?
85
85
  Protocol::HTTPS
86
86
  else
87
- Protocol::HTTP1
87
+ Protocol::HTTP
88
88
  end
89
89
  end
90
90
  end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Thomas Morgan.
5
+
6
+ require_relative 'http1'
7
+ require_relative 'http2'
8
+
9
+ module Async
10
+ module HTTP
11
+ module Protocol
12
+ # HTTP is an http:// server that auto-selects HTTP/1.1 or HTTP/2 by detecting the HTTP/2
13
+ # connection preface.
14
+ module HTTP
15
+ HTTP2_PREFACE = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n"
16
+ HTTP2_PREFACE_SIZE = HTTP2_PREFACE.bytesize
17
+
18
+ def self.protocol_for(stream)
19
+ # Detect HTTP/2 connection preface
20
+ # https://www.rfc-editor.org/rfc/rfc9113.html#section-3.4
21
+ preface = stream.peek do |read_buffer|
22
+ if read_buffer.bytesize >= HTTP2_PREFACE_SIZE
23
+ break read_buffer[0, HTTP2_PREFACE_SIZE]
24
+ elsif read_buffer.bytesize > 0
25
+ # If partial read_buffer already doesn't match, no need to wait for more bytes.
26
+ break read_buffer unless HTTP2_PREFACE[read_buffer]
27
+ end
28
+ end
29
+
30
+ if preface == HTTP2_PREFACE
31
+ HTTP2
32
+ else
33
+ HTTP1
34
+ end
35
+ end
36
+
37
+ # Only inbound connections can detect HTTP1 vs HTTP2 for http://.
38
+ # Outbound connections default to HTTP1.
39
+ def self.client(peer, **options)
40
+ HTTP1.client(peer, **options)
41
+ end
42
+
43
+ def self.server(peer, **options)
44
+ stream = ::IO::Stream(peer)
45
+
46
+ return protocol_for(stream).server(stream, **options)
47
+ end
48
+
49
+ def self.names
50
+ ["h2", "http/1.1", "http/1.0"]
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -2,11 +2,12 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2017-2024, by Samuel Williams.
5
+ # Copyright, 2023, by Thomas Morgan.
5
6
 
6
7
  require_relative 'http1/client'
7
8
  require_relative 'http1/server'
8
9
 
9
- require 'io/stream/buffered'
10
+ require 'io/stream'
10
11
 
11
12
  module Async
12
13
  module HTTP
@@ -23,13 +24,13 @@ module Async
23
24
  end
24
25
 
25
26
  def self.client(peer)
26
- stream = ::IO::Stream::Buffered.wrap(peer)
27
+ stream = ::IO::Stream(peer)
27
28
 
28
29
  return HTTP1::Client.new(stream, VERSION)
29
30
  end
30
31
 
31
32
  def self.server(peer)
32
- stream = ::IO::Stream::Buffered.wrap(peer)
33
+ stream = ::IO::Stream(peer)
33
34
 
34
35
  return HTTP1::Server.new(stream, VERSION)
35
36
  end
@@ -2,6 +2,7 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2017-2024, by Samuel Williams.
5
+ # Copyright, 2023, by Thomas Morgan.
5
6
 
6
7
  require_relative 'http1'
7
8
 
@@ -20,13 +21,13 @@ module Async
20
21
  end
21
22
 
22
23
  def self.client(peer)
23
- stream = ::IO::Stream::Buffered.wrap(peer)
24
+ stream = ::IO::Stream(peer)
24
25
 
25
26
  return HTTP1::Client.new(stream, VERSION)
26
27
  end
27
28
 
28
29
  def self.server(peer)
29
- stream = ::IO::Stream::Buffered.wrap(peer)
30
+ stream = ::IO::Stream(peer)
30
31
 
31
32
  return HTTP1::Server.new(stream, VERSION)
32
33
  end
@@ -3,6 +3,7 @@
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2017-2024, by Samuel Williams.
5
5
  # Copyright, 2018, by Janko Marohnić.
6
+ # Copyright, 2023, by Thomas Morgan.
6
7
 
7
8
  require_relative 'http1'
8
9
 
@@ -21,13 +22,13 @@ module Async
21
22
  end
22
23
 
23
24
  def self.client(peer)
24
- stream = ::IO::Stream::Buffered.wrap(peer)
25
+ stream = ::IO::Stream(peer)
25
26
 
26
27
  return HTTP1::Client.new(stream, VERSION)
27
28
  end
28
29
 
29
30
  def self.server(peer)
30
- stream = ::IO::Stream::Buffered.wrap(peer)
31
+ stream = ::IO::Stream(peer)
31
32
 
32
33
  return HTTP1::Server.new(stream, VERSION)
33
34
  end
@@ -2,11 +2,12 @@
2
2
 
3
3
  # Released under the MIT License.
4
4
  # Copyright, 2018-2024, by Samuel Williams.
5
+ # Copyright, 2023, by Thomas Morgan.
5
6
 
6
7
  require_relative 'http2/client'
7
8
  require_relative 'http2/server'
8
9
 
9
- require 'io/stream/buffered'
10
+ require 'io/stream'
10
11
 
11
12
  module Async
12
13
  module HTTP
@@ -37,7 +38,7 @@ module Async
37
38
  }
38
39
 
39
40
  def self.client(peer, settings = CLIENT_SETTINGS)
40
- stream = ::IO::Stream::Buffered.wrap(peer)
41
+ stream = ::IO::Stream(peer)
41
42
  client = Client.new(stream)
42
43
 
43
44
  client.send_connection_preface(settings)
@@ -47,7 +48,7 @@ module Async
47
48
  end
48
49
 
49
50
  def self.server(peer, settings = SERVER_SETTINGS)
50
- stream = ::IO::Stream::Buffered.wrap(peer)
51
+ stream = ::IO::Stream(peer)
51
52
  server = Server.new(stream)
52
53
 
53
54
  server.read_connection_preface(settings)
@@ -5,6 +5,6 @@
5
5
 
6
6
  module Async
7
7
  module HTTP
8
- VERSION = "0.66.2"
8
+ VERSION = "0.67.0"
9
9
  end
10
10
  end
data.tar.gz.sig CHANGED
Binary file
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.66.2
4
+ version: 0.67.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
@@ -57,7 +57,7 @@ cert_chain:
57
57
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
58
58
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
59
59
  -----END CERTIFICATE-----
60
- date: 2024-04-30 00:00:00.000000000 Z
60
+ date: 2024-06-09 00:00:00.000000000 Z
61
61
  dependencies:
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: async
@@ -94,6 +94,9 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.10'
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: 0.10.3
97
100
  type: :runtime
98
101
  prerelease: false
99
102
  version_requirements: !ruby/object:Gem::Requirement
@@ -101,6 +104,9 @@ dependencies:
101
104
  - - "~>"
102
105
  - !ruby/object:Gem::Version
103
106
  version: '0.10'
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 0.10.3
104
110
  - !ruby/object:Gem::Dependency
105
111
  name: io-stream
106
112
  requirement: !ruby/object:Gem::Requirement
@@ -191,6 +197,7 @@ files:
191
197
  - lib/async/http/internet.rb
192
198
  - lib/async/http/internet/instance.rb
193
199
  - lib/async/http/protocol.rb
200
+ - lib/async/http/protocol/http.rb
194
201
  - lib/async/http/protocol/http1.rb
195
202
  - lib/async/http/protocol/http1/client.rb
196
203
  - lib/async/http/protocol/http1/connection.rb
@@ -240,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
247
  - !ruby/object:Gem::Version
241
248
  version: '0'
242
249
  requirements: []
243
- rubygems_version: 3.5.3
250
+ rubygems_version: 3.5.9
244
251
  signing_key:
245
252
  specification_version: 4
246
253
  summary: A HTTP client and server library.
metadata.gz.sig CHANGED
Binary file