falcon 0.35.6 → 0.36.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: d7d2d4155e79287bfe7dd04ae2c5cc534be8133858c69c1c053ce26b04f08d43
4
- data.tar.gz: fa93053422138e450a6f2ba8f1fbb68c62c50286d1380e727a56f9c8529a575a
3
+ metadata.gz: 28aa82ead35cc63c3a409d97839eadfc328f9464dfbb5c78481dabe35822b637
4
+ data.tar.gz: dc2ea1d97d323132509a70d7b2a86910c57aa8f728faa73d8d4a624bfa69ee2b
5
5
  SHA512:
6
- metadata.gz: eb2d35183a7dcb578cb0273a8d68b559837f9b02e5ed8202ff861a05d7af5c16b8c82a2fdf2238ca1a87a30954e515d788d53543b927038e3eb25978e802d806
7
- data.tar.gz: 5cefb2f9b4211e7082b9ee26e869fbf160c8ff7955f2886649904d9842e1f194bb13c1fc97cf2b1773387f40dc3bf5970af4d16f91df47cd272260e0790d3361
6
+ metadata.gz: 48b9092e315016c36756cb1d5863fd7ee938873770fd2a61e8566900b7e0ad8a7c6e17c7853d56b372745535ba63dbf116ca5ca773ca73106c3ee92b99cacd99
7
+ data.tar.gz: e9c3f3541b89fe30b724e17f3fe953713252bfd945c69676c99e35e74a4ce2f52db8c1a098b2732db80e201f58225d647a935bb3ea996eaca7cc3dc7b666afef
@@ -0,0 +1,45 @@
1
+ name: Development
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ test:
7
+ strategy:
8
+ matrix:
9
+ os:
10
+ - ubuntu
11
+ - macos
12
+
13
+ ruby:
14
+ - 2.5
15
+ - 2.6
16
+ - 2.7
17
+
18
+ include:
19
+ - os: 'ubuntu'
20
+ ruby: 2.7
21
+ env: BUNDLE_GEMFILE=gems/rack1.gemfile
22
+ - os: 'ubuntu'
23
+ ruby: 2.7
24
+ env: BUNDLE_GEMFILE=gems/rack3.gemfile
25
+ - os: 'ubuntu'
26
+ ruby: 2.6
27
+ env: COVERAGE=PartialSummary,Coveralls
28
+
29
+ runs-on: ${{matrix.os}}-latest
30
+
31
+ steps:
32
+ - uses: actions/checkout@v1
33
+ - uses: ruby/setup-ruby@v1
34
+ with:
35
+ ruby-version: ${{matrix.ruby}}
36
+
37
+ - name: Installing packages (ubuntu)
38
+ if: matrix.os == 'ubuntu'
39
+ run: sudo apt-get install apache2-utils
40
+
41
+ - name: Install dependencies
42
+ run: ${{matrix.env}} bundle install
43
+
44
+ - name: Run tests
45
+ run: ${{matrix.env}} bundle exec rspec
@@ -11,12 +11,13 @@ addons:
11
11
  packages:
12
12
  - wrk
13
13
 
14
+ script: bundle exec rspec
15
+
14
16
  after_script:
15
17
  - bundle exec rake benchmark:compare
16
18
 
17
19
  matrix:
18
20
  include:
19
- - rvm: 2.4
20
21
  - rvm: 2.5
21
22
  - rvm: 2.6
22
23
  - rvm: 2.6
data/Gemfile CHANGED
@@ -5,12 +5,12 @@ source 'https://rubygems.org'
5
5
  gemspec
6
6
 
7
7
  # gem "async-container", path: "../async-container"
8
+ # gem "async-websocket", path: "../async-websocket"
8
9
 
9
10
  group :development do
10
11
  gem 'ruby-prof', platform: :mri
11
12
  end
12
13
 
13
14
  group :test do
14
- gem 'pry'
15
15
  gem 'puma'
16
16
  end
@@ -0,0 +1,27 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'async'
4
+ require 'async/http/endpoint'
5
+ require 'async/websocket/adapters/rack'
6
+
7
+ require 'falcon'
8
+
9
+ module WebSocketApp
10
+ def self.call(env)
11
+ Async::WebSocket::Adapters::Rack.open(env, protocols: %w[ws]) do |connection|
12
+ while (message = connection.read)
13
+ pp message
14
+ end
15
+ end or [200, [], ["Websocket only."]]
16
+ end
17
+ end
18
+
19
+ Async do
20
+ websocket_endpoint = Async::HTTP::Endpoint.parse('http://127.0.0.1:3000')
21
+
22
+ app = Falcon::Server.middleware(WebSocketApp)
23
+
24
+ server = Falcon::Server.new(app, websocket_endpoint)
25
+
26
+ server.run.each(&:wait)
27
+ end
@@ -14,15 +14,15 @@ Gem::Specification.new do |spec|
14
14
  f.match(%r{^(test|spec|features)/})
