falcon 0.23.0 → 0.24.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: e0e70db57599ceb24ef8ba959ccf4e9d7c43c774e5bafec0e08956d98362dc31
4
- data.tar.gz: 742ea2d7f69b142c9e05cc4f9f2dca3d372c3b41f0b3e4d0733923b7e50853e8
3
+ metadata.gz: 504e6916fab8a0e117d92f5278a9b5fd9c882da9e390b32884db933af61f311d
4
+ data.tar.gz: 1706310fa9fd8d820b005fad2fec24426828d92fdaeee5252e1f6e6fa0b6a50f
5
5
  SHA512:
6
- metadata.gz: f140e5df2529863dc8ad27cdd16cc6fa7d24e13db1d95f545e09b4e49255762b44cf5f497402be4461570277d6a7d76afda7d9291a397aeae99177743b74f8e7
7
- data.tar.gz: e951345f66cfaad7e3e3d82e818cc7079f4156b60a03f1e1ee717ebffab8ac8c2585c317061836fd90346cef0d5103510e5a091209750446a6d061c5468fc799
6
+ metadata.gz: 5aedf3ada69a3df6e5c4be27617e9e4de163272f992ab1915568781e808991bfa4a0ba5e35051578195975dfc776afe704c5c6d810f0691e0335e5a7600380f5
7
+ data.tar.gz: 816941e7cb925b12aedeb0b8cd171d4df3783eeb6b999bf73734b579fe3ae0545c7d9864ce20f1d28af69772be49ef88d44f3b2449189dfa534c56b16b42335d
data/README.md CHANGED
@@ -101,6 +101,7 @@ module MySite
101
101
  end
102
102
  end
