falcon 0.39.2 → 0.41.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: 92f616fdd459f200e56043b17ca65c7ca089755c36b7f61804329690dd50e97f
4
- data.tar.gz: c32174f12294a5b8d955eb380d7ec4a9dc158728f9ab68f5fff002ddf7494086
3
+ metadata.gz: 9ea41a48b0da7b6ba65df7bd8f3c63c06a8deb498119079f8ca03367bc78cfa5
4
+ data.tar.gz: 79e5693fc78e56b829d88b6addffe4d255fa09629cf201356192eb70563e1036
5
5
  SHA512:
6
- metadata.gz: 4d836b07e2b53f7dd2c7f907c84ecbf8b9854cd16520d32248bfdcf8edc7db3d59c284b52b6044f43b46a92d9308096663b71cd3b86a18c63980aff49b3aadd0
7
- data.tar.gz: ad997d393ade337767b0a107e70da56bfd11276e061cb66413d50992bbdb39830758487cc8d0853bd598554f9df0e93bad9e5bbc58be0215ddfc2927c03ec45a
6
+ metadata.gz: d97ae8f6aebe79fa10c410ca4ba038a731b6ace354b2bcc2bd8ec0d5a958fefed7c89d5bd47141fbb0e2f8fbbac869476e6bc1c552a8034ddc9b5835e9278d4c
7
+ data.tar.gz: '080b0ac4a57575b3177024248fa538d7019f3812eed267a3fd5ca9b7de7cc9388759d55c51a6b0de6b2aa71788b69f2bbc08e08488415f3cfc7e54d3707f8a14'
checksums.yaml.gz.sig ADDED
Binary file
@@ -35,19 +35,37 @@ module Falcon
35
35
  # @parameter status [Integer] The response status.
36
36
  # @parameter headers [Protocol::HTTP::Headers] The response headers.
37
37
  # @parameter body [Object] The `rack` response body.
38
- def self.wrap(status, headers, body)
38
+ def self.wrap(status, headers, body, request = nil)
39
39
  # In no circumstance do we want this header propagating out:
40
40
  if length = headers.delete(CONTENT_LENGTH)
41
41
  # We don't really trust the user to provide the right length to the transport.
42
42
  length = Integer(length)
43
43
  end
44
44
 
45
+ # If we have an Async::HTTP body, we return it directly:
45
46
  if body.is_a?(::Protocol::HTTP::Body::Readable)
47
+ # warn "Returning #{body.class} as body is falcon-specific and may be removed in the future!"
46
48
  return body
47
- elsif status == 200 and body.respond_to?(:to_path)
48
- # Don't mangle partial responsese (206)
49
- return ::Protocol::HTTP::Body::File.open(body.to_path)
50
- elsif body.is_a?(Array)
49
+ end
50
+
51
+ # Otherwise, we have a more typical response body:
52
+ if status == 200 and body.respond_to?(:to_path)
53
+ begin
54
+ # Don't mangle partial responses (206)
55
+ return ::Protocol::HTTP::Body::File.open(body.to_path).tap do
56
+ body.close if body.respond_to?(:close) # Close the original body.
57
+ end
58
+ rescue Errno::ENOENT
59
+ # If the file is not available, ignore.
60
+ end
61
+ end
62
+
63
+ # If we have a streaming body, we hijack the connection:
64
+ unless body.respond_to?(:each)
65
+ return Async::HTTP::Body::Hijack.new(body, request&.body)
66
+ end
67
+
68
+ if body.is_a?(Array)
51
69
  length ||= body.sum(&:bytesize)
52
70
  return self.new(body, length)
53
71
  else
@@ -78,7 +96,7 @@ module Falcon
78
96
 
79
97
  # Whether the body can be read immediately.
80
98
  def ready?
81
- true
99
+ body.is_a?(Array) or body.respond_to?(:to_ary)
82
100
  end
83
101
 
84
102
  # Close the response body.
@@ -81,7 +81,7 @@ module Falcon
81
81
  Console.logger.warn("Ignoring protocol-level headers: #{ignored.inspect}")
82
82
  end
83
83
 
84
- body = Output.wrap(status, headers, body)
84
+ body = Output.wrap(status, headers, body, request)
85
85
  end
86
86
 
87
87
  if request&.head?
@@ -20,7 +20,6 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
- require_relative '../extensions/openssl'
24
23
  require_relative '../controller/proxy'
25
24
  require_relative '../tls'
26
25
 
@@ -46,7 +45,7 @@ environment(:tls) do
46
45
  # The list of certificates loaded from that path.
47
46
  # @attribute [Array(OpenSSL::X509::Certificate)]
48
47
  ssl_certificates do
49
- OpenSSL::X509.load_certificates(ssl_certificate_path)
48
+ OpenSSL::X509::Certificate.load_file(ssl_certificate_path)
50
49
  end
51
50
 
52
51
  # The main certificate.
@@ -87,9 +87,9 @@ module Falcon
87
87
 
88
88
  begin
89
89
  service.stop
90
- rescue
90
+ rescue => error
91
91
  failed = true
