iodine 0.7.14 → 0.7.15
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.
Potentially problematic release.
This version of iodine might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +9 -8
- data/SPEC-PubSub-Draft.md +26 -22
- data/SPEC-Websocket-Draft.md +4 -4
- data/examples/sub-protocols.ru +90 -0
- data/exe/iodine +3 -1
- data/ext/iodine/fio.c +103 -69
- data/ext/iodine/fio.h +1 -1
- data/ext/iodine/fio_cli.c +26 -18
- data/ext/iodine/fio_cli.h +3 -1
- data/ext/iodine/fiobj_data.c +6 -1
- data/ext/iodine/fiobj_mustache.c +69 -13
- data/ext/iodine/http.c +26 -11
- data/ext/iodine/http1.c +3 -3
- data/ext/iodine/http_mime_parser.h +9 -0
- data/ext/iodine/iodine.c +34 -16
- data/ext/iodine/iodine_mustache.c +0 -65
- data/ext/iodine/iodine_pubsub.c +0 -1
- data/ext/iodine/mustache_parser.h +40 -14
- data/lib/iodine.rb +16 -8
- data/lib/iodine/version.rb +1 -1
- metadata +4 -3
@@ -50,71 +50,6 @@ static VALUE iodine_mustache_data_alloc_c(VALUE self) {
|
|
50
50
|
Parser Callbacks
|
51
51
|
***************************************************************************** */
|
52
52
|
|
53
|
-
/** HTML ecape table, created using the following Ruby Script:
|
54
|
-
|
55
|
-
a = (0..255).to_a.map {|i| i.chr }
|
56
|
-
# 100.times {|i| a[i] = "&\#x#{ i < 16 ? "0#{i.to_s(16)}" : i.to_s(16)};"}
|
57
|
-
100.times {|i| a[i] = "&\##{i.to_s(10)};"}
|
58
|
-
('a'.ord..'z'.ord).each {|i| a[i] = i.chr }
|
59
|
-
('A'.ord..'Z'.ord).each {|i| a[i] = i.chr }
|
60
|
-
('0'.ord..'9'.ord).each {|i| a[i] = i.chr }
|
61
|
-
a['<'.ord] = "<"
|
62
|
-
a['>'.ord] = ">"
|
63
|
-
a['&'.ord] = "&"
|
64
|
-
a['"'.ord] = """
|
65
|
-
a["\'".ord] = "'"
|
66
|
-
a['|'.ord] = "&\##{'|'.ord.to_s(10)};"
|
67
|
-
|
68
|
-
b = a.map {|s| s.length }
|
69
|
-
puts "static char *html_escape_strs[] = {", a.to_s.slice(1..-2) ,"};",
|
70
|
-
"static uint8_t html_escape_len[] = {", b.to_s.slice(1..-2),"};"
|
71
|
-
*/
|
72
|
-
static char *html_escape_strs[] = {
|
73
|
-
"�", "", "", "", "", "", "", "",
|
74
|
-
"", "	", " ", "", "", " ", "", "",
|
75
|
-
"", "", "", "", "", "", "", "",
|
76
|
-
"", "", "", "", "", "", "", "",
|
77
|
-
" ", "!", """, "#", "$", "%", "&", "'",
|
78
|
-
"(", ")", "*", "+", ",", "-", ".", "/",
|
79
|
-
"0", "1", "2", "3", "4", "5", "6", "7",
|
80
|
-
"8", "9", ":", ";", "<", "=", ">", "?",
|
81
|
-
"@", "A", "B", "C", "D", "E", "F", "G",
|
82
|
-
"H", "I", "J", "K", "L", "M", "N", "O",
|
83
|
-
"P", "Q", "R", "S", "T", "U", "V", "W",
|
84
|
-
"X", "Y", "Z", "[", "\", "]", "^", "_",
|
85
|
-
"`", "a", "b", "c", "d", "e", "f", "g",
|
86
|
-
"h", "i", "j", "k", "l", "m", "n", "o",
|
87
|
-
"p", "q", "r", "s", "t", "u", "v", "w",
|
88
|
-
"x", "y", "z", "{", "|", "}", "~", "\x7F",
|
89
|
-
"\x80", "\x81", "\x82", "\x83", "\x84", "\x85", "\x86", "\x87",
|
90
|
-
"\x88", "\x89", "\x8A", "\x8B", "\x8C", "\x8D", "\x8E", "\x8F",
|
91
|
-
"\x90", "\x91", "\x92", "\x93", "\x94", "\x95", "\x96", "\x97",
|
92
|
-
"\x98", "\x99", "\x9A", "\x9B", "\x9C", "\x9D", "\x9E", "\x9F",
|
93
|
-
"\xA0", "\xA1", "\xA2", "\xA3", "\xA4", "\xA5", "\xA6", "\xA7",
|
94
|
-
"\xA8", "\xA9", "\xAA", "\xAB", "\xAC", "\xAD", "\xAE", "\xAF",
|
95
|
-
"\xB0", "\xB1", "\xB2", "\xB3", "\xB4", "\xB5", "\xB6", "\xB7",
|
96
|
-
"\xB8", "\xB9", "\xBA", "\xBB", "\xBC", "\xBD", "\xBE", "\xBF",
|
97
|
-
"\xC0", "\xC1", "\xC2", "\xC3", "\xC4", "\xC5", "\xC6", "\xC7",
|
98
|
-
"\xC8", "\xC9", "\xCA", "\xCB", "\xCC", "\xCD", "\xCE", "\xCF",
|
99
|
-
"\xD0", "\xD1", "\xD2", "\xD3", "\xD4", "\xD5", "\xD6", "\xD7",
|
100
|
-
"\xD8", "\xD9", "\xDA", "\xDB", "\xDC", "\xDD", "\xDE", "\xDF",
|
101
|
-
"\xE0", "\xE1", "\xE2", "\xE3", "\xE4", "\xE5", "\xE6", "\xE7",
|
102
|
-
"\xE8", "\xE9", "\xEA", "\xEB", "\xEC", "\xED", "\xEE", "\xEF",
|
103
|
-
"\xF0", "\xF1", "\xF2", "\xF3", "\xF4", "\xF5", "\xF6", "\xF7",
|
104
|
-
"\xF8", "\xF9", "\xFA", "\xFB", "\xFC", "\xFD", "\xFE", "\xFF"};
|
105
|
-
static uint8_t html_escape_len[] = {
|
106
|
-
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
|
107
|
-
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 5, 5, 5, 5, 6, 5, 5, 5, 5, 5, 5, 5, 5,
|
108
|
-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 4, 5, 4, 5, 5, 1, 1, 1, 1, 1, 1, 1,
|
109
|
-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 5, 5, 5, 5,
|
110
|
-
5, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
111
|
-
1, 1, 1, 1, 6, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
112
|
-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
113
|
-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
114
|
-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
115
|
-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
116
|
-
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
|
117
|
-
|
118
53
|
static inline VALUE fiobj_mustache_find_obj_absolute(VALUE udata,
|
119
54
|
const char *name,
|
120
55
|
uint32_t name_len) {
|
data/ext/iodine/iodine_pubsub.c
CHANGED
@@ -524,7 +524,6 @@ void iodine_pubsub_init(void) {
|
|
524
524
|
rb_define_module_function(PubSubModule, "default", iodine_pubsub_default_get,
|
525
525
|
0);
|
526
526
|
rb_define_module_function(PubSubModule, "attach", iodine_pubsub_attach, 1);
|
527
|
-
rb_define_module_function(PubSubModule, "dettach", iodine_pubsub_detach, 1);
|
528
527
|
rb_define_module_function(PubSubModule, "detach", iodine_pubsub_detach, 1);
|
529
528
|
rb_define_module_function(PubSubModule, "reset", iodine_pubsub_reset, 1);
|
530
529
|
|
@@ -28,11 +28,6 @@ Feel free to copy, use and enjoy according to the license provided.
|
|
28
28
|
#include <sys/stat.h>
|
29
29
|
#include <sys/types.h>
|
30
30
|
|
31
|
-
#if !defined(MUSTACHE_NESTING_LIMIT) || !MUSTACHE_NESTING_LIMIT
|
32
|
-
#undef MUSTACHE_NESTING_LIMIT
|
33
|
-
#define MUSTACHE_NESTING_LIMIT 82
|
34
|
-
#endif
|
35
|
-
|
36
31
|
#if !defined(__GNUC__) && !defined(__clang__) && !defined(FIO_GNUC_BYPASS)
|
37
32
|
#define __attribute__(...)
|
38
33
|
#define __has_include(...) 0
|
@@ -47,6 +42,23 @@ Feel free to copy, use and enjoy according to the license provided.
|
|
47
42
|
#define MUSTACHE_FUNC static __attribute__((unused))
|
48
43
|
#endif
|
49
44
|
|
45
|
+
/* *****************************************************************************
|
46
|
+
Compile Time Behavior Flags
|
47
|
+
***************************************************************************** */
|
48
|
+
|
49
|
+
#ifndef MUSTACHE_USE_DYNAMIC_PADDING
|
50
|
+
#define MUSTACHE_USE_DYNAMIC_PADDING 1
|
51
|
+
#endif
|
52
|
+
|
53
|
+
#ifndef MUSTACHE_FAIL_ON_MISSING_TEMPLATE
|
54
|
+
#define MUSTACHE_FAIL_ON_MISSING_TEMPLATE 1
|
55
|
+
#endif
|
56
|
+
|
57
|
+
#if !defined(MUSTACHE_NESTING_LIMIT) || !MUSTACHE_NESTING_LIMIT
|
58
|
+
#undef MUSTACHE_NESTING_LIMIT
|
59
|
+
#define MUSTACHE_NESTING_LIMIT 82
|
60
|
+
#endif
|
61
|
+
|
50
62
|
/* *****************************************************************************
|
51
63
|
Mustache API Argument types
|
52
64
|
***************************************************************************** */
|
@@ -54,7 +66,7 @@ Mustache API Argument types
|
|
54
66
|
/** an opaque type for mustache template data (when caching). */
|
55
67
|
typedef struct mustache_s mustache_s;
|
56
68
|
|
57
|
-
/** Error reporting
|
69
|
+
/** Error reporting type. */
|
58
70
|
typedef enum mustache_error_en {
|
59
71
|
MUSTACHE_OK,
|
60
72
|
MUSTACHE_ERR_TOO_DEEP,
|
@@ -70,7 +82,7 @@ typedef enum mustache_error_en {
|
|
70
82
|
MUSTACHE_ERR_USER_ERROR,
|
71
83
|
} mustache_error_en;
|
72
84
|
|
73
|
-
/** Arguments for the `mustache_load` function. */
|
85
|
+
/** Arguments for the `mustache_load` function, used by the mustache parser. */
|
74
86
|
typedef struct {
|
75
87
|
/** The root template's file name. */
|
76
88
|
char const *filename;
|
@@ -94,10 +106,6 @@ REQUIRED: Define INCLUDE_MUSTACHE_IMPLEMENTATION only in the implementation file
|
|
94
106
|
*
|
95
107
|
* Before including the header within an implementation faile, define
|
96
108
|
* INCLUDE_MUSTACHE_IMPLEMENTATION as 1.
|
97
|
-
*
|
98
|
-
* When unset (or zero), this will expose the return error reporting and
|
99
|
-
* function argument types, allowing them to be exposed in a public facing API.
|
100
|
-
* exposure to the function return and argument types.
|
101
109
|
*/
|
102
110
|
#if INCLUDE_MUSTACHE_IMPLEMENTATION
|
103
111
|
|
@@ -214,6 +222,8 @@ Client Callbacks - MUST be implemented by the including file
|
|
214
222
|
* A conforming implementation will output the named argument's value (either
|
215
223
|
* HTML escaped or not, depending on the `escape` flag) as a string.
|
216
224
|
*
|
225
|
+
* A conforming implementation will test for dot notation in the name.
|
226
|
+
*
|
217
227
|
* NOTE: the `name` data is **not** NUL terminated. Use the `name_len` data to
|
218
228
|
* determine the actual string length.
|
219
229
|
*/
|
@@ -252,6 +262,8 @@ static int mustache_on_text(mustache_section_s *section, const char *data,
|
|
252
262
|
*
|
253
263
|
* NOTE: the `name` data is **not** NUL terminated. Use the `name_len` data to
|
254
264
|
* determine the actual string length.
|
265
|
+
*
|
266
|
+
* A conforming implementation will test for dot notation in the name.
|
255
267
|
*/
|
256
268
|
static int32_t mustache_on_section_test(mustache_section_s *section,
|
257
269
|
const char *name, uint32_t name_len,
|
@@ -271,6 +283,8 @@ static int32_t mustache_on_section_test(mustache_section_s *section,
|
|
271
283
|
*
|
272
284
|
* NOTE: the `name` data is **not** NUL terminated. Use the `name_len` data to
|
273
285
|
* determine the actual string length.
|
286
|
+
*
|
287
|
+
* A conforming implementation will test for dot notation in the name.
|
274
288
|
*/
|
275
289
|
static int mustache_on_section_start(mustache_section_s *section,
|
276
290
|
char const *name, uint32_t name_len,
|
@@ -553,7 +567,7 @@ static int mustache__write_escaped(mustache__builder_stack_s *s, char *text,
|
|
553
567
|
size_t pos = 0;
|
554
568
|
const char *end = text + len;
|
555
569
|
while (text < end) {
|
556
|
-
if (*text == '\n' && s->padding) {
|
570
|
+
if (MUSTACHE_USE_DYNAMIC_PADDING && *text == '\n' && s->padding) {
|
557
571
|
buffer[pos++] = '\n';
|
558
572
|
buffer[pos] = 0;
|
559
573
|
if (mustache_on_text(&s->stack[s->index].sec, buffer, pos) == -1)
|
@@ -591,7 +605,8 @@ static inline int mustache_write_text(mustache_section_s *section, char *text,
|
|
591
605
|
mustache__builder_stack_s *s = mustache___section2stack(section);
|
592
606
|
if (escape)
|
593
607
|
return mustache__write_escaped(s, text, len);
|
594
|
-
|
608
|
+
/* TODO */
|
609
|
+
#if MUSTACHE_USE_DYNAMIC_PADDING
|
595
610
|
char *end = memchr(text, '\n', len);
|
596
611
|
while (len && end) {
|
597
612
|
++end;
|
@@ -606,6 +621,11 @@ static inline int mustache_write_text(mustache_section_s *section, char *text,
|
|
606
621
|
}
|
607
622
|
if (len && mustache_on_text(&s->stack[s->index].sec, text, len) == -1)
|
608
623
|
return -1;
|
624
|
+
#else
|
625
|
+
if (mustache_on_text(&s->stack[s->index].sec, text, len) == -1)
|
626
|
+
return -1;
|
627
|
+
|
628
|
+
#endif
|
609
629
|
return 0;
|
610
630
|
}
|
611
631
|
|
@@ -629,7 +649,7 @@ typedef struct {
|
|
629
649
|
uint16_t path_len; /* if the file is in a folder, this marks the '/' */
|
630
650
|
} mustache__data_segment_s;
|
631
651
|
|
632
|
-
/*
|
652
|
+
/* data segment serialization, returns the number of bytes written. */
|
633
653
|
static inline size_t
|
634
654
|
mustache__data_segment_write(uint8_t *dest, mustache__data_segment_s data) {
|
635
655
|
dest[0] = 0xFF & data.inst_start;
|
@@ -653,6 +673,8 @@ mustache__data_segment_write(uint8_t *dest, mustache__data_segment_s data) {
|
|
653
673
|
static inline size_t mustache__data_segment_length(size_t filename_len) {
|
654
674
|
return 13 + filename_len;
|
655
675
|
}
|
676
|
+
|
677
|
+
/* data segment serialization, reads data from raw stream. */
|
656
678
|
static inline mustache__data_segment_s
|
657
679
|
mustache__data_segment_read(uint8_t *data) {
|
658
680
|
mustache__data_segment_s s = {
|
@@ -907,8 +929,12 @@ static inline ssize_t mustache__load_file(mustache__loader_stack_s *s,
|
|
907
929
|
}
|
908
930
|
}
|
909
931
|
|
932
|
+
#if MUSTACHE_FAIL_ON_MISSING_TEMPLATE
|
910
933
|
*s->err = MUSTACHE_ERR_FILE_NOT_FOUND;
|
911
934
|
return -1;
|
935
|
+
#else
|
936
|
+
return 0;
|
937
|
+
#endif
|
912
938
|
|
913
939
|
file_found:
|
914
940
|
if (f_data.st_size >= INT32_MAX) {
|
data/lib/iodine.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'socket'
|
1
|
+
require 'socket' # TCPSocket is used internally for Hijack support
|
2
2
|
|
3
3
|
require 'iodine/version'
|
4
4
|
require 'iodine/iodine'
|
@@ -65,12 +65,12 @@ module Iodine
|
|
65
65
|
def self.patch_rack
|
66
66
|
begin
|
67
67
|
require 'rack'
|
68
|
-
rescue LoadError
|
68
|
+
rescue LoadError
|
69
69
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
::Rack::Utils.class_eval do
|
71
|
+
Iodine::Base::MonkeyPatch::RackUtils.methods(false).each do |m|
|
72
|
+
::Rack::Utils.define_singleton_method(m,
|
73
|
+
Iodine::Base::MonkeyPatch::RackUtils.instance_method(m) )
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
@@ -114,12 +114,20 @@ module Iodine
|
|
114
114
|
Iodine.on_state(:on_finish, &block)
|
115
115
|
end
|
116
116
|
|
117
|
+
module PubSub
|
118
|
+
# @deprecated use {Iodine::PubSub.detach}.
|
119
|
+
def self.dettach(engine)
|
120
|
+
warn "Iodine::PubSub.dettach is deprecated (was a typo), use Iodine::PubSub.detach(engine)."
|
121
|
+
Iodine::PubSub.detach(engine)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
117
125
|
end
|
118
126
|
|
119
127
|
require 'rack/handler/iodine' unless defined? ::Iodine::Rack::IODINE_RACK_LOADED
|
120
128
|
|
121
129
|
|
122
|
-
### Automatic ActiveRecord and Sequel
|
130
|
+
### Automatic ActiveRecord and Sequel support for forking (preventing connection sharing)
|
123
131
|
Iodine.on_state(:before_fork) do
|
124
132
|
if defined?(ActiveRecord) && defined?(ActiveRecord::Base) && ActiveRecord::Base.respond_to?(:connection)
|
125
133
|
begin
|
@@ -144,7 +152,7 @@ Iodine.on_state(:after_fork) do
|
|
144
152
|
end
|
145
153
|
|
146
154
|
### Parse CLI for default HTTP settings
|
147
|
-
Iodine::Base::CLI.parse
|
155
|
+
Iodine::Base::CLI.parse
|
148
156
|
|
149
157
|
### Initialize Redis if set in CLI
|
150
158
|
Iodine::PubSub.default = Iodine::PubSub::Redis.new(Iodine::DEFAULT_HTTP_ARGS[:redis_], ping: Iodine::DEFAULT_HTTP_ARGS[:redis_ping_]) if Iodine::DEFAULT_HTTP_ARGS[:redis_]
|
data/lib/iodine/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iodine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Boaz Segev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-12-
|
11
|
+
date: 2018-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -125,6 +125,7 @@ files:
|
|
125
125
|
- examples/pubsub_engine.ru
|
126
126
|
- examples/redis.ru
|
127
127
|
- examples/shootout.ru
|
128
|
+
- examples/sub-protocols.ru
|
128
129
|
- exe/iodine
|
129
130
|
- ext/iodine/extconf.rb
|
130
131
|
- ext/iodine/fio.c
|
@@ -210,7 +211,7 @@ licenses:
|
|
210
211
|
- MIT
|
211
212
|
metadata:
|
212
213
|
allowed_push_host: https://rubygems.org
|
213
|
-
post_install_message: 'Thank you for installing Iodine 0.7.
|
214
|
+
post_install_message: 'Thank you for installing Iodine 0.7.15.
|
214
215
|
|
215
216
|
'
|
216
217
|
rdoc_options: []
|