agoo 2.2.1 → 2.2.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of agoo might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/bin/agoo +57 -31
- data/ext/agoo/con.c +1 -7
- data/ext/agoo/hook.c +2 -0
- data/ext/agoo/page.c +10 -5
- data/lib/agoo/version.rb +1 -1
- data/lib/rack/handler/agoo.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9ec3fe82e8d4833d543ce7389dbf2c184fefed6ceee8b6ede337dd99588a69c4
|
4
|
+
data.tar.gz: 9b65a945479295f9b3663dd443e96d3f1b053536cf1062d10b6096d4b58cd333
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 335d419d49420ae7c091a2c89ba46830520be29041cdf18967a588c9bcf63383efbbddced7d65cab96d3d97f835b23b4c1f2a1749c2cb5591d3b66c89bb4af55
|
7
|
+
data.tar.gz: a25b384fcec18a72635a03c2f87218939adebcb3f18f63f912ab9c1e1fdbb04653cbb03f5598dfb3786113ad4496ee213d57d0971eeac254ca354a34253b45e7
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# CHANGELOG
|
2
2
|
|
3
|
+
### 2.2.2 - 2018-06-05
|
4
|
+
|
5
|
+
- Fixed `bin/agoo` which had become out of date.
|
6
|
+
|
7
|
+
- Added optimization description in `misc/optimize.md`.
|
8
|
+
|
9
|
+
- Fixed static file asset page caching bug.
|
10
|
+
|
3
11
|
### 2.2.1 - 2018-05-31
|
4
12
|
|
5
13
|
- Corrected header bug where a `:` in the value would cause an incorrect header key and value.
|
data/bin/agoo
CHANGED
@@ -22,10 +22,17 @@ Usage: agoo [options] [<handler_class>@<path>]...
|
|
22
22
|
|
23
23
|
version #{Agoo::VERSION}
|
24
24
|
|
25
|
-
Agoo is a Ruby web server. It can be run as a standalone application using
|
26
|
-
application. The handler/class arguments must have the form of
|
27
|
-
where the class is
|
28
|
-
|
25
|
+
Agoo is a Ruby web server. It can be run as a standalone application using
|
26
|
+
this application. The handler/class arguments must have the form of
|
27
|
+
<path>@<class> where the class is a Ruby class and the path is the URL path
|
28
|
+
that will be directed to the class or an instance of the class provided. If
|
29
|
+
the class implements a call() or on_request() method it will be used directly
|
30
|
+
otherwise an instance of the class will be created. The new method mut take no
|
31
|
+
arguments and have either a call() method or a on_request() method.
|
32
|
+
|
33
|
+
Example:
|
34
|
+
|
35
|
+
agoo -I example -r simple /simple@Simple
|
29
36
|
|
30
37
|
}
|
31
38
|
|
@@ -36,47 +43,66 @@ has either a call() method or a on_request() method.
|
|
36
43
|
@classic = true
|
37
44
|
@console = true
|
38
45
|
@colorize = true
|
46
|
+
@threads = 0
|
47
|
+
@workers = 0
|
48
|
+
@first = false
|
39
49
|
|
40
50
|
@opts = OptionParser.new(usage)
|
41
|
-
@opts.on('-h', '--help', 'Show this display.')
|
42
|
-
@opts.on('-s', '--silent', 'Silent.')
|
43
|
-
@opts.on('-v', '--verbose', 'Increase verbosity.')
|
44
|
-
@opts.on('-
|
45
|
-
@opts.on('-
|
46
|
-
@opts.on('-
|
47
|
-
@opts.on('--
|
48
|
-
@opts.on('
|
49
|
-
@opts.on('
|
50
|
-
@opts.on('--
|
51
|
+
@opts.on('-h', '--help', 'Show this display.') { puts @opts.help; Process.exit!(0) }
|
52
|
+
@opts.on('-s', '--silent', 'Silent.') { @verbose = 0 }
|
53
|
+
@opts.on('-v', '--verbose', 'Increase verbosity.') { @verbose += 1 }
|
54
|
+
@opts.on('-f', '--root_first', 'Check the root directory before the handle paths.') { @first = true }
|
55
|
+
@opts.on('-p', '--port PORT', Integer, 'Port to listen on.') { |p| @port = p }
|
56
|
+
@opts.on('-d', '--dir DIR', String, 'Directory to serve static assets from.') { |d| @root = d }
|
57
|
+
@opts.on('-r', '--require FILE', String, 'Ruby require.') { |r| require r }
|
58
|
+
@opts.on('-t', '--threads COUNT', Integer, 'Number of threads to use.') { |t| @threads = t }
|
59
|
+
@opts.on('-w', '--workers COUNT', Integer, 'Number of workers to use.') { |w| @workers = w }
|
60
|
+
@opts.on('--log.dir DIR', String, 'Log file directory.') { |d| @log_dir = d }
|
61
|
+
@opts.on('--[no-]log.classic', 'Classic log entries instead of JSON.') { |b| @classic = b }
|
62
|
+
@opts.on('--[no-]log.console', 'Display log entries on the console.') { |b| @console = b }
|
63
|
+
@opts.on('--[no-]log.colorize', 'Display log entries in color.') { |b| @colorize = b }
|
51
64
|
|
52
65
|
handler_paths = @opts.parse(ARGV)
|
53
66
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
67
|
+
@threads = 0 if @threads < 0
|
68
|
+
@workers = 1 if @workers < 1
|
69
|
+
|
70
|
+
Agoo::Log.configure(dir: @log_dir,
|
71
|
+
console: @console,
|
72
|
+
classic: @classic,
|
73
|
+
colorize: @colorize,
|
74
|
+
states: {
|
75
|
+
INFO: 1 <= @verbose,
|
76
|
+
DEBUG: 3 <= @verbose,
|
77
|
+
connect: 2 <= @verbose,
|
78
|
+
request: 2 <= @verbose,
|
79
|
+
response: 2 <= @verbose,
|
80
|
+
eval: 2 <= @verbose,
|
81
|
+
push: 2 <= @verbose,
|
82
|
+
})
|
83
|
+
|
84
|
+
Agoo::Server.init(@port, @root, thread_count: @threads, worker_count: @workers, root_first: @first)
|
85
|
+
|
68
86
|
puts "Agoo #{Agoo::VERSION} is listening on port #{@port}. Path mappings are:" if 1 <= @verbose
|
69
87
|
|
70
88
|
handler_paths.each { |hp|
|
71
|
-
|
89
|
+
path, classname = hp.split('@')
|
72
90
|
if classname.nil? || path.nil? || classname.empty? || path.empty?
|
73
91
|
raise "Invalid handler/path specification. Both a class and path must be present."
|
74
92
|
end
|
75
93
|
c = Object.const_get(classname)
|
76
|
-
|
94
|
+
if c.respond_to?(:call) || c.respond_to?(:on_request)
|
95
|
+
Agoo::Server.handle(nil, path, c)
|
96
|
+
else
|
97
|
+
Agoo::Server.handle(nil, path, c.new)
|
98
|
+
end
|
77
99
|
if 1 <= @verbose
|
78
100
|
puts " #{path} => #{classname}"
|
79
101
|
end
|
80
102
|
}
|
81
103
|
|
82
|
-
|
104
|
+
if handler_paths.empty?
|
105
|
+
puts "Agoo is only serving static files in '#{@root}'."
|
106
|
+
end
|
107
|
+
|
108
|
+
Agoo::Server.start()
|
data/ext/agoo/con.c
CHANGED
@@ -272,15 +272,9 @@ con_header_read(Con c) {
|
|
272
272
|
return bad_request(c, 500, __LINE__);
|
273
273
|
}
|
274
274
|
return -mlen;
|
275
|
-
|
276
|
-
// TBD int hook_or_page(method, path, pend, &hook)
|
277
|
-
// return http status
|
278
|
-
// 0 is not handled
|
279
|
-
// 200 means taken care of
|
280
|
-
// default (over 200) call bad_request
|
281
275
|
}
|
282
276
|
if (GET == method && the_server.root_first &&
|
283
|
-
|
277
|
+
NULL != (p = page_get(&err, &the_server.pages, path, (int)(pend - path)))) {
|
284
278
|
if (page_response(c, p, hend)) {
|
285
279
|
return bad_request(c, 500, __LINE__);
|
286
280
|
}
|
data/ext/agoo/hook.c
CHANGED
@@ -62,6 +62,8 @@ hook_create(Method method, const char *pattern, VALUE handler) {
|
|
62
62
|
hook->next = NULL;
|
63
63
|
if (T_STRING == rb_type(handler)) {
|
64
64
|
handler = resolve_classpath(StringValuePtr(handler), RSTRING_LEN(handler));
|
65
|
+
// TBD does class handle it or should an instance be made?
|
66
|
+
//
|
65
67
|
}
|
66
68
|
hook->handler = handler;
|
67
69
|
rb_gc_register_address(&handler);
|
data/ext/agoo/page.c
CHANGED
@@ -157,9 +157,9 @@ mime_set(Cache cache, const char *key, const char *value) {
|
|
157
157
|
}
|
158
158
|
for (s = *bucket; NULL != s; s = s->next) {
|
159
159
|
if (h == (int64_t)s->hash && len == s->klen &&
|
160
|
-
((0 <= len && len <= MAX_KEY_UNIQ) || 0 ==
|
160
|
+
((0 <= len && len <= MAX_KEY_UNIQ) || 0 == strncmp(s->key, key, len))) {
|
161
161
|
if (h == (int64_t)s->hash && len == s->klen &&
|
162
|
-
((0 <= len && len <= MAX_KEY_UNIQ) || 0 ==
|
162
|
+
((0 <= len && len <= MAX_KEY_UNIQ) || 0 == strncmp(s->key, key, len))) {
|
163
163
|
DEBUG_FREE(mem_mime_slot, s->value)
|
164
164
|
free(s->value);
|
165
165
|
s->value = strdup(value);
|
@@ -196,9 +196,9 @@ cache_set(Cache cache, const char *key, int klen, Page value) {
|
|
196
196
|
}
|
197
197
|
for (s = *bucket; NULL != s; s = s->next) {
|
198
198
|
if (h == (int64_t)s->hash && len == s->klen &&
|
199
|
-
((0 <= len && len <= MAX_KEY_UNIQ) || 0 ==
|
199
|
+
((0 <= len && len <= MAX_KEY_UNIQ) || 0 == strncmp(s->key, key, len))) {
|
200
200
|
if (h == (int64_t)s->hash && len == s->klen &&
|
201
|
-
((0 <= len && len <= MAX_KEY_UNIQ) || 0 ==
|
201
|
+
((0 <= len && len <= MAX_KEY_UNIQ) || 0 == strncmp(s->key, key, len))) {
|
202
202
|
old = s->value;
|
203
203
|
// replace
|
204
204
|
s->value = value;
|
@@ -216,7 +216,8 @@ cache_set(Cache cache, const char *key, int klen, Page value) {
|
|
216
216
|
if (NULL == key) {
|
217
217
|
*s->key = '\0';
|
218
218
|
} else {
|
219
|
-
|
219
|
+
strncpy(s->key, key, len);
|
220
|
+
s->key[len] = '\0';
|
220
221
|
}
|
221
222
|
s->value = value;
|
222
223
|
s->next = *bucket;
|
@@ -318,6 +319,9 @@ update_contents(Cache cache, Page p) {
|
|
318
319
|
break;
|
319
320
|
}
|
320
321
|
}
|
322
|
+
if (suffix <= p->path) {
|
323
|
+
suffix = NULL;
|
324
|
+
}
|
321
325
|
if (NULL != suffix) {
|
322
326
|
suffix++;
|
323
327
|
if (NULL == (mime = mime_get(cache, suffix))) {
|
@@ -369,6 +373,7 @@ update_contents(Cache cache, Page p) {
|
|
369
373
|
return false;
|
370
374
|
}
|
371
375
|
rewind(f);
|
376
|
+
|
372
377
|
// Format size plus space for the length, the mime type, and some
|
373
378
|
// padding. Then add the content length.
|
374
379
|
msize = sizeof(page_fmt) + 60 + size;
|
data/lib/agoo/version.rb
CHANGED
data/lib/rack/handler/agoo.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
|
2
|
-
require 'agoo'
|
2
|
+
require 'agoo' unless defined?(Agoo)
|
3
3
|
|
4
4
|
# Grand parent for the Agoo rack handler.
|
5
5
|
module Rack
|
@@ -15,7 +15,7 @@ module Rack
|
|
15
15
|
#
|
16
16
|
# - *:port [_Integer_] port to listen on
|
17
17
|
# - *:root [_String_] root or public directory for static assets
|
18
|
-
# - *:
|
18
|
+
# - *:root_first [_true_|_false_] if true look in the root directory first before calling Ruby hooks
|
19
19
|
# - *:wc* [_Integer_] number of workers to fork. Defaults to one which is not to fork.
|
20
20
|
# - */path=MyHandler* path and class name to handle requests on that path
|
21
21
|
def self.run(handler, options={})
|
@@ -40,7 +40,7 @@ module Rack
|
|
40
40
|
elsif :wc == k
|
41
41
|
worker_count = v.to_i
|
42
42
|
options.delete(k)
|
43
|
-
elsif :rmux == k
|
43
|
+
elsif :rmux == k || :root_first == k || :f == k
|
44
44
|
options[:root_first] = false
|
45
45
|
elsif k.nil?
|
46
46
|
not_found_handler = v
|
@@ -56,8 +56,8 @@ module Rack
|
|
56
56
|
options[:thread_count] = 0
|
57
57
|
options[:worker_count] = worker_count
|
58
58
|
::Agoo::Server.init(port, root, options)
|
59
|
-
path_map.each { |path,
|
60
|
-
::Agoo::Server.handle(nil, path,
|
59
|
+
path_map.each { |path,h|
|
60
|
+
::Agoo::Server.handle(nil, path, h)
|
61
61
|
}
|
62
62
|
begin
|
63
63
|
# If Rails is loaded this should work else just ignore.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: agoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oj
|