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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/falcon/adapters/output.rb +24 -6
- data/lib/falcon/adapters/response.rb +1 -1
- data/lib/falcon/environments/tls.rb +1 -2
- data/lib/falcon/services.rb +2 -2
- data/lib/falcon/tls.rb +0 -2
- data/lib/falcon/version.rb +1 -1
- data/lib/rack/handler/falcon.rb +48 -13
- data.tar.gz.sig +0 -0
- metadata +68 -9
- metadata.gz.sig +2 -0
- data/lib/falcon/extensions/openssl.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ea41a48b0da7b6ba65df7bd8f3c63c06a8deb498119079f8ca03367bc78cfa5
|
4
|
+
data.tar.gz: 79e5693fc78e56b829d88b6addffe4d255fa09629cf201356192eb70563e1036
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
99
|
+
body.is_a?(Array) or body.respond_to?(:to_ary)
|
82
100
|
end
|
83
101
|
|
84
102
|
# Close the response body.
|
@@ -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.
|
48
|
+
OpenSSL::X509::Certificate.load_file(ssl_certificate_path)
|
50
49
|
end
|
51
50
|
|
52
51
|
# The main certificate.
|
data/lib/falcon/services.rb
CHANGED
data/lib/falcon/tls.rb
CHANGED
data/lib/falcon/version.rb
CHANGED
data/lib/rack/handler/falcon.rb
CHANGED
@@ -4,16 +4,16 @@ require 'rack/handler'
|
|
4
4
|
|
5
5
|
require_relative '../../falcon'
|
6
6
|
|
7
|
-
require '
|
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
|
-
|
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
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
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.
|
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
|
-
|
27
|
+
cert_chain:
|
28
|
+
- |
|
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3XAgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0O
|
45
|
+
BBYEFO9t7XWuFf2SKLmuijgqR4sGDlRsMC4GA1UdEQQnMCWBI3NhbXVlbC53aWxs
|
46
|
+
aWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWBI3NhbXVlbC53aWxs
|
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.
|
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.
|
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.
|
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.
|
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.
|
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
|