opal-up 0.0.1 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +209 -0
  3. data/README.md +108 -23
  4. data/bin/up +5 -22
  5. data/bin/up_bun +5 -16
  6. data/bin/up_cluster +12 -0
  7. data/bin/up_node +12 -0
  8. data/bin/up_node_cluster +12 -0
  9. data/bin/up_ruby +4 -0
  10. data/bin/up_ruby_cluster +4 -0
  11. data/ext/up_ext/App.h +606 -0
  12. data/ext/up_ext/AsyncSocket.h +355 -0
  13. data/ext/up_ext/AsyncSocketData.h +87 -0
  14. data/ext/up_ext/BloomFilter.h +83 -0
  15. data/ext/up_ext/ChunkedEncoding.h +236 -0
  16. data/ext/up_ext/ClientApp.h +36 -0
  17. data/ext/up_ext/HttpContext.h +502 -0
  18. data/ext/up_ext/HttpContextData.h +56 -0
  19. data/ext/up_ext/HttpErrors.h +53 -0
  20. data/ext/up_ext/HttpParser.h +680 -0
  21. data/ext/up_ext/HttpResponse.h +578 -0
  22. data/ext/up_ext/HttpResponseData.h +95 -0
  23. data/ext/up_ext/HttpRouter.h +380 -0
  24. data/ext/up_ext/Loop.h +204 -0
  25. data/ext/up_ext/LoopData.h +112 -0
  26. data/ext/up_ext/MoveOnlyFunction.h +377 -0
  27. data/ext/up_ext/PerMessageDeflate.h +315 -0
  28. data/ext/up_ext/ProxyParser.h +163 -0
  29. data/ext/up_ext/QueryParser.h +120 -0
  30. data/ext/up_ext/TopicTree.h +363 -0
  31. data/ext/up_ext/Utilities.h +66 -0
  32. data/ext/up_ext/WebSocket.h +381 -0
  33. data/ext/up_ext/WebSocketContext.h +434 -0
  34. data/ext/up_ext/WebSocketContextData.h +109 -0
  35. data/ext/up_ext/WebSocketData.h +86 -0
  36. data/ext/up_ext/WebSocketExtensions.h +256 -0
  37. data/ext/up_ext/WebSocketHandshake.h +145 -0
  38. data/ext/up_ext/WebSocketProtocol.h +506 -0
  39. data/ext/up_ext/bsd.c +767 -0
  40. data/ext/up_ext/bsd.h +109 -0
  41. data/ext/up_ext/context.c +524 -0
  42. data/ext/up_ext/epoll_kqueue.c +458 -0
  43. data/ext/up_ext/epoll_kqueue.h +67 -0
  44. data/ext/up_ext/extconf.rb +5 -0
  45. data/ext/up_ext/internal.h +224 -0
  46. data/ext/up_ext/libusockets.h +350 -0
  47. data/ext/up_ext/libuwebsockets.cpp +1374 -0
  48. data/ext/up_ext/libuwebsockets.h +260 -0
  49. data/ext/up_ext/loop.c +386 -0
  50. data/ext/up_ext/loop_data.h +38 -0
  51. data/ext/up_ext/socket.c +231 -0
  52. data/ext/up_ext/up_ext.c +278 -0
  53. data/lib/up/bun/rack_env.rb +104 -0
  54. data/lib/up/bun/rack_server.rb +25 -0
  55. data/lib/up/bun/server.rb +89 -0
  56. data/lib/up/bun/server_cli.rb +15 -0
  57. data/lib/up/cli.rb +151 -0
  58. data/lib/up/node/cluster.rb +39 -0
  59. data/lib/up/node/cluster_cli.rb +15 -0
  60. data/lib/up/node/rack_cluster.rb +25 -0
  61. data/lib/up/node/rack_env.rb +106 -0
  62. data/lib/up/node/rack_server.rb +25 -0
  63. data/lib/up/node/server.rb +84 -0
  64. data/lib/up/node/server_cli.rb +15 -0
  65. data/lib/up/ruby/cluster_cli.rb +10 -0
  66. data/lib/up/ruby/rack_cluster.rb +26 -0
  67. data/lib/up/ruby/rack_env.rb +97 -0
  68. data/lib/up/ruby/rack_server.rb +26 -0
  69. data/lib/up/ruby/server_cli.rb +10 -0
  70. data/lib/up/u_web_socket/cluster.rb +39 -0
  71. data/lib/up/u_web_socket/cluster_cli.rb +15 -0
  72. data/lib/up/u_web_socket/rack_cluster.rb +25 -0
  73. data/lib/up/u_web_socket/rack_env.rb +101 -0
  74. data/lib/up/u_web_socket/rack_server.rb +25 -0
  75. data/lib/up/u_web_socket/server.rb +82 -0
  76. data/lib/up/u_web_socket/server_cli.rb +15 -0
  77. data/lib/up/version.rb +1 -1
  78. metadata +96 -29
  79. data/.gitignore +0 -5
  80. data/Gemfile +0 -2
  81. data/example_rack_app/Gemfile +0 -3
  82. data/example_rack_app/config.ru +0 -6
  83. data/example_rack_app/rack_app.rb +0 -5
  84. data/example_roda_app/Gemfile +0 -6
  85. data/example_roda_app/config.ru +0 -6
  86. data/example_roda_app/roda_app.rb +0 -35
  87. data/example_sinatra_app/Gemfile +0 -6
  88. data/example_sinatra_app/config.ru +0 -6
  89. data/example_sinatra_app/sinatra_app.rb +0 -7
  90. data/lib/up/bun.rb +0 -91
  91. data/lib/up/bun_cli.rb +0 -32
  92. data/lib/up/bun_rack.rb +0 -19
  93. data/lib/up/bun_rack_env.rb +0 -102
  94. data/lib/up/u_web_socket.rb +0 -83
  95. data/lib/up/u_web_socket_cluster.rb +0 -89
  96. data/lib/up/uws_cli.rb +0 -32
  97. data/lib/up/uws_rack.rb +0 -19
  98. data/lib/up/uws_rack_env.rb +0 -99
  99. data/lib/up-bun.rb +0 -7
  100. data/lib/up-node.rb +0 -7
  101. data/opal-up.gemspec +0 -27
  102. data/up_logo.svg +0 -256
