opal-up 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +46 -14
- data/bin/up +5 -22
- data/bin/up_bun +5 -16
- data/bin/up_cluster +12 -0
- data/bin/up_node +12 -0
- data/bin/up_node_cluster +12 -0
- data/example_roda_app/Gemfile +2 -2
- data/example_roda_app/roda_app.rb +2 -0
- data/example_sinatra_app/Gemfile +1 -1
- data/lib/up/bun/rack_env.rb +104 -0
- data/lib/up/bun/rack_server.rb +25 -0
- data/lib/up/bun/server.rb +89 -0
- data/lib/up/bun/server_cli.rb +15 -0
- data/lib/up/cli.rb +151 -0
- data/lib/up/node/cluster.rb +39 -0
- data/lib/up/node/cluster_cli.rb +15 -0
- data/lib/up/node/rack_cluster.rb +25 -0
- data/lib/up/node/rack_env.rb +106 -0
- data/lib/up/node/rack_server.rb +25 -0
- data/lib/up/node/server.rb +84 -0
- data/lib/up/node/server_cli.rb +15 -0
- data/lib/up/u_web_socket/cluster.rb +39 -0
- data/lib/up/u_web_socket/cluster_cli.rb +15 -0
- data/lib/up/u_web_socket/rack_cluster.rb +25 -0
- data/lib/up/u_web_socket/rack_env.rb +101 -0
- data/lib/up/u_web_socket/rack_server.rb +25 -0
- data/lib/up/u_web_socket/server.rb +82 -0
- data/lib/up/u_web_socket/server_cli.rb +15 -0
- data/lib/up/version.rb +1 -1
- data/opal-up.gemspec +1 -1
- metadata +27 -13
- data/lib/up/bun.rb +0 -91
- data/lib/up/bun_cli.rb +0 -32
- data/lib/up/bun_rack.rb +0 -19
- data/lib/up/bun_rack_env.rb +0 -102
- data/lib/up/u_web_socket.rb +0 -83
- data/lib/up/u_web_socket_cluster.rb +0 -89
- data/lib/up/uws_cli.rb +0 -32
- data/lib/up/uws_rack.rb +0 -19
- data/lib/up/uws_rack_env.rb +0 -99
- data/lib/up-bun.rb +0 -7
- data/lib/up-node.rb +0 -7
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
|
data/lib/up/bun_rack_env.rb
DELETED
@@ -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
|
data/lib/up/u_web_socket.rb
DELETED
@@ -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
|
data/lib/up/uws_rack_env.rb
DELETED
@@ -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