103
103
  ```
104
+
104
105
  ##### Rails 4.x
105
106
 
106
107
  Please ensure you have `config.allow_concurrency = true` in your configuration.
@@ -119,6 +120,10 @@ Falcon supports `rack.hijack` for HTTP/1.x connections. You can thus use [async-
119
120
 
120
121
  The `rack.hijack` functionality is compatible with ActionCable. If you use the `async` adapter, you should run falcon in threaded mode, or in forked mode with `--concurrency 1`. Otherwise, your messaging system will be distributed over several processes with no IPC mechanism. You might like to try out [async-redis](https://github.com/socketry/async-redis) as an asynchronous message bus.
121
122
 
123
+ ### Early Hints
124
+
125
+ Falcon supports the `rack.early_hints` API when running over HTTP/2.
126
+
122
127
  ### Integration with Guard
123
128
 
124
129
  Falcon can restart very quickly and is ideal for use with guard. See [guard-falcon] for more details.
@@ -218,7 +223,7 @@ The standard price for business support is $120.00 USD / year / production insta
218
223
 
219
224
  Each paying business customer is entitled to one vote to prioritize the below work.
220
225
 
221
- - Add support for push promises and stream prioritization in [async-http].
226
+ - Add support stream prioritization in [async-http].
222
227
  - Add support for rolling restarts in [async-container].
223
228
  - Add support for hybrid process/thread model in [async-container].
224
229
  - Asynchronous Postgres and MySQL database adapters for ActiveRecord in [async-postgres] and [async-mysql].
@@ -0,0 +1,19 @@
1
+
2
+ class EarlyHints
3
+ def initialize(app)
4
+ @app = app
5
+ end
6
+
7
+ def call(env)
8
+ if env['PATH_INFO'] == "/index.html" and early_hints = env['rack.early_hints']
9
+ early_hints.push("/style.css")
10
+ early_hints.push("/script.js")
11
+ end
12
+
13
+ @app.call(env)
14
+ end
15
+ end
16
+
17
+ use EarlyHints
18
+ use Rack::Static, :urls => [""], :root => __dir__, :index => 'index.html'
19
+ run lambda{|env| [404, [], ["Not Found"]]}
@@ -0,0 +1,14 @@
1
+ <!doctype HTML>
2
+ <html>
3
+ <head>
4
+ <title>Hello World</title>
5
+
6
+ <link rel="stylesheet" href="/style.css" />
7
+ <script type="text/javascript" src="script.js"></script>
8
+ </head>
9
+ <body>
10
+ <h1>Early Hints</h1>
11
+
12
+ <p>Check the developer tools to see if early hints worked!</p>
13
+ </body>
14
+ </html>
File without changes
@@ -0,0 +1,4 @@
1
+
2
+ html {
3
+ font-family: Helvetica;
4
+ }
@@ -22,37 +22,25 @@ require 'async/http/middleware'
22
22
 
23
23
  module Falcon
24
24
  module Adapters
25
- # Interprets link headers to implement server push.
26
- # https://tools.ietf.org/html/rfc8288
27
- class Push < Async::HTTP::Middleware
25
+ class EarlyHints
28
26
  PRELOAD = /<(?<path>.*?)>;.*?rel=preload/
29
27
 
30
- def self.early_hints(headers)
28
+ def initialize(request)
29
+ @request = request
30
+ end
31
+
32
+ def push(path, preload: true, **options)
33
+ @request.push(path)
34
+ end
35
+
36
+ def call(headers)
31
37
  headers.each do |key, value|
32
38
  if key.casecmp("link").zero? and match = PRELOAD.match(value)
33
- yield match[:path]
39
+ @request.push(match[:path])
34
40
  else
35
- Async.logger.warn(request) {"Unsure how to handle early hints header: #{key}"}
36
- end
37
- end
38
- end
39
-
40
- def call(request)
41
- response = super
42
-
43
- Async.logger.debug(self) {response}
44
-
45
- if request.push?
46
- Async.logger.debug(self) {response.headers['link']}
47
-
48
- response.headers['link']&.each do |link|
49
- if match = link.match(PRELOAD)
50
- request.push(match[:path])
51
- end
41
+ Async.logger.warn(@request) {"Unsure how to handle early hints header: #{key}"}
52
42
  end
53
43
  end
54
-
55
- return response
56
44
  end
57
45
  end
58
46
  end
@@ -22,6 +22,7 @@ require 'rack'
22
22
 
23
23
  require_relative 'input'
24
24
  require_relative 'response'
25
+ require_relative 'early_hints'
25
26
 
26
27
  require 'async/logger'
27
28
 
@@ -161,11 +162,7 @@ module Falcon
161
162
  self.unwrap_request(request, env)
162
163
 
163
164
  if request.push?
164
- env[RACK_EARLY_HINTS] = lambda do |headers|
165
- Falcon::Adapters::Push.early_hints(headers) do |path|
166
- request.push(path)
167
- end
168
- end
165
+ env[RACK_EARLY_HINTS] = EarlyHints.new(request)
169
166
  end
170
167
 
171
168
  if request.hijack?
data/lib/falcon/server.rb CHANGED
@@ -26,7 +26,6 @@ require 'async/http/content_encoding'
26
26
  require_relative 'verbose'
27
27
  require_relative 'adapters/rewindable'
28
28
  require_relative 'adapters/rack'
29
- require_relative 'adapters/push'
30
29
 
31
30
  module Falcon
32
31
  class Server < Async::HTTP::Server
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Falcon
22
- VERSION = "0.23.0"
22
+ VERSION = "0.24.0"
23
23
  end
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.23.0
4
+ version: 0.24.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: 2019-02-09 00:00:00.000000000 Z
11
+ date: 2019-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-protocol
@@ -239,6 +239,10 @@ files:
239
239
  - examples/beer/config.ru
240
240
  - examples/benchmark/config.ru
241
241
  - examples/hello/config.ru
242
+ - examples/push/config.ru
243
+ - examples/push/index.html
244
+ - examples/push/script.js
245
+ - examples/push/style.css
242
246
  - examples/redis/Gemfile
243
247
  - examples/redis/config.ru
244
248
  - examples/sinatra/Gemfile
@@ -248,9 +252,9 @@ files:
248
252
  - gems/rack1.gemfile
249
253
  - gems/rack3.gemfile
250
254
  - lib/falcon.rb
255
+ - lib/falcon/adapters/early_hints.rb
251
256
  - lib/falcon/adapters/input.rb
252
257
  - lib/falcon/adapters/output.rb
253
- - lib/falcon/adapters/push.rb
254
258
  - lib/falcon/adapters/rack.rb
255
259
  - lib/falcon/adapters/response.rb
256
260
  - lib/falcon/adapters/rewindable.rb