@@ -1,35 +0,0 @@
1
- require "roda"
2
-
3
- class RodaApp < Roda
4
- route do |r|
5
- # GET / request
6
- r.root do
7
- r.redirect "/hello"
8
- end
9
-
10
- # /hello branch
11
- r.on "hello" do
12
- # Set variable for all routes in /hello branch
13
- @greeting = 'Hello'
14
-
15
- # GET /hello/world request
16
- r.get "world" do
17
- "#{@greeting} world!"
18
- end
19
-
20
- # /hello request
21
- r.is do
22
- # GET /hello request
23
- r.get do
24
- "#{@greeting}!"
25
- end
26
-
27
- # POST /hello request
28
- r.post do
29
- puts "Someone said #{@greeting}!"
30
- r.redirect
31
- end
32
- end
33
- end
34
- end
35
- end
@@ -1,6 +0,0 @@
1
- source 'https://rubygems.org'
2
- git_source(:github) { |repo| "https://github.com/#{repo}.git" }
3
-
4
- gem 'opal', github: 'opal/opal'
5
- gem 'opal-up', path: '../'
6
- gem 'sinatra', '>= 4.0.0'
@@ -1,6 +0,0 @@
1
- require_relative 'sinatra_app'
2
- if defined? RubyVM
3
- # ensure up contenders use a JIT
4
- RubyVM::YJIT.enable
5
- end
6
- run SinatraApp
@@ -1,7 +0,0 @@
1
- require 'sinatra/base'
2
-
3
- class SinatraApp
4
- get '/' do
5
- 'Hello world!'
6
- end
7
- end
data/lib/up/bun.rb DELETED
@@ -1,91 +0,0 @@
1
- # backtick_javascript: true
2
-
3
- require 'up/bun_rack_env'
4
-
5
- module Up
6
- module Bun
7
- def self.listen(app:, host: 'localhost', port: 3000, scheme: 'http', ca_file: nil, cert_file: nil, key_file: nil)
8
- port = port&.to_i
9
- scheme ||= 'http'
10
- host ||= 'localhost'
11
- port ||= 3000
12
- config = { handler: self.name, engine: "bun/#{`process.version`}", port: port, scheme: scheme, host: host }
13
- %x{
14
- if (scheme !== 'http' && scheme !== 'https') {
15
- #{raise "unsupported scheme #{scheme}"}
16
- }
17
-
18
- var server_options = {
19
- port: port,
20
- hostname: host,
21
- development: false,
22
- fetch(req) {
23
- const rack_res = app.$call(Opal.Up.BunRackEnv.$new(req, config));
24
- const hdr = new Headers();
25
- const headers = rack_res[1];
26
- if (headers.$$is_hash) {
27
- var header, k, v;
28
- for(header of headers) {
29
- k = header[0];
30
- v = header[1];
31
- if (!k.startsWith('rack.')) {
32
- if (v.$$is_array) {
33
- v = v.join("\n");
34
- }
35
- hdr.set(k, v);
36
- }
37
- }
38
- }
39
- var body = '';
40
-
41
- #{
42
- parts = `rack_res[2]`
43
- if parts.respond_to?(:each)
44
- parts.each do |part|
45
- # this is not technically correct, just to make htings work
46
- `body = body + part`
47
- end
48
- elsif parts.respond_to?(:call)
49
- `body = parts.$call()`
50
- end
51
- parts.close if parts.respond_to?(:close)
52
- }
53
-
54
- return new Response(body, {status: rack_res[0], statusText: 'OK', headers: hdr});
55
- }
56
- };
57
- if (scheme === 'https') {
58
- server_options.tls = {
59
- key: Bun.file(key_file),
60
- cert: Bun.file(cert_file),
61
- ca: Bun.file(ca_file)
62
- };
63
- }
64
-
65
- Bun.serve(server_options);
66
- console.log(`Server is running on http://${host}:${port}`);
67
- }
68
- end
69
-
70
- def self.stop
71
- sleep 0.1
72
- puts 'deflating request chain links'
73
- sleep 0.1
74
- puts 'optimizing response distortion'
75
- sleep 0.1
76
- print 'releasing boost pressure: '
77
- 3.times do
78
- sleep 0.2
79
- print '.'
80
- end
81
- 3.times do
82
- puts "\nRED ALERT: boost pressure to high, cannot open release valve!1!!!"
83
- sleep 0.1
84
- print '.'
85
- sleep 0.1
86
- end
87
- puts 'stopping engines failed, for further help see:'
88
- puts 'https://www.youtube.com/watch?v=ecBco63zvas'
89
- end
90
- end
91
- end
data/lib/up/bun_cli.rb DELETED
@@ -1,32 +0,0 @@
1
- require 'opal/platform'
2
- require 'bun/file'
3
- require 'nodejs/require'
4
- require 'opal-parser'
5
- require 'rack/builder'
6
- require 'up/rack_builder_patch'
7
-
8
- module Up
9
- module CLI
10
- def self.try_file(filename)
11
- return nil unless File.exist? filename
12
- ::Rack::Builder.parse_file filename
13
- end
14
-
15
- def self.get_app(filename = 'config.ru')
16
- app = nil
17
- filename ||= 'config.ru'
18
- app = try_file filename
19
- if File.exist?("#{filename}.ru")
20
- filename = "#{filename}.ru"
21
- app ||= try_file filename
22
- end
23
- raise "Something wrong with #{filename}\n" unless app
24
- app
25
- end
26
-
27
- def self.call
28
- app = get_app
29
- Up::BunRack.run(app)
30
- end
31
- end
32
- end
data/lib/up/bun_rack.rb DELETED
@@ -1,19 +0,0 @@
1
- module Up
2
- module BunRack
3
- def self.run(app, options = {})
4
- Up::Bun.listen(app: app, port: options[:port], host: options[:host])
5
- true
6
- end
7
-
8
- def self.shutdown
9
- Up::Bun.stop
10
- end
11
- end
12
- end
13
-
14
- ENV['RACK_HANDLER'] ||= 'up'
15
-
16
- begin
17
- ::Rackup::Handler.register('up', Up::BunRack) if defined?(::Rackup::Handler)
18
- rescue StandardError
19
- end
@@ -1,102 +0,0 @@
1
- # backtick_javascript: true
2
-
3
- require 'logger'
4
- require 'up/version'
5
-
6
- module Up
7
- class BunRackEnv < ::Hash
8
- RACK_VARS = %w[rack.errors rack.hijack rack.hijack? rack.input rack.logger
9
- rack.multipart.buffer_size rack.multipart.tempfile_factory
10
- rack.response_finished
11
- rack.session rack.upgrade rack.upgrade? rack.url_scheme
12
- HTTP_ACCEPT HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE
13
- HTTP_CONNECTION HTTP_HOST HTTP_USER_AGENT PATH_INFO QUERY_STRING REQUEST_METHOD
14
- SCRIPT_NAME SERVER_NAME SERVER_PROTOCOL SERVER_SOFTWARE]
15
- def initialize(req, config)
16
- @req = req
17
- @config = config
18
- end
19
-
20
- def [](key)
21
- return super(key) if key?(key)
22
- self[key] = case key
23
- when 'rack.errors'
24
- STDERR
25
- when 'rack.hijack'
26
- nil
27
- when 'rack.hijack?'
28
- false
29
- when 'rack.input'
30
- ::IO.new
31
- when 'rack.logger'
32
- ::Logger.new(self['rack.errors'])
33
- when 'rack.multipart.buffer_size'
34
- 4096
35
- when 'rack.multipart.tempfile_factory'
36
- proc { |_filename, _content_type| File.new }
37
- when 'rack.response_finished'
38
- []
39
- when 'rack.session'
40
- {}
41
- when 'rack.upgrade'
42
- nil
43
- when 'rack.upgrade?'
44
- nil
45
- when 'rack.url_scheme'
46
- @config[:scheme]
47
- when 'PATH_INFO'
48
- `#@req.url`
49
- when 'QUERY_STRING'
50
- ""
51
- when 'RACK_ERRORS'
52
- self['rack.errors']
53
- when 'RACK_LOGGER'
54
- self['rack.logger']
55
- when 'REQUEST_METHOD'
56
- `#@req.method`
57
- when 'SCRIPT_NAME'
58
- ""
59
- when 'SERVER_NAME'
60
- @config[:host]
61
- when 'SERVER_PORT'
62
- @config[:port].to_s
63
- when 'SERVER_PROTOCOL'
64
- ""
65
- when 'SERVER_SOFTWARE'
66
- "#{@config[:handler]}/#{Up::VERSION} #{@config[:engine]}"
67
- else
68
- if key.start_with?('HTTP_')
69
- key = key[5..].gsub(/_/, '-')
70
- `#@req.headers.get(key.toLowerCase())`
71
- else
72
- nil
73
- end
74
- end
75
- end
76
-
77
- def req_headers
78
- h = {}
79
- %x{
80
- var hdr, hds = #@req.headers;
81
- for (hdr in hds) { h.set(hdr[0], hdr[1]); }
82
- }
83
- h
84
- end
85
-
86
- def each
87
- unless @got_them_all
88
- RACK_VARS.each { |k| self[k] unless self.key?(k) }
89
- @got_them_all = true
90
- end
91
- super
92
- end
93
-
94
- def to_s
95
- unless @got_them_all
96
- RACK_VARS.each { |k| self[k] unless self.key?(k) }
97
- @got_them_all = true
98
- end
99
- super
100
- end
101
- end
102
- end
@@ -1,83 +0,0 @@
1
- # backtick_javascript: true
2
-
3
- %x{
4
- module.paths.push(process.cwd() + '/node_modules');
5
- const uws = require('uWebSockets.js');
6
- const cluster = require('node:cluster');
7
- }
8
-
9
- require 'up/uws_rack_env'
10
-
11
- module Up
12
- module UWebSocket
13
- def self.listen(app:, host: 'localhost', port: 3000, scheme: 'http', ca_file: nil, cert_file: nil, key_file: nil)
14
- port = port&.to_i
15
- scheme ||= 'http'
16
- host ||= 'localhost'
17
- port ||= 3000
18
- config = { handler: self.name, engine: "node/#{`process.version`}", port: port, scheme: scheme, host: host }
19
- %x{
20
- let server;
21
- if (scheme == 'http') {
22
- server = uws.App();
23
- } else if (scheme == 'https') {
24
- server = uws.SSLApp({ ca_file_name: ca_file, cert_file_name: cert_file, key_file_name: key_file });
25
- } else {
26
- #{raise "unsupported scheme #{scheme}"}
27
- }
28
- server.get('/*', (res, req) => {
29
- const rack_res = app.$call(Opal.Up.UwsRackEnv.$new(req, config));
30
- res.writeStatus(`${rack_res[0].toString()} OK`);
31
- const headers = rack_res[1];
32
- if (headers.$$is_hash) {
33
- var header, k, v;
34
- for(header of headers) {
35
- k = header[0];
36
- v = header[1];
37
- if (!k.startsWith('rack.')) {
38
- if (v.$$is_array) {
39
- v = v.join("\n");
40
- }
41
- res.writeHeader(k, v);
42
- }
43
- }
44
- }
45
- #{
46
- parts = `rack_res[2]`
47
- if parts.respond_to?(:each)
48
- parts.each do |part|
49
- `res.write(part)`
50
- end
51
- elsif parts.respond_to?(:call)
52
- `res.write(parts.$call())`
53
- end
54
- parts.close if parts.respond_to?(:close)
55
- }
56
- res.end();
57
- });
58
- server.listen(port, host, () => { console.log(`Server is running on http://${host}:${port}`)});
59
- }
60
- end
61
-
62
- def self.stop
63
- sleep 0.1
64
- puts 'deflating request chain links'
65
- sleep 0.1
66
- puts 'optimizing response distortion'
67
- sleep 0.1
68
- print 'releasing boost pressure: '
69
- 3.times do
70
- sleep 0.2
71
- print '.'
72
- end
73
- 3.times do
74
- puts "\nRED ALERT: boost pressure to high, cannot open release valve!1!!!"
75
- sleep 0.1
76
- print '.'
77
- sleep 0.1
78
- end
79
- puts 'stopping engines failed, for further help see:'
80
- puts 'https://www.youtube.com/watch?v=ecBco63zvas'
81
- end
82
- end
83
- end
@@ -1,89 +0,0 @@
1
- # backtick_javascript: true
2
-
3
- %x{
4
- module.paths.push(process.cwd() + '/node_modules');
5
- const uws = require('uWebSockets.js');
6
- const cluster = require('node:cluster');
7
- }
8
-
9
- require 'up/uws_rack_env'
10
-
11
- module Up
12
- module UWebSocket
13
- def self.listen(app:, host: 'localhost', port: 3000, scheme: 'http', ca_file: nil, cert_file: nil, key_file: nil, workers: 4)
14
- port = port&.to_i
15
- scheme ||= 'http'
16
- host ||= 'localhost'
17
- port ||= 3000
18
- config = { handler: self.name, engine: "node/#{`process.version`}", port: port, scheme: scheme, host: host }
19
- %x{
20
- if (cluster.isPrimary) {
21
- for (let i = 0; i < workers; i++) {
22
- cluster.fork();
23
- }
24
- } else {
25
- let server;
26
- if (scheme == 'http') {
27
- server = uws.App();
28
- } else if (scheme == 'https') {
29
- server = uws.SSLApp({ ca_file_name: ca_file, cert_file_name: cert_file, key_file_name: key_file });
30
- } else {
31
- #{raise "unsupported scheme #{scheme}"}
32
- }
33
- server.get('/*', (res, req) => {
34
- const rack_res = app.$call(Opal.Up.UwsRackEnv.$new(req, config));
35
- res.writeStatus(`${rack_res[0].toString()} OK`);
36
- const headers = rack_res[1];
37
- if (headers.$$is_hash) {
38
- var header, k, v;
39
- for(header of headers) {
40
- k = header[0];
41
- v = header[1];
42
- if (!k.startsWith('rack.')) {
43
- if (v.$$is_array) {
44
- v = v.join("\n");
45
- }
46
- res.writeHeader(k, v);
47
- }
48
- }
49
- }
50
- #{
51
- parts = `rack_res[2]`
52
- if parts.respond_to?(:each)
53
- parts.each do |part|
54
- `res.write(part)`
55
- end
56
- elsif parts.respond_to?(:call)
57
- `res.write(parts.$call())`
58
- end
59
- parts.close if parts.respond_to?(:close)
60
- }
61
- res.end();
62
- });
63
- server.listen(port, host, () => { console.log(`Server is running on http://${host}:${port}`)});
64
- }
65
- }
66
- end
67
-
68
- def self.stop
69
- sleep 0.1
70
- puts 'deflating request chain links'
71
- sleep 0.1
72
- puts 'optimizing response distortion'
73
- sleep 0.1
74
- print 'releasing boost pressure: '
75
- 3.times do
76
- sleep 0.2
77
- print '.'
78
- end
79
- 3.times do
80
- puts "\nRED ALERT: boost pressure to high, cannot open release valve!1!!!"
81
- sleep 0.1
82
- print '.'
83
- sleep 0.1
84
- end
85
- puts 'stopping engines failed, for further help see:'
86
- puts 'https://www.youtube.com/watch?v=ecBco63zvas'
87
- end
88
- end
89
- end
data/lib/up/uws_cli.rb DELETED
@@ -1,32 +0,0 @@
1
- require 'opal/platform'
2
- require 'nodejs/file'
3
- require 'nodejs/require'
4
- require 'opal-parser'
5
- require 'rack/builder'
6
- require 'up/rack_builder_patch'
7
-
8
- module Up
9
- module CLI
10
- def self.try_file(filename)
11
- return nil unless File.exist? filename
12
- ::Rack::Builder.parse_file filename
13
- end
14
-
15
- def self.get_app(filename = 'config.ru')
16
- app = nil
17
- filename ||= 'config.ru'
18
- app = try_file filename
19
- if File.exist?("#{filename}.ru")
20
- filename = "#{filename}.ru"
21
- app ||= try_file filename
22
- end
23
- raise "Something wrong with #{filename}\n" unless app
24
- app
25
- end
26
-
27
- def self.call
28
- app = get_app
29
- Up::UwsRack.run(app)
30
- end
31
- end
32
- end
data/lib/up/uws_rack.rb DELETED
@@ -1,19 +0,0 @@
1
- module Up
2
- module UwsRack
3
- def self.run(app, options = {})
4
- Up::UWebSocket.listen(app: app, port: options[:port], host: options[:host])
5
- true
6
- end
7
-
8
- def self.shutdown
9
- Up::UWebSocket.stop
10
- end
11
- end
12
- end
13
-
14
- ENV['RACK_HANDLER'] ||= 'up'
15
-
16
- begin
17
- ::Rackup::Handler.register('up', Up::UwsRack) if defined?(::Rackup::Handler)
18
- rescue StandardError
19
- end
@@ -1,99 +0,0 @@
1
- # backtick_javascript: true
2
-
3
- require 'logger'
4
- require 'up/version'
5
-
6
- module Up
7
- class UwsRackEnv < ::Hash
8
- RACK_VARS = %w[rack.errors rack.hijack rack.hijack? rack.input rack.logger
9
- rack.multipart.buffer_size rack.multipart.tempfile_factory
10
- rack.response_finished
11
- rack.session rack.upgrade rack.upgrade? rack.url_scheme
12
- HTTP_ACCEPT HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE
13
- HTTP_CONNECTION HTTP_HOST HTTP_USER_AGENT PATH_INFO QUERY_STRING REQUEST_METHOD
14
- SCRIPT_NAME SERVER_NAME SERVER_PROTOCOL SERVER_SOFTWARE]
15
- def initialize(req, config)
16
- @req = req
17
- @config = config
18
- end
19
-
20
- def [](key)
21
- return super(key) if key?(key)
22
- self[key] = case key
23
- when 'rack.errors'
24
- STDERR
25
- when 'rack.hijack'
26
- nil
27
- when 'rack.hijack?'
28
- false
29
- when 'rack.input'
30
- ::IO.new
31
- when 'rack.logger'
32
- ::Logger.new(self['rack.errors'])
33
- when 'rack.multipart.buffer_size'
34
- 4096
35
- when 'rack.multipart.tempfile_factory'
36
- proc { |_filename, _content_type| File.new }
37
- when 'rack.response_finished'
38
- []
39
- when 'rack.session'
40
- {}
41
- when 'rack.upgrade'
42
- nil
43
- when 'rack.upgrade?'
44
- nil
45
- when 'rack.url_scheme'
46
- @config[:scheme]
47
- when 'PATH_INFO'
48
- `#@req.getUrl()`
49
- when 'QUERY_STRING'
50
- `#@req.getQuery()`
51
- when 'RACK_ERRORS'
52
- self['rack.errors']
53
- when 'RACK_LOGGER'
54
- self['rack.logger']
55
- when 'REQUEST_METHOD'
56
- `#@req.getMethod().toUpperCase()`
57
- when 'SCRIPT_NAME'
58
- ""
59
- when 'SERVER_NAME'
60
- @config[:host]
61
- when 'SERVER_PORT'
62
- @config[:port].to_s
63
- when 'SERVER_PROTOCOL'
64
- `#@req.getHeader('protocol')`
65
- when 'SERVER_SOFTWARE'
66
- "#{@config[:handler]}/#{Up::VERSION} #{@config[:engine]}"
67
- else
68
- if key.start_with?('HTTP_')
69
- key = key[5..].gsub(/_/, '-')
70
- `#@req.getHeader(key.toLowerCase())`
71
- else
72
- nil
73
- end
74
- end
75
- end
76
-
77
- def req_headers
78
- h = {}
79
- `#@req.forEach((k, v) => { h.set(k, v); })`
80
- h
81
- end
82
-
83
- def each
84
- unless @got_them_all
85
- RACK_VARS.each { |k| self[k] unless self.key?(k) }
86
- @got_them_all = true
87
- end
88
- super
89
- end
90
-
91
- def to_s
92
- unless @got_them_all
93
- RACK_VARS.each { |k| self[k] unless self.key?(k) }
94
- @got_them_all = true
95
- end
96
- super
97
- end
98
- end
99
- end
data/lib/up-bun.rb DELETED
@@ -1,7 +0,0 @@
1
- module Up
2
- end
3
-
4
- require 'up/bun_cli'
5
- require 'up/bun'
6
- require 'up/bun_rack'
7
- require 'up/bun_rack_env'
data/lib/up-node.rb DELETED
@@ -1,7 +0,0 @@
1
- module Up
2
- end
3
-
4
- require 'up/uws_cli'
5
- require 'up/u_web_socket'
6
- require 'up/uws_rack'
7
- require 'up/uws_rack_env'
data/opal-up.gemspec DELETED
@@ -1,27 +0,0 @@
1
- lib = File.expand_path('lib', __dir__)
2
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
- require_relative 'lib/up/version'
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = 'opal-up'
7
- spec.version = Up::VERSION
8
- spec.authors = ['Jan Biedermann']
9
- spec.email = ['jan@kursator.de']
10
-
11
- spec.summary = 'Rack server for Opal'
12
- spec.description = 'High performance Rack server for Opal Ruby'
13
- spec.homepage = ''
14
- spec.license = 'MIT'
15
- spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test_app|test|spec|features)/}) }
16
- spec.bindir = 'bin'
17
- spec.executables = %w[up up_bun]
18
- spec.require_paths = %w[lib]
19
-
20
- spec.add_dependency 'logger', '~> 1.6.0'
21
- spec.add_dependency 'opal', '>= 1.8.2', '< 3.0.0'
22
- spec.add_dependency 'rack', '~> 3.0.9'
23
- spec.add_dependency 'rackup', '>= 0.2.2', '< 3.0.0'
24
-
25
- spec.add_development_dependency 'rake', '~> 13.1.0'
26
- spec.add_development_dependency 'rspec', '~> 3.12.0'
27
- end