opal-up 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/up_ext/Loop.h +1 -1
- data/ext/up_ext/WebSocketProtocol.h +1 -1
- data/ext/up_ext/up_ext.c +11 -12
- data/lib/up/bun/server.rb +8 -4
- data/lib/up/u_web_socket/server.rb +8 -4
- data/lib/up/version.rb +1 -1
- metadata +1 -2
- data/lib/up/bun/rack_env.rb +0 -92
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3bb6a2cde4f3f4cc8415d17f9d6c471dd5a991cf8ef3a588c528370b4330683d
|
|
4
|
+
data.tar.gz: 697d463336883f4259a27804239642fca35915f7991de7cc92260b6adcda44e1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '09e5af566f909d626a00e0b865b5bb7d7e717d7488f7111a5cc6b9fd8ad2b53d2c9e9aa651492ff76e6ef5eb61da63f208d719af2a593b458033b1eec3a90a10'
|
|
7
|
+
data.tar.gz: f96190488e44fac00d338f639b9167e80ac0a48cd9ee108a75474e99d982834514b94f4a01c8769ef399091c6cab2c6e54381e3e1e524215b2a028a8039abf75
|
data/ext/up_ext/Loop.h
CHANGED
data/ext/up_ext/up_ext.c
CHANGED
|
@@ -143,9 +143,17 @@ static void up_internal_req_header_handler(const char *h, size_t h_len,
|
|
|
143
143
|
}
|
|
144
144
|
|
|
145
145
|
header_key[h_len + 5] = '\0';
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
146
|
+
if (header_key[5] == 'C' &&
|
|
147
|
+
((strncmp(header_key + 5, "CONTENT_TYPE", 12) == 0) ||
|
|
148
|
+
(strncmp(header_key + 5, "CONTENT_LENGTH", 14) == 0))) {
|
|
149
|
+
rb_hash_aset((VALUE)renv,
|
|
150
|
+
rb_enc_str_new(header_key + 5, h_len, binary_encoding),
|
|
151
|
+
rb_enc_str_new(v, v_len, binary_encoding));
|
|
152
|
+
} else {
|
|
153
|
+
rb_hash_aset((VALUE)renv,
|
|
154
|
+
rb_enc_str_new(header_key, h_len + 5, binary_encoding),
|
|
155
|
+
rb_enc_str_new(v, v_len, binary_encoding));
|
|
156
|
+
}
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
static void up_server_prepare_env(VALUE renv, uws_req_t *req) {
|
|
@@ -921,15 +929,6 @@ void up_setup_rack_env_template(void) {
|
|
|
921
929
|
// A common object interface for logging messages
|
|
922
930
|
up_hash_set(rack_env_template, "rack.logger", default_logger);
|
|
923
931
|
|
|
924
|
-
// An Integer hint to the multipart parser as to what chunk size to use for
|
|
925
|
-
// reads and writes.
|
|
926
|
-
up_hash_set(rack_env_template, "rack.multipart.buffer_size", INT2FIX(4096));
|
|
927
|
-
|
|
928
|
-
// An object responding to #call with two arguments, the filename and
|
|
929
|
-
// content_type given for the multipart form field, and returning an IO-like
|
|
930
|
-
// object that responds to #<< and optionally #rewind.
|
|
931
|
-
// up_hash_set(rack_env_template, "rack.multipart.tempfile_factory", Qnil);
|
|
932
|
-
|
|
933
932
|
// An array of callables run by the server after the response has been
|
|
934
933
|
// processed.
|
|
935
934
|
// up_hash_set(rack_env_template, "rack.response_finished", Qnil);
|
data/lib/up/bun/server.rb
CHANGED
|
@@ -27,7 +27,6 @@ module Up
|
|
|
27
27
|
@default_input = StringIO.new('', 'r')
|
|
28
28
|
@server = nil
|
|
29
29
|
@logger = logger
|
|
30
|
-
@t_factory = proc { |filename, _content_type| File.new(filename, 'a+') }
|
|
31
30
|
end
|
|
32
31
|
|
|
33
32
|
%x{
|
|
@@ -78,8 +77,6 @@ module Up
|
|
|
78
77
|
env.set('rack.input', #@default_input);
|
|
79
78
|
}
|
|
80
79
|
env.set('rack.logger', #@logger);
|
|
81
|
-
env.set('rack.multipart.buffer_size', 4096);
|
|
82
|
-
env.set('rack.multipart.tempfile_factory', #@t_factory);
|
|
83
80
|
if (upgrade) {
|
|
84
81
|
env.set('rack.upgrade?', #{:websocket});
|
|
85
82
|
}
|
|
@@ -92,7 +89,14 @@ module Up
|
|
|
92
89
|
env.set('QUERY_STRING', "");
|
|
93
90
|
env.set('REQUEST_METHOD', req.method);
|
|
94
91
|
env.set('PATH_INFO', req.url);
|
|
95
|
-
req.headers.forEach((k, v) => {
|
|
92
|
+
req.headers.forEach((k, v) => {
|
|
93
|
+
let h = k.toUpperCase().replaceAll('-', '_');
|
|
94
|
+
if (h[0] === 'C' && (h === 'CONTENT_TYPE || h === 'CONTENT_LENGTH')) {
|
|
95
|
+
env.set(h, v) ;
|
|
96
|
+
} else {
|
|
97
|
+
env.set('HTTP_' + h, v) ;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
96
100
|
const rack_res = #@app.$call(env);
|
|
97
101
|
if (upgrade) {
|
|
98
102
|
const handler = env.get('rack.upgrade');
|
|
@@ -33,7 +33,6 @@ module Up
|
|
|
33
33
|
@default_input = StringIO.new('', 'r')
|
|
34
34
|
@server = nil
|
|
35
35
|
@logger = logger
|
|
36
|
-
@t_factory = proc { |filename, _content_type| File.new(filename, 'a+') }
|
|
37
36
|
end
|
|
38
37
|
|
|
39
38
|
%x{
|
|
@@ -64,8 +63,6 @@ module Up
|
|
|
64
63
|
env.set('rack.errors',#{STDERR});
|
|
65
64
|
env.set('rack.input', ins.default_input);
|
|
66
65
|
env.set('rack.logger', ins.logger);
|
|
67
|
-
env.set('rack.multipart.buffer_size', 4096);
|
|
68
|
-
env.set('rack.multipart.tempfile_factory', ins.t_factory);
|
|
69
66
|
env.set('rack.url_scheme', ins.scheme);
|
|
70
67
|
env.set('SCRIPT_NAME', "");
|
|
71
68
|
env.set('SERVER_PROTOCOL', 'HTTP/1.1');
|
|
@@ -75,7 +72,14 @@ module Up
|
|
|
75
72
|
env.set('QUERY_STRING', req.getQuery() || '');
|
|
76
73
|
env.set('REQUEST_METHOD', req.getMethod().toUpperCase());
|
|
77
74
|
env.set('PATH_INFO', req.getUrl());
|
|
78
|
-
req.forEach((k, v) => {
|
|
75
|
+
req.forEach((k, v) => {
|
|
76
|
+
let h = k.toUpperCase().replaceAll('-', '_');
|
|
77
|
+
if (h[0] === 'C' && (h === 'CONTENT_TYPE || h === 'CONTENT_LENGTH')) {
|
|
78
|
+
env.set(h, v) ;
|
|
79
|
+
} else {
|
|
80
|
+
env.set('HTTP_' + h, v) ;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
79
83
|
return env;
|
|
80
84
|
}
|
|
81
85
|
}
|
data/lib/up/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: opal-up
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jan Biedermann
|
|
@@ -162,7 +162,6 @@ files:
|
|
|
162
162
|
- ext/up_ext/loop_data.h
|
|
163
163
|
- ext/up_ext/socket.c
|
|
164
164
|
- ext/up_ext/up_ext.c
|
|
165
|
-
- lib/up/bun/rack_env.rb
|
|
166
165
|
- lib/up/bun/rack_server.rb
|
|
167
166
|
- lib/up/bun/server.rb
|
|
168
167
|
- lib/up/bun/server_cli.rb
|
data/lib/up/bun/rack_env.rb
DELETED
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
# backtick_javascript: true
|
|
2
|
-
|
|
3
|
-
require 'logger'
|
|
4
|
-
require 'up/version'
|
|
5
|
-
|
|
6
|
-
module Up
|
|
7
|
-
module Bun
|
|
8
|
-
class RackEnv < ::Hash
|
|
9
|
-
RACK_VARS = %w[rack.errors rack.hijack rack.hijack? rack.input rack.logger
|
|
10
|
-
rack.multipart.buffer_size rack.multipart.tempfile_factory
|
|
11
|
-
rack.response_finished
|
|
12
|
-
rack.session rack.upgrade rack.upgrade? rack.url_scheme
|
|
13
|
-
HTTP_ACCEPT HTTP_ACCEPT_ENCODING HTTP_ACCEPT_LANGUAGE
|
|
14
|
-
HTTP_CONNECTION HTTP_HOST HTTP_USER_AGENT PATH_INFO QUERY_STRING REQUEST_METHOD
|
|
15
|
-
SCRIPT_NAME SERVER_NAME SERVER_PROTOCOL SERVER_SOFTWARE]
|
|
16
|
-
def initialize(req, config)
|
|
17
|
-
@req = req
|
|
18
|
-
@config = config
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def [](key)
|
|
22
|
-
return super(key) if key?(key)
|
|
23
|
-
self[key] = case key
|
|
24
|
-
when 'rack.errors'
|
|
25
|
-
STDERR
|
|
26
|
-
when 'rack.logger'
|
|
27
|
-
@config[:logger]
|
|
28
|
-
when 'rack.multipart.buffer_size'
|
|
29
|
-
4096
|
|
30
|
-
when 'rack.multipart.tempfile_factory'
|
|
31
|
-
proc { |_filename, _content_type| File.new }
|
|
32
|
-
when 'rack.session'
|
|
33
|
-
{}
|
|
34
|
-
when 'rack.url_scheme'
|
|
35
|
-
@config[:scheme]
|
|
36
|
-
when 'PATH_INFO'
|
|
37
|
-
`#@req.url`
|
|
38
|
-
when 'QUERY_STRING'
|
|
39
|
-
""
|
|
40
|
-
when 'RACK_ERRORS'
|
|
41
|
-
self['rack.errors']
|
|
42
|
-
when 'RACK_LOGGER'
|
|
43
|
-
self['rack.logger']
|
|
44
|
-
when 'REQUEST_METHOD'
|
|
45
|
-
`#@req.method`
|
|
46
|
-
when 'SCRIPT_NAME'
|
|
47
|
-
""
|
|
48
|
-
when 'SERVER_NAME'
|
|
49
|
-
@config[:host]
|
|
50
|
-
when 'SERVER_PORT'
|
|
51
|
-
@config[:port].to_s
|
|
52
|
-
when 'SERVER_PROTOCOL'
|
|
53
|
-
""
|
|
54
|
-
when 'SERVER_SOFTWARE'
|
|
55
|
-
"#{@config[:handler]}/#{Up::VERSION} #{@config[:engine]}"
|
|
56
|
-
else
|
|
57
|
-
if key.start_with?('HTTP_')
|
|
58
|
-
key = key[5..].gsub(/_/, '-')
|
|
59
|
-
`#@req.headers.get(key.toLowerCase())`
|
|
60
|
-
else
|
|
61
|
-
nil
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def req_headers
|
|
67
|
-
h = {}
|
|
68
|
-
%x{
|
|
69
|
-
var hdr, hds = #@req.headers;
|
|
70
|
-
for (hdr of hds) { h.set(hdr[0], hdr[1]); }
|
|
71
|
-
}
|
|
72
|
-
h
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def each
|
|
76
|
-
unless @got_them_all
|
|
77
|
-
RACK_VARS.each { |k| self[k] unless self.key?(k) }
|
|
78
|
-
@got_them_all = true
|
|
79
|
-
end
|
|
80
|
-
super
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def to_s
|
|
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
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|