async-http 0.66.3 → 0.67.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: 6333433caa77214ab225abff1e948dd2b48dc3230d2b0fc2bdb14e239152f7d5
4
- data.tar.gz: 89bc214d31e3270eb507913b3214b7aed79a98972aae22a28bfd77b22e1a3353
3
+ metadata.gz: 86fa32fbabfbf7e98484c197db5062ecbdd5fc7f2e360fbdb778781ab64c2d18
4
+ data.tar.gz: 7212090a7708522c11dfa457e85714eb698493fc3382372f48b22cde748f1350
5
5
  SHA512:
6
- metadata.gz: f20b9ac9ce576e06cb634fd5a72874d6fe471859bbf9e3d6b4e0bd90497d6d0a6e892511b6cfe1c4736ef292b408d833ed3bb3f7ad6b331e16db2ffaa696aae3
7
- data.tar.gz: 2809e2f25f6430dce4271ac3a3891197efca709fccbe4506fb3b5a089330b5479ac2d010289b33e1270673b1c8aff427ef369c7c64eb2c5c0c8b7bd8a5f491a0
6
+ metadata.gz: 9aa817a134d29db249a8c503ac9fc69ffb8ed500e1518249f09f1fb4fe9d123e3682ec032d7e87368007ebcce56cf42861bd56be2e418d23d86565672d7a5017
7
+ data.tar.gz: 71e89c429dbdc4731c6e4335d14a235946fd1fecbbdc2deeed0ec0ef332f7952a5d175de63009a91b4cc35544b3ee8b3e915c6586df5fbea9a78253a4c5f5e19
checksums.yaml.gz.sig CHANGED
Binary file
@@ -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.3"
8
+ VERSION = "0.67.1"
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.3
4
+ version: 0.67.1
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-05-10 00:00:00.000000000 Z
60
+ date: 2024-06-10 00:00:00.000000000 Z
61
61
  dependencies:
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: async
@@ -155,14 +155,14 @@ dependencies:
155
155
  requirements:
156
156
  - - "~>"
157
157
  - !ruby/object:Gem::Version
158
- version: 0.17.0
158
+ version: 0.18.0
159
159
  type: :runtime
160
160
  prerelease: false
161
161
  version_requirements: !ruby/object:Gem::Requirement
162
162
  requirements:
163
163
  - - "~>"
164
164
  - !ruby/object:Gem::Version
165
- version: 0.17.0
165
+ version: 0.18.0
166
166
  - !ruby/object:Gem::Dependency
167
167
  name: traces
168
168
  requirement: !ruby/object:Gem::Requirement
@@ -197,6 +197,7 @@ files:
197
197
  - lib/async/http/internet.rb
198
198
  - lib/async/http/internet/instance.rb
199
199
  - lib/async/http/protocol.rb
200
+ - lib/async/http/protocol/http.rb
200
201
  - lib/async/http/protocol/http1.rb
201
202
  - lib/async/http/protocol/http1/client.rb
202
203
  - lib/async/http/protocol/http1/connection.rb
@@ -246,7 +247,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
246
247
  - !ruby/object:Gem::Version
247
248
  version: '0'
248
249
  requirements: []
249
- rubygems_version: 3.5.3
250
+ rubygems_version: 3.5.9
250
251
  signing_key:
251
252
  specification_version: 4
252
253
  summary: A HTTP client and server library.
metadata.gz.sig CHANGED
Binary file