92
- Console.logger.error(self, $!)
92
+ Console.logger.error(self, error)
93
93
  end
94
94
  end
95
95
 
data/lib/falcon/tls.rb CHANGED
@@ -20,8 +20,6 @@
20
20
  # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
21
  # THE SOFTWARE.
22
22
 
23
- require_relative 'extensions/openssl'
24
-
25
23
  module Falcon
26
24
  module TLS
27
25
  # The list of supported ciphers.
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Falcon
24
- VERSION = "0.39.2"
24
+ VERSION = "0.41.0"
25
25
  end
@@ -4,16 +4,16 @@ require 'rack/handler'
4
4
 
5
5
  require_relative '../../falcon'
6
6
 
7
- require 'async/reactor'
7
+ require 'kernel/sync'
8
8
  require 'async/io/host_endpoint'
9
+ require 'async/io/notification'
9
10
 
10
11
  module Rack
11
12
  module Handler
12
13
  # The falcon adaptor for the `rackup` executable.
13
- module Falcon
14
+ class Falcon
14
15
  # The default scheme.
15
16
  SCHEME = "http"
16
- NAME = :falcon
17
17
 
18
18
  # Generate an endpoint for the given `rackup` options.
19
19
  # @returns [Async::IO::Endpoint]
@@ -27,20 +27,55 @@ module Rack
27
27
  # Run the specified app using the given options:
28
28
  # @parameter app [Object] The rack middleware.
29
29
  def self.run(app, **options)
30
- endpoint = endpoint_for(**options)
31
-
32
30
  app = ::Falcon::Adapters::Rack.new(app)
33
31
  app = ::Falcon::Adapters::Rewindable.new(app)
34
-
35
- server = ::Falcon::Server.new(app, endpoint, protocol: Async::HTTP::Protocol::HTTP1, scheme: SCHEME)
36
- yield server if block_given?
37
-
38
- Async::Reactor.run do
39
- server.run
32
+
33
+ Sync do |task|
34
+ endpoint = endpoint_for(**options)
35
+ server = ::Falcon::Server.new(app, endpoint, protocol: Async::HTTP::Protocol::HTTP1, scheme: SCHEME)
36
+
37
+ server_task = task.async do
38
+ server.run.each(&:wait)
39
+ end
40
+
41
+ wrapper = self.new(server, task)
42
+
43
+ yield wrapper if block_given?
44
+
45
+ server_task.wait
46
+ ensure
47
+ server_task.stop
48
+ wrapper.close
49
+ end
50
+ end
51
+
52
+ def initialize(server, task)
53
+ @server = server
54
+ @task = task
55
+
56
+ @notification = Async::IO::Notification.new
57
+
58
+ @waiter = @task.async(transient: true) do
59
+ @notification.wait
60
+
61
+ @task&.stop
62
+ @task = nil
40
63
  end
41
64
  end
65
+
66
+ def stop
67
+ @notification&.signal
68
+ end
69
+
70
+ def close
71
+ @notification&.close
72
+ @notification = nil
73
+
74
+ @waiter&.stop
75
+ @waiter = nil
76
+ end
42
77
  end
43
-
44
- register Falcon::NAME, Falcon
78
+
79
+ register :falcon, Falcon
45
80
  end
46
81
  end
data.tar.gz.sig ADDED
Binary file
metadata CHANGED
@@ -1,14 +1,60 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falcon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.39.2
4
+ version: 0.41.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ - Janko Marohnić
9
+ - dependabot[bot]
10
+ - Bryan Powell
11
+ - Sho Ito
12
+ - claudiu
13
+ - takkanm
14
+ - tamkylet
15
+ - Colby Swandale
16
+ - Daniel Evans
17
+ - Kent Gruber
18
+ - Michael Adams
19
+ - Mikel Kew
20
+ - Olle Jonsson
21
+ - Sh Lin
22
+ - Tad Thorley
23
+ - Tasos Latsas
24
+ - deepj
8
25
  autorequire:
9
26
  bindir: bin
10
- cert_chain: []
11
- date: 2021-07-16 00:00:00.000000000 Z
27
+ cert_chain:
28
+ - |
29
+ -----BEGIN CERTIFICATE-----
30
+ MIIE2DCCA0CgAwIBAgIBATANBgkqhkiG9w0BAQsFADBhMRgwFgYDVQQDDA9zYW11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zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
47
+ aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEBCwUAA4IBgQB5sxkE
48
+ cBsSYwK6fYpM+hA5B5yZY2+L0Z+27jF1pWGgbhPH8/FjjBLVn+VFok3CDpRqwXCl
49
+ xCO40JEkKdznNy2avOMra6PFiQyOE74kCtv7P+Fdc+FhgqI5lMon6tt9rNeXmnW/
50
+ c1NaMRdxy999hmRGzUSFjozcCwxpy/LwabxtdXwXgSay4mQ32EDjqR1TixS1+smp
51
+ 8C/NCWgpIfzpHGJsjvmH2wAfKtTTqB9CVKLCWEnCHyCaRVuKkrKjqhYCdmMBqCws
52
+ JkxfQWC+jBVeG9ZtPhQgZpfhvh+6hMhraUYRQ6XGyvBqEUe+yo6DKIT3MtGE2+CP
53
+ eX9i9ZWBydWb8/rvmwmX2kkcBbX0hZS1rcR593hGc61JR6lvkGYQ2MYskBveyaxt
54
+ Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
55
+ voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
56
+ -----END CERTIFICATE-----
57
+ date: 2022-08-07 00:00:00.000000000 Z
12
58
  dependencies:
13
59
  - !ruby/object:Gem::Dependency
14
60
  name: async
@@ -44,14 +90,14 @@ dependencies:
44
90
  requirements:
45
91
  - - "~>"
46
92
  - !ruby/object:Gem::Version
47
- version: 0.56.0
93
+ version: 0.57.0
48
94
  type: :runtime
49
95
  prerelease: false
50
96
  version_requirements: !ruby/object:Gem::Requirement
51
97
  requirements:
52
98
  - - "~>"
53
99
  - !ruby/object:Gem::Version
54
- version: 0.56.0
100
+ version: 0.57.0
55
101
  - !ruby/object:Gem::Dependency
56
102
  name: async-http-cache
57
103
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +168,20 @@ dependencies:
122
168
  - - "~>"
123
169
  - !ruby/object:Gem::Version
124
170
  version: '1.1'
171
+ - !ruby/object:Gem::Dependency
172
+ name: openssl
173
+ requirement: !ruby/object:Gem::Requirement
174
+ requirements:
175
+ - - "~>"
176
+ - !ruby/object:Gem::Version
177
+ version: '3.0'
178
+ type: :runtime
179
+ prerelease: false
180
+ version_requirements: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - "~>"
183
+ - !ruby/object:Gem::Version
184
+ version: '3.0'
125
185
  - !ruby/object:Gem::Dependency
126
186
  name: process-metrics
127
187
  requirement: !ruby/object:Gem::Requirement
@@ -198,14 +258,14 @@ dependencies:
198
258
  requirements:
199
259
  - - "~>"
200
260
  - !ruby/object:Gem::Version
201
- version: 0.14.0
261
+ version: 0.19.2
202
262
  type: :development
203
263
  prerelease: false
204
264
  version_requirements: !ruby/object:Gem::Requirement
205
265
  requirements:
206
266
  - - "~>"
207
267
  - !ruby/object:Gem::Version
208
- version: 0.14.0
268
+ version: 0.19.2
209
269
  - !ruby/object:Gem::Dependency
210
270
  name: bake
211
271
  requirement: !ruby/object:Gem::Requirement
@@ -289,7 +349,6 @@ files:
289
349
  - lib/falcon/environments/self_signed_tls.rb
290
350
  - lib/falcon/environments/supervisor.rb
291
351
  - lib/falcon/environments/tls.rb
292
- - lib/falcon/extensions/openssl.rb
293
352
  - lib/falcon/middleware/proxy.rb
294
353
  - lib/falcon/middleware/redirect.rb
295
354
  - lib/falcon/middleware/verbose.rb
@@ -322,7 +381,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
381
  - !ruby/object:Gem::Version
323
382
  version: '0'
324
383
  requirements: []
325
- rubygems_version: 3.2.22
384
+ rubygems_version: 3.3.7
326
385
  signing_key:
327
386
  specification_version: 4
328
387
  summary: A fast, asynchronous, rack-compatible web server.
metadata.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ ��]���.���5��w�٤����_��v����) �����y��Ĺm,�
2
+ ��9$8�InSnv:�>���Uҟkx�:4�pVaJ89���E�bKt�����o!�m���ƛ�>;p�dKM~`���v\>=���;�$u�B�:��^ ��m|-.9+M�`��G����"#ͻa:W�F ��s�m� � �m���a4��[��;�;����&$O�ٺ48��<tR4ȑ�wfn]�����-|F�T���W���C+ t���2�N~��G� {gW�c-A�L%Uט����.h�z����s{��w��z�W��������Hn'����B���YЉ��MM���[4>Q4��3 ���&G?��E�H��� ç�t􃥩(�
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2018, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
- #
5
- # Permission is hereby granted, free of charge, to any person obtaining a copy
6
- # of this software and associated documentation files (the "Software"), to deal
7
- # in the Software without restriction, including without limitation the rights
8
- # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- # copies of the Software, and to permit persons to whom the Software is
10
- # furnished to do so, subject to the following conditions:
11
- #
12
- # The above copyright notice and this permission notice shall be included in
13
- # all copies or substantial portions of the Software.
14
- #
15
- # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- # THE SOFTWARE.
22
-
23
- require 'openssl/x509'
24
-
25
- module OpenSSL::X509
26
- CERTIFICATE_PATTERN = /-----BEGIN CERTIFICATE-----.*?-----END CERTIFICATE-----/m
27
-
28
- # An extension to load an array of certificates from a file at the given path.
29
- def self.load_certificates(path)
30
- File.read(path).scan(CERTIFICATE_PATTERN).collect do |text|
31
- Certificate.new(text)
32
- end
33
- end
34
- end