15
15
  end
16
16
 
17
- spec.required_ruby_version = '>= 2.4.0'
17
+ spec.required_ruby_version = '~> 2.4'
18
18
 
19
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.add_dependency "async", "~> 1.13"
23
23
  spec.add_dependency "async-io", "~> 1.22"
24
- spec.add_dependency "async-http", "~> 0.50.4"
25
- spec.add_dependency "async-http-cache", "~> 0.1.0"
24
+ spec.add_dependency "async-http", "~> 0.51.0"
25
+ spec.add_dependency "async-http-cache", "~> 0.2.0"
26
26
  spec.add_dependency "async-container", "~> 0.16.0"
27
27
 
28
28
  spec.add_dependency "rack", ">= 1.0"
@@ -34,12 +34,12 @@ Gem::Specification.new do |spec|
34
34
  spec.add_dependency 'process-metrics', '~> 0.1.0'
35
35
 
36
36
  spec.add_development_dependency "async-rspec", "~> 1.7"
37
- spec.add_development_dependency "async-websocket", "~> 0.12.0"
37
+ spec.add_development_dependency "async-websocket", "~> 0.14.0"
38
38
  spec.add_development_dependency "async-process", "~> 1.1"
39
39
 
40
40
  spec.add_development_dependency "bake"
41
- spec.add_development_dependency "covered", "~> 0.10"
41
+ spec.add_development_dependency "covered"
42
42
  spec.add_development_dependency "bundler"
43
43
  spec.add_development_dependency "rspec", "~> 3.6"
44
- spec.add_development_dependency "rake"
44
+ spec.add_development_dependency "bake-bundler"
45
45
  end
@@ -43,16 +43,15 @@ module Falcon
43
43
  elsif status == 200 and body.respond_to?(:to_path)
44
44
  # Don't mangle partial responsese (206)
45
45
  return ::Protocol::HTTP::Body::File.open(body.to_path)
46
- elsif body.is_a? Array
47
- # TODO after dropping 2.3, change to #sum
48
- length ||= body.inject(0){|sum, chunk| sum + chunk.bytesize}
49
- return self.new(headers, body, length)
46
+ elsif body.is_a?(Array)
47
+ length ||= body.sum(&:bytesize)
48
+ return self.new(body, length)
50
49
  else
51
- return self.new(headers, body, length)
50
+ return self.new(body, length)
52
51
  end
53
52
  end
54
53
 
55
- def initialize(headers, body, length)
54
+ def initialize(body, length)
56
55
  @length = length
57
56
  @body = body
58
57
 
@@ -67,6 +67,11 @@ module Falcon
67
67
  body = Output.wrap(status, headers, body)
68
68
  end
69
69
 
70
+ if request&.head?
71
+ # I thought about doing this in Output.wrap, but decided the semantics are too tricky. Specifically, the various ways a rack response body can be wrapped, and the need to invoke #close at the right point.
72
+ body = ::Protocol::HTTP::Body::Head.for(body)
73
+ end
74
+
70
75
  protocol = meta['rack.protocol']
71
76
 
72
77
  # https://tools.ietf.org/html/rfc7231#section-7.4.2
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module Falcon
24
- VERSION = "0.35.6"
24
+ VERSION = "0.36.0"
25
25
  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.35.6
4
+ version: 0.36.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-03-12 00:00:00.000000000 Z
11
+ date: 2020-04-08 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.50.4
47
+ version: 0.51.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.50.4
54
+ version: 0.51.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.1.0
61
+ version: 0.2.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.1.0
68
+ version: 0.2.0
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: async-container
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -170,14 +170,14 @@ dependencies:
170
170
  requirements:
171
171
  - - "~>"
172
172
  - !ruby/object:Gem::Version
173
- version: 0.12.0
173
+ version: 0.14.0
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
178
  - - "~>"
179
179
  - !ruby/object:Gem::Version
180
- version: 0.12.0
180
+ version: 0.14.0
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: async-process
183
183
  requirement: !ruby/object:Gem::Requirement
@@ -210,16 +210,16 @@ dependencies:
210
210
  name: covered
211
211
  requirement: !ruby/object:Gem::Requirement
212
212
  requirements:
213
- - - "~>"
213
+ - - ">="
214
214
  - !ruby/object:Gem::Version
