falcon 0.36.7 → 0.38.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: cf341f482ade4d35f1b63da2c7b937d85f69a07537e5073233f5e2aeb771bcd6
4
- data.tar.gz: ab45bb5d32c5a6afd41d83069da778e085f03b87704f2d67301ceaa251725772
3
+ metadata.gz: c5a4201cd601d651d96edf8c9eee196033ce1e1d31a802d16619a986dd1bd077
4
+ data.tar.gz: 9b1c9d31622951486ea1d1db012074551cb18ed4ff785d8dbb37bfa1b75dc046
5
5
  SHA512:
6
- metadata.gz: 1c8bdfbfc3d7056695eed090fc49bf07e21517a251c5e7185b7450db9bf6648dd8f6d8d5f6b32472feeea0aa6f6cd2d384cac4dc8bfd06b20e924e88ae2a08ca
7
- data.tar.gz: 22b1c2729420fbb1190dde29b0774f39ac86d52e75f2b0a5769c7ebde1ddba1a71dcaaa44bee27b3200ad349a2026641050bfccbcafe6d860d4ea868f7bd862b
6
+ metadata.gz: 9f1cd7757afa92a27b7b9d021e2ff443144afef2c9b0e30bddad548b45e68b4519ab02f2293f6388a00f62af0e8efb865e51f1241b8cee9312f9187406cb86ed
7
+ data.tar.gz: a75c84be6f77e4e79aa6d572d1a95e7c90d310650324f8d60fbca4dcd679138e30e799b538184ff804bfeac6c351478e574f61670d4e1d568801166ce24ac2ea
@@ -24,7 +24,6 @@ require 'rack'
24
24
 
25
25
  require_relative 'input'
26
26
  require_relative 'response'
27
- require_relative 'early_hints'
28
27
 
29
28
  require 'async/logger'
30
29
 
@@ -60,7 +59,10 @@ module Falcon
60
59
  RACK_HIJACK = 'rack.hijack'
61
60
  RACK_IS_HIJACK = 'rack.hijack?'
62
61
  RACK_HIJACK_IO = 'rack.hijack_io'
63
- RACK_EARLY_HINTS = "rack.early_hints"
62
+
63
+ # Raised back up through the middleware when the underlying connection is hijacked.
64
+ class FullHijack < StandardError
65
+ end
64
66
 
65
67
  # Async::HTTP specific metadata:
66
68
 
@@ -184,10 +186,6 @@ module Falcon
184
186
 
185
187
  self.unwrap_request(request, env)
186
188
 
187
- if request.push?
188
- env[RACK_EARLY_HINTS] = EarlyHints.new(request)
189
- end
190
-
191
189
  full_hijack = false
192
190
 
193
191
  if request.hijack?
@@ -208,7 +206,7 @@ module Falcon
208
206
 
209
207
  # If there was a full hijack:
210
208
  if full_hijack
211
- return nil
209
+ raise FullHijack, "The connection was hijacked."
212
210
  else
213
211
  return Response.wrap(status, headers, body, request)
214
212
  end
@@ -92,10 +92,10 @@ module Falcon
92
92
  protocol = meta['rack.protocol']
93
93
 
94
94
  # https://tools.ietf.org/html/rfc7231#section-7.4.2
95
- headers.add('server', "falcon/#{Falcon::VERSION}")
95
+ # headers.add('server', "falcon/#{Falcon::VERSION}")
96
96
 
97
97
  # https://tools.ietf.org/html/rfc7231#section-7.1.1.2
98
- headers.add('date', Time.now.httpdate)
98
+ # headers.add('date', Time.now.httpdate)
99
99
 
100
100
  return self.new(status, headers, body, protocol)
101
101
  end
@@ -71,7 +71,15 @@ module Falcon
71
71
  buffer.puts "- To reload: kill -HUP #{Process.pid}"
72
72
  end
73
73
 
74
- Bundler.require(:preload)
74
+ begin
75
+ Bundler.require(:preload)
76
+ rescue Bundler::GemfileNotFound
77
+ # Ignore.
78
+ end
79
+
80
+ if GC.respond_to?(:compact)
81
+ GC.compact
82
+ end
75
83
 
76
84
  self.controller.run
77
85
  end
@@ -145,7 +145,11 @@ module Falcon
145
145
  load(full_path)
146
146
  end
147
147
 
148
- Bundler.require(:preload)
148
+ begin
149
+ Bundler.require(:preload)
150
+ rescue Bundler::GemfileNotFound
151
+ # Ignore.
152
+ end
149
153
 
150
154
  if GC.respond_to?(:compact)
151
155
  GC.compact
@@ -77,6 +77,8 @@ module Falcon
77
77
  buffer.puts "- To reload all sites: kill -HUP #{Process.pid}"
78
78
  end
79
79
 
80
+ ENV['CONSOLE_LEVEL'] = 'debug'
81
+
80
82
  self.controller.run
81
83
  end
82
84
 
@@ -112,6 +112,10 @@ module Falcon
112
112
  if service.is_a?(Service::Proxy)
113
113
  Async.logger.info(self) {"Proxying #{service.authority} to #{service.endpoint}"}
114
114
  @hosts[service.authority] = service
115
+
116
+ # Pre-cache the ssl contexts:
117
+ # It seems some OpenSSL objects don't like event-driven I/O.
118
+ service.ssl_context
115
119
  end
116
120
  end
117
121
 
@@ -102,7 +102,7 @@ module Falcon
102
102
  end
103
103
  end
104
104
 
105
- server = Falcon::Server.new(app, @bound_endpoint, @endpoint.protocol, @endpoint.scheme)
105
+ server = Falcon::Server.new(app, @bound_endpoint, protocol: @endpoint.protocol, scheme: @endpoint.scheme)
106
106
 
107
107
  server.run
108
108
 
@@ -90,7 +90,7 @@ module Falcon
90
90
  Async(logger: logger) do |task|
91
91
  Async.logger.info(self) {"Starting application server for #{self.root}..."}
92
92
 
93
- server = Server.new(self.middleware, @bound_endpoint, protocol, scheme)
93
+ server = Server.new(self.middleware, @bound_endpoint, protocol: protocol, scheme: scheme)
94
94
 
95
95
  server.run
96
96
 
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Falcon
24
- VERSION = "0.36.7"
24
+ VERSION = "0.38.0"
25
25
  end
@@ -32,7 +32,7 @@ module Rack
32
32
  app = ::Falcon::Adapters::Rack.new(app)
33
33
  app = ::Falcon::Adapters::Rewindable.new(app)
34
34
 
35
- server = ::Falcon::Server.new(app, endpoint, Async::HTTP::Protocol::HTTP1, SCHEME)
35
+ server = ::Falcon::Server.new(app, endpoint, protocol: Async::HTTP::Protocol::HTTP1, scheme: SCHEME)
36
36
  yield server if block_given?
37
37
 
38
38
  Async::Reactor.run do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falcon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.36.7
4
+ version: 0.38.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-11-15 00:00:00.000000000 Z
11
+ date: 2021-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -44,28 +44,28 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.53.0
47
+ version: 0.56.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.53.0
54
+ version: 0.56.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: async-http-cache
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.3.0
61
+ version: 0.4.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.3.0
68
+ version: 0.4.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: async-io
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -260,7 +260,6 @@ files:
260
260
  - bin/falcon
261
261
  - bin/falcon-host
262
262
  - lib/falcon.rb
263
- - lib/falcon/adapters/early_hints.rb
264
263
  - lib/falcon/adapters/input.rb
265
264
  - lib/falcon/adapters/output.rb
266
265
  - lib/falcon/adapters/rack.rb
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # Copyright, 2019, 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 'protocol/http/middleware'
24
-
25
- module Falcon
26
- module Adapters
27
- # Provide an interface for advising the client to preload related resources.
28
- class EarlyHints
29
- PRELOAD = /<(?<path>.*?)>;.*?rel=preload/
30
-
31
- # Initialize the early hints interface.
32
- #
33
- # @parameter request [Protocol::HTTP::Request]
34
- def initialize(request)
35
- @request = request
36
- end
37
-
38
- # Advise the request that the specified path should be preloaded.
39
- # @parameter path [String]
40
- # @parameter preload [Boolean] whether the client should preload the resource.
41
- def push(path, preload: true, **options)
42
- @request.push(path)
43
- end
44
-
45
- # Extract link headers and invoke {push}.
46
- def call(headers)
47
- headers.each do |key, value|
48
- if key.casecmp("link").zero? and match = PRELOAD.match(value)
49
- @request.push(match[:path])
50
- else
51
- Async.logger.warn(@request) {"Unsure how to handle early hints header: #{key}"}
52
- end
53
- end
54
- end
55
- end
56
- end
57
- end