215
- version: '0.10'
215
+ version: '0'
216
216
  type: :development
217
217
  prerelease: false
218
218
  version_requirements: !ruby/object:Gem::Requirement
219
219
  requirements:
220
- - - "~>"
220
+ - - ">="
221
221
  - !ruby/object:Gem::Version
222
- version: '0.10'
222
+ version: '0'
223
223
  - !ruby/object:Gem::Dependency
224
224
  name: bundler
225
225
  requirement: !ruby/object:Gem::Requirement
@@ -249,7 +249,7 @@ dependencies:
249
249
  - !ruby/object:Gem::Version
250
250
  version: '3.6'
251
251
  - !ruby/object:Gem::Dependency
252
- name: rake
252
+ name: bake-bundler
253
253
  requirement: !ruby/object:Gem::Requirement
254
254
  requirements:
255
255
  - - ">="
@@ -273,13 +273,12 @@ extra_rdoc_files: []
273
273
  files:
274
274
  - ".editorconfig"
275
275
  - ".github/FUNDING.yml"
276
+ - ".github/workflows/development.yml"
276
277
  - ".gitignore"
277
278
  - ".rspec"
278
279
  - ".travis.yml"
279
280
  - Gemfile
280
281
  - README.md
281
- - Rakefile
282
- - VIRTUAL.md
283
282
  - bake/falcon/supervisor.rb
284
283
  - bin/falcon
285
284
  - bin/falcon-host
@@ -305,6 +304,7 @@ files:
305
304
  - examples/sequel/Gemfile
306
305
  - examples/sequel/config.ru
307
306
  - examples/sequel/data.sqlite3
307
+ - examples/server/standalone.rb
308
308
  - examples/sinatra/Gemfile
309
309
  - examples/sinatra/Gemfile.lock
310
310
  - examples/sinatra/config.ru
@@ -371,9 +371,9 @@ require_paths:
371
371
  - lib
372
372
  required_ruby_version: !ruby/object:Gem::Requirement
373
373
  requirements:
374
- - - ">="
374
+ - - "~>"
375
375
  - !ruby/object:Gem::Version
376
- version: 2.4.0
376
+ version: '2.4'
377
377
  required_rubygems_version: !ruby/object:Gem::Requirement
378
378
  requirements:
379
379
  - - ">="
data/Rakefile DELETED
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:test)
7
-
8
- task :default => :test
9
-
10
- # Load all rake tasks:
11
- import(*Dir.glob('tasks/**/*.rake'))
12
-
13
- task :server do
14
- require 'async/reactor'
15
- require 'async/http/server'
16
-
17
- app = lambda do |env|
18
- [200, {}, ["Hello World"]]
19
- end
20
-
21
- server = Async::HTTP::Server.new([
22
- Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
23
- ], app)
24
-
25
- Async::Reactor.run do
26
- server.run
27
- end
28
- end
29
-
30
- task :client do
31
- require 'async/reactor'
32
- require 'async/http/client'
33
-
34
- client = Async::HTTP::Client.new([
35
- Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
36
- ])
37
-
38
- Async::Reactor.run do
39
- response = client.get("/")
40
-
41
- puts response.inspect
42
- end
43
- end
44
-
45
- task :wrk do
46
- require 'async/reactor'
47
- require 'async/http/server'
48
-
49
- app = lambda do |env|
50
- [200, {}, ["Hello World"]]
51
- end
52
-
53
- server = Async::HTTP::Server.new([
54
- Async::IO::Endpoint.tcp('127.0.0.1', 9294, reuse_port: true)
55
- ], app)
56
-
57
- process_count = Etc.nprocessors
58
-
59
- pids = process_count.times.collect do
60
- fork do
61
- Async::Reactor.run do
62
- server.run
63
- end
64
- end
65
- end
66
-
67
- url = "http://127.0.0.1:9294/"
68
-
69
- connections = process_count
70
- system("wrk", "-c", connections.to_s, "-d", "2", "-t", connections.to_s, url)
71
-
72
- pids.each do |pid|
73
- Process.kill(:KILL, pid)
74
- Process.wait pid
75
- end
76
- end
77
-
data/VIRTUAL.md DELETED
@@ -1,14 +0,0 @@
1
- For every `falcon.rb`:
2
-
3
- Spawn a child which loads falcon.rb:
4
- - Bind to `server.ipc`
5
-
6
- Server loads falcon.rb:
7
- - Figure out whether it is application or not.
8
-
9
- Server forks client:
10
- - Client binds to `server.ipc`.
11
- - Server connects to `server.ipc`.
12
-
13
-
14
- Server expects client to bind to `server.